@checkdigit/eslint-plugin 7.8.0-PR.97-e271 → 7.8.0-PR.97-7207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/no-status-code-assert.ts
|
|
2
|
+
import { StatusCodes } from "http-status-codes";
|
|
2
3
|
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
4
|
import getDocumentationUrl from "./get-documentation-url.mjs";
|
|
4
5
|
var ruleId = "no-status-code-assert";
|
|
@@ -14,6 +15,11 @@ var hasStatusCodeOrValue = (arg) => {
|
|
|
14
15
|
}
|
|
15
16
|
break;
|
|
16
17
|
}
|
|
18
|
+
case AST_NODE_TYPES.Literal:
|
|
19
|
+
if (typeof arg.value === "number" && Object.values(StatusCodes).includes(arg.value)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
break;
|
|
17
23
|
case AST_NODE_TYPES.BinaryExpression:
|
|
18
24
|
return hasStatusCodeOrValue(arg.left) || hasStatusCodeOrValue(arg.right);
|
|
19
25
|
}
|
|
@@ -54,4 +60,4 @@ export {
|
|
|
54
60
|
no_status_code_assert_default as default,
|
|
55
61
|
ruleId
|
|
56
62
|
};
|
|
57
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL25vLXN0YXR1cy1jb2RlLWFzc2VydC50cyJdLAogICJtYXBwaW5ncyI6ICI7QUFRQSxTQUFTLG1CQUFtQjtBQUM1QixTQUFTLGdCQUFnQixtQkFBdUM7QUFDaEUsT0FBTyx5QkFBeUI7QUFFekIsSUFBTSxTQUFTO0FBQ3RCLElBQU0sd0JBQXdCO0FBRTlCLElBQU0sYUFBYSxZQUFZLFlBQVksQ0FBQyxTQUFTLG9CQUFvQixJQUFJLENBQUM7QUFHOUUsSUF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Q04sTUFBTTtBQUFBLE1BQ0osYUFBYTtBQUFBLElBQ2Y7QUFBQSxJQUNBLFFBQVEsQ0FBQztBQUFBLElBQ1QsVUFBVTtBQUFBLE1BQ1IsQ0FBQyxxQkFBcUIsR0FBRztBQUFBLElBQzNCO0FBQUEsRUFDRjtBQUFBLEVBQ0EsZ0JBQWdCLENBQUM7QUFBQSxFQUNqQixPQUFPLFNBQVM7QUFDZCxXQUFPO0FBQUEsTUFDTCxlQUFlLE1BQStCO0FBQzVDLGNBQU0sU0FBUyxLQUFLO0FBQ3BCLFlBQUksMkJBQTJCLFFBQVEsS0FBSyxTQUFTLEdBQUc7QUFDdEQsa0JBQVEsT0FBTztBQUFBLFlBQ2I7QUFBQSxZQUNBLFdBQVc7QUFBQSxVQUNiLENBQUM7QUFBQSxRQUNIO0FBQUEsTUFDRjtBQUFBLElBQ0Y7QUFBQSxFQUNGO0FBQ0YsQ0FBQztBQUVELElBQU8sZ0NBQVE7IiwKICAibmFtZXMiOiBbXQp9Cg==
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@checkdigit/eslint-plugin","version":"7.8.0-PR.97-
|
|
1
|
+
{"name":"@checkdigit/eslint-plugin","version":"7.8.0-PR.97-7207","description":"Check Digit eslint plugins","keywords":["eslint","eslintplugin"],"homepage":"https://github.com/checkdigit/eslint-plugin#readme","bugs":{"url":"https://github.com/checkdigit/eslint-plugin/issues"},"repository":{"type":"git","url":"https://github.com/checkdigit/eslint-plugin"},"license":"MIT","author":"Check Digit, LLC","sideEffects":false,"type":"module","exports":{".":{"types":"./dist-types/index.d.ts","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["src","dist-types","dist-mjs","!src/**/test/**","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/test/**","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-mjs/**/test/**","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md"],"scripts":{"build:dist-mjs":"rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-types","ci:compile":"tsc --noEmit","ci:coverage":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=true","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false","lint":"eslint --max-warnings 0 .","lint:fix":"eslint --max-warnings 0 --fix .","prepare":"","prepublishOnly":"npm run build:dist-types && npm run build:dist-mjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style"},"prettier":"@checkdigit/prettier-config","jest":{"preset":"@checkdigit/jest-config"},"dependencies":{"@typescript-eslint/type-utils":"^8.18.1","@typescript-eslint/utils":"^8.18.1","ts-api-utils":"^2.0.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^6.0.0","@checkdigit/typescript-config":"^9.0.0","@eslint/js":"^9.17.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.18.1","@typescript-eslint/rule-tester":"^8.18.1","eslint":"^9.17.0","eslint-config-prettier":"^9.1.0","eslint-import-resolver-typescript":"^3.7.0","eslint-plugin-eslint-plugin":"^6.3.2","eslint-plugin-import":"^2.31.0","eslint-plugin-no-only-tests":"^3.3.0","eslint-plugin-no-secrets":"^2.1.1","eslint-plugin-node":"^11.1.0","eslint-plugin-sonarjs":"1.0.4","http-status-codes":"^2.3.0","rimraf":"^6.0.1","typescript-eslint":"^8.18.1"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { StatusCodes } from 'http-status-codes';
|
|
9
10
|
import { AST_NODE_TYPES, ESLintUtils, TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
10
11
|
import getDocumentationUrl from './get-documentation-url';
|
|
11
12
|
|
|
@@ -29,6 +30,11 @@ const hasStatusCodeOrValue = (arg: TSESTree.Node): boolean => {
|
|
|
29
30
|
}
|
|
30
31
|
break;
|
|
31
32
|
}
|
|
33
|
+
case AST_NODE_TYPES.Literal:
|
|
34
|
+
if (typeof arg.value === 'number' && Object.values(StatusCodes).includes(arg.value)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
32
38
|
case AST_NODE_TYPES.BinaryExpression:
|
|
33
39
|
return hasStatusCodeOrValue(arg.left) || hasStatusCodeOrValue(arg.right);
|
|
34
40
|
}
|