Skip to content

Commit

Permalink
kill old eslint rule
Browse files Browse the repository at this point in the history
ci for github wasm
update call util.ts to try to improve
  • Loading branch information
badetitou committed Mar 19, 2024
1 parent 6ce96d9 commit 7edadcf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 94 deletions.
35 changes: 2 additions & 33 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
Expand Down Expand Up @@ -86,9 +86,7 @@
"eqeqeq": ["error", "smart"],
"guard-for-in": "error",
"id-match": "error",
"import/no-deprecated": "warn",
"import/order": "off",
"jsdoc/no-types": "error",
"max-classes-per-file": "off",
"max-len": [
"error",
Expand Down Expand Up @@ -155,7 +153,6 @@
"no-var": "error",
"object-shorthand": "error",
"one-var": ["error", "never"],
"prefer-arrow/prefer-arrow-functions": "error",
"prefer-const": "error",
"quote-props": ["error", "as-needed"],
"radix": "error",
Expand All @@ -169,33 +166,5 @@
],
"spaced-comment": "error",
"use-isnan": "error",
"valid-typeof": "off",
"@typescript-eslint/tslint/config": [
"error",
{
"rules": {
"import-spacing": true,
"jsdoc-format": true,
"no-reference-import": true,
"one-line": [
true,
"check-catch",
"check-else",
"check-finally",
"check-open-brace",
"check-whitespace"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
}
}
]
}
"valid-typeof": "off"
}
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- main
- wasm

jobs:
build:
Expand All @@ -14,7 +15,7 @@ jobs:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm test
Expand Down
66 changes: 6 additions & 60 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const makeMetadataKeyWithContext = (
if (options.contextGroup != null && !regExp.test(options.contextGroup)) {
// eslint-disable-next-line max-len
throw new JacksonError(
// eslint-disable-next-line max-len
`Invalid context group name "${options.contextGroup}" found! The context group name must match "/^[\\w]+$/" regular expression, that is a non-empty string which contains any alphanumeric character including the underscore.`
);
}
Expand Down Expand Up @@ -903,68 +904,13 @@ export const isInt = (n: number) => Number(n) === n && n % 1 === 0;
*/
export const isFloat = (n: number) => Number(n) === n && n % 1 !== 0;

/**
* find metadata considering also _internalDecorators
* @internal
*/
// export const findMetadataByMetadataKeyWithContext = <T extends JsonDecoratorOptions>(
// metadataKeyWithContext: string,
// target: Record<string, any>,
// propertyKey: string | symbol = null,
// context: JsonStringifierParserCommonContext<any>): T => {

// let jsonDecoratorOptions: JsonDecoratorOptions = (propertyKey) ?
// Reflect.getMetadata(metadataKeyWithContext, target, propertyKey) :
// Reflect.getMetadata(metadataKeyWithContext, target);

// // search also on its prototype chain
// let parent = target;
// while (jsonDecoratorOptions == null && parent.name) {
// if (jsonDecoratorOptions == null && propertyKey == null && context != null && context._internalDecorators != null) {
// const map = context._internalDecorators.get(parent as ObjectConstructor);
// if (map != null && metadataKeyWithContext in map) {
// jsonDecoratorOptions = map[metadataKeyWithContext] as JsonDecoratorOptions;
// }
// }
// // get parent class
// parent = Object.getPrototypeOf(parent);
// }

// return jsonDecoratorOptions as T;
// };

export const findMetadataByMetadataKeyWithContext = <
T extends JsonDecoratorOptions
>(
metadataKeyWithContext: string,
target: Record<string, any>,
propertyKey: string | symbol = null,
context: JsonStringifierParserCommonContext<any>
): T => {
if (propertyKey == null) {
return find_metadata_by_metadata_key_with_context(
metadataKeyWithContext,
target,
null,
context
);
} else {
return find_metadata_by_metadata_key_with_context(
metadataKeyWithContext,
target,
propertyKey.toString(),
context
);
}
};

/**
* @internal
*/
export const findMetadata = <T extends JsonDecoratorOptions>(
metadataKey: string,
target: Record<string, any>,
propertyKey: string | symbol = null,
propertyKey: string = null,
context: JsonStringifierParserCommonContext<any>
): T => {
let jsonDecoratorOptions: JsonDecoratorOptions = null;
Expand All @@ -979,7 +925,7 @@ export const findMetadata = <T extends JsonDecoratorOptions>(
contextGroup,
});

jsonDecoratorOptions = findMetadataByMetadataKeyWithContext(
jsonDecoratorOptions = find_metadata_by_metadata_key_with_context(
metadataKeyWithContext,
target,
propertyKey,
Expand All @@ -1000,13 +946,13 @@ export const findMetadata = <T extends JsonDecoratorOptions>(
export const getMetadata = <T extends JsonDecoratorOptions>(
metadataKey: string,
target: Record<string, any>,
propertyKey: string | symbol = null,
propertyKey: string = null,
context: JsonStringifierParserCommonContext<any>
): T => {
const jsonDecoratorOptions: JsonDecoratorOptions = metadataKey.startsWith(
'jackson:'
)
? findMetadataByMetadataKeyWithContext(
? find_metadata_by_metadata_key_with_context(
metadataKey,
target,
propertyKey,
Expand Down Expand Up @@ -1119,7 +1065,7 @@ export const getMetadataKeys = <T extends JsonDecoratorOptions>(
export const hasMetadata = <T extends JsonDecoratorOptions>(
metadataKey: string,
target: Record<string, any>,
propertyKey: string | symbol = null,
propertyKey: string = null,
context: JsonStringifierParserCommonContext<any>
): boolean => {
const option: JsonDecoratorOptions = getMetadata<T>(
Expand Down

0 comments on commit 7edadcf

Please sign in to comment.