@checkdigit/eslint-plugin 7.6.0-PR.97-68dc → 7.6.0-PR.97-b2ae

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.
@@ -5,8 +5,8 @@ var ruleId = "no-status-code-assert";
5
5
  var NO_STATUS_CODE_ASSERT = "NO_STATUS_CODE_ASSERT";
6
6
  var keywords = ["status", "code", "StatusCodes", "statusCode"];
7
7
  var createRule = ESLintUtils.RuleCreator((name) => getDocumentationUrl(name));
8
- var checkName = (name) => name !== void 0 && keywords.some((keyword) => name.toLowerCase().includes(keyword));
9
8
  var hasStatusCodeOrValue = (arg) => {
9
+ const checkName = (name) => name !== void 0 && keywords.some((keyword) => name.toLowerCase().includes(keyword));
10
10
  switch (arg.type) {
11
11
  case AST_NODE_TYPES.Identifier:
12
12
  return checkName(arg.name);
@@ -29,6 +29,8 @@ var hasStatusCodeOrValue = (arg) => {
29
29
  }
30
30
  return false;
31
31
  };
32
+ var isAssertIdentifier = (node) => node.type === AST_NODE_TYPES.Identifier && node.name === "assert";
33
+ var isAssertMemberExpression = (node) => node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.Identifier && node.object.name === "assert" && node.property.type === AST_NODE_TYPES.Identifier;
32
34
  var rule = createRule({
33
35
  name: ruleId,
34
36
  meta: {
@@ -45,7 +47,8 @@ var rule = createRule({
45
47
  create(context) {
46
48
  return {
47
49
  CallExpression(node) {
48
- if (node.arguments.some(hasStatusCodeOrValue)) {
50
+ const callee = node.callee;
51
+ if ((isAssertIdentifier(callee) || isAssertMemberExpression(callee)) && node.arguments.some(hasStatusCodeOrValue)) {
49
52
  context.report({
50
53
  node,
51
54
  messageId: NO_STATUS_CODE_ASSERT
@@ -60,4 +63,4 @@ export {
60
63
  no_status_code_assert_default as default,
61
64
  ruleId
62
65
  };
63
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3Jj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1BQU07QUFBQSxJQUNOLE1BQU07QUFBQSxNQUNKLGFBQWE7QUFBQSxJQUNmO0FBQUEsSUFDQSxRQUFRLENBQUM7QUFBQSxJQUNULFVBQVU7QUFBQSxNQUNSLENBQUMscUJBQXFCLEdBQUc7QUFBQSxJQUMzQjtBQUFBLEVBQ0Y7QUFBQSxFQUNBLGdCQUFnQixDQUFDO0FBQUEsRUFDakIsT0FBTyxTQUFTO0FBQ2QsV0FBTztBQUFBLE1BQ0wsZUFBZSxNQUErQjtBQUM1QyxjQUFNLFNBQVMsS0FBSztBQUNwQixhQUNHLG1CQUFtQixNQUFNLEtBQUsseUJBQXlCLE1BQU0sTUFDOUQsS0FBSyxVQUFVLEtBQUssb0JBQW9CLEdBQ3hDO0FBQ0Esa0JBQVEsT0FBTztBQUFBLFlBQ2I7QUFBQSxZQUNBLFdBQVc7QUFBQSxVQUNiLENBQUM7QUFBQSxRQUNIO0FBQUEsTUFDRjtBQUFBLElBQ0Y7QUFBQSxFQUNGO0FBQ0YsQ0FBQztBQUVELElBQU8sZ0NBQVE7IiwKICAibmFtZXMiOiBbXQp9Cg==
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@checkdigit/eslint-plugin","version":"7.6.0-PR.97-68dc","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.15.0","@typescript-eslint/utils":"^8.15.0","ts-api-utils":"^1.4.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^5.5.1","@checkdigit/typescript-config":"^8.0.0","@eslint/js":"^9.15.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.15.0","@typescript-eslint/rule-tester":"^8.15.0","eslint":"^9.15.0","eslint-config-prettier":"^9.1.0","eslint-import-resolver-typescript":"^3.6.3","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":"^1.1.2","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.15.0"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
1
+ {"name":"@checkdigit/eslint-plugin","version":"7.6.0-PR.97-b2ae","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.15.0","@typescript-eslint/utils":"^8.15.0","ts-api-utils":"^1.4.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^5.5.1","@checkdigit/typescript-config":"^8.0.0","@eslint/js":"^9.15.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.15.0","@typescript-eslint/rule-tester":"^8.15.0","eslint":"^9.15.0","eslint-config-prettier":"^9.1.0","eslint-import-resolver-typescript":"^3.6.3","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":"^1.1.2","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.15.0"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
@@ -15,15 +15,6 @@ const keywords = ['status', 'code', 'StatusCodes', 'statusCode'];
15
15
 
16
16
  const createRule = ESLintUtils.RuleCreator((name) => getDocumentationUrl(name));
17
17
 
18
- /**
19
- * Checks if a given string contains any of the specified keywords ('status', 'code', 'StatusCodes', or 'statusCode').
20
- *
21
- * @param name - The string to check.
22
- * @returns `true` if the string contains any of the specified keywords, otherwise `false`.
23
- */
24
- const checkName = (name?: string): boolean =>
25
- name !== undefined && keywords.some((keyword) => name.toLowerCase().includes(keyword));
26
-
27
18
  /**
28
19
  * Checks if a given AST node contains any identifier, member expression, or binary expression
29
20
  * that includes the keywords 'status', 'code', 'StatusCodes', or 'statusCode'.
@@ -32,6 +23,9 @@ const checkName = (name?: string): boolean =>
32
23
  * @returns `true` if the node or its sub-nodes contain any of the specified keywords, otherwise `false`.
33
24
  */
34
25
  const hasStatusCodeOrValue = (arg: TSESTree.Node): boolean => {
26
+ const checkName = (name?: string): boolean =>
27
+ name !== undefined && keywords.some((keyword) => name.toLowerCase().includes(keyword));
28
+
35
29
  switch (arg.type) {
36
30
  case AST_NODE_TYPES.Identifier:
37
31
  return checkName(arg.name);
@@ -55,6 +49,27 @@ const hasStatusCodeOrValue = (arg: TSESTree.Node): boolean => {
55
49
  return false;
56
50
  };
57
51
 
52
+ /**
53
+ * Checks if a given AST node is an identifier with the name 'assert'.
54
+ *
55
+ * @param node - The AST node to check.
56
+ * @returns `true` if the node is an identifier with the name 'assert', otherwise `false`.
57
+ */
58
+ const isAssertIdentifier = (node: TSESTree.Node): boolean =>
59
+ node.type === AST_NODE_TYPES.Identifier && node.name === 'assert';
60
+
61
+ /**
62
+ * Checks if a given AST node is a member expression with the object named 'assert'.
63
+ *
64
+ * @param node - The AST node to check.
65
+ * @returns `true` if the node is a member expression with the object named 'assert', otherwise `false`.
66
+ */
67
+ const isAssertMemberExpression = (node: TSESTree.Node): boolean =>
68
+ node.type === AST_NODE_TYPES.MemberExpression &&
69
+ node.object.type === AST_NODE_TYPES.Identifier &&
70
+ node.object.name === 'assert' &&
71
+ node.property.type === AST_NODE_TYPES.Identifier;
72
+
58
73
  const rule: TSESLint.RuleModule<typeof NO_STATUS_CODE_ASSERT> = createRule({
59
74
  name: ruleId,
60
75
  meta: {
@@ -71,7 +86,11 @@ const rule: TSESLint.RuleModule<typeof NO_STATUS_CODE_ASSERT> = createRule({
71
86
  create(context) {
72
87
  return {
73
88
  CallExpression(node: TSESTree.CallExpression) {
74
- if (node.arguments.some(hasStatusCodeOrValue)) {
89
+ const callee = node.callee;
90
+ if (
91
+ (isAssertIdentifier(callee) || isAssertMemberExpression(callee)) &&
92
+ node.arguments.some(hasStatusCodeOrValue)
93
+ ) {
75
94
  context.report({
76
95
  node,
77
96
  messageId: NO_STATUS_CODE_ASSERT,