@checkdigit/eslint-plugin 7.2.0-PR.66-49d4 → 7.2.0-PR.79-490a

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.
package/README.md CHANGED
@@ -13,12 +13,12 @@ Copyright (c) 2021-2024 [Check Digit, LLC](https://checkdigit.com)
13
13
  - `@checkdigit/require-assert-predicate-rejects-throws`
14
14
  - `@checkdigit/object-literal-response`
15
15
  - `@checkdigit/no-test-import`
16
- - `@checkdigit/no-side-effects`
17
16
  - `@checkdigit/no-promise-instance-method`
18
17
  - `@checkdigit/invalid-json-stringify`
19
18
  - `@checkdigit/no-full-response`
20
19
  - `@checkdigit/require-resolve-full-response`
21
20
  - `@checkdigit/require-type-out-of-type-only-imports`
21
+ - `@checkdigit/no-enum`
22
22
 
23
23
  ## Configurations
24
24
 
@@ -14,7 +14,7 @@ import requireTypeOutOfTypeOnlyImports, {
14
14
  } from "./require-type-out-of-type-only-imports.mjs";
15
15
  import filePathComment from "./file-path-comment.mjs";
16
16
  import noCardNumbers from "./no-card-numbers.mjs";
17
- import noSideEffects from "./no-side-effects.mjs";
17
+ import noEnum from "./no-enum.mjs";
18
18
  import noTestImport from "./no-test-import.mjs";
19
19
  import noUuid from "./no-uuid.mjs";
20
20
  import noWallabyComment from "./no-wallaby-comment.mjs";
@@ -25,11 +25,11 @@ import requireStrictAssert from "./require-strict-assert.mjs";
25
25
  var rules = {
26
26
  "file-path-comment": filePathComment,
27
27
  "no-card-numbers": noCardNumbers,
28
+ "no-enum": noEnum,
28
29
  "no-uuid": noUuid,
29
30
  "require-strict-assert": requireStrictAssert,
30
31
  "no-test-import": noTestImport,
31
32
  "no-wallaby-comment": noWallabyComment,
32
- "no-side-effects": noSideEffects,
33
33
  "regular-expression-comment": regexComment,
34
34
  "require-assert-predicate-rejects-throws": requireAssertPredicateRejectsThrows,
35
35
  "object-literal-response": objectLiteralResponse,
@@ -51,11 +51,11 @@ var configs = {
51
51
  },
52
52
  rules: {
53
53
  "@checkdigit/no-card-numbers": "error",
54
+ "@checkdigit/no-enum": "error",
54
55
  "@checkdigit/file-path-comment": "error",
55
56
  "@checkdigit/no-uuid": "error",
56
57
  "@checkdigit/require-strict-assert": "error",
57
58
  "@checkdigit/no-wallaby-comment": "error",
58
- "@checkdigit/no-side-effects": ["error", { excludedIdentifiers: ["assert", "debug", "log", "promisify"] }],
59
59
  "@checkdigit/regular-expression-comment": "error",
60
60
  "@checkdigit/require-assert-predicate-rejects-throws": "error",
61
61
  "@checkdigit/object-literal-response": "error",
@@ -75,11 +75,11 @@ var configs = {
75
75
  },
76
76
  rules: {
77
77
  "@checkdigit/no-card-numbers": "error",
78
+ "@checkdigit/no-enum": "error",
78
79
  "@checkdigit/file-path-comment": "off",
79
80
  "@checkdigit/no-uuid": "error",
80
81
  "@checkdigit/require-strict-assert": "error",
81
82
  "@checkdigit/no-wallaby-comment": "off",
82
- "@checkdigit/no-side-effects": "error",
83
83
  "@checkdigit/regular-expression-comment": "error",
84
84
  "@checkdigit/require-assert-predicate-rejects-throws": "error",
85
85
  "@checkdigit/object-literal-response": "error",
@@ -97,4 +97,4 @@ var src_default = pluginToExport;
97
97
  export {
98
98
  src_default as default
99
99
  };
100
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2luZGV4LnRzIl0sCiAgIm1hcHBpbmdzIjogIjtBQVVBLE9BQU8sd0JBQXdCLFVBQVUsa0NBQWtDO0FBQzNFLE9BQU8sdUJBQXVCLFVBQVUsaUNBQWlDO0FBQ3pFLE9BQU8sa0JBQWtCLFVBQVUsNEJBQTRCO0FBQy9ELE9BQU8sMkJBQTJCLFVBQVUscUNBQXFDO0FBQ2pGLE9BQU87QUFBQSxFQUNMLFVBQVU7QUFBQSxPQUNMO0FBQ1AsT0FBTztBQUFBLEVBQ0wsVUFBVTtBQUFBLE9BQ0w7QUFDUCxPQUFPO0FBQUEsRUFDTCxVQUF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EsSUFDdkQ7QUFBQSxFQUNGO0FBQUEsRUFDQSxhQUFhO0FBQUEsSUFDWCxTQUFTO0FBQUEsTUFDUCxlQUFlO0FBQUEsSUFDakI7QUFBQSxJQUNBLE9BQU87QUFBQSxNQUNMLCtCQUErQjtBQUFBLE1BQy9CLHVCQUF1QjtBQUFBLE1BQ3ZCLGlDQUFpQztBQUFBLE1BQ2pDLHVCQUF1QjtBQUFBLE1BQ3ZCLHFDQUFxQztBQUFBLE1BQ3JDLGtDQUFrQztBQUFBLE1BQ2xDLDBDQUEwQztBQUFBLE1BQzFDLHVEQUF1RDtBQUFBLE1BQ3ZELHVDQUF1QztBQUFBLE1BQ3ZDLDhCQUE4QjtBQUFBLE1BQzlCLENBQUMsZUFBZSwwQkFBMEIsRUFBRSxHQUFHO0FBQUEsTUFDL0MsQ0FBQyxlQUFlLDZCQUE2QixFQUFFLEdBQUc7QUFBQSxJQUNwRDtBQUFBLEVBQ0Y7QUFDRjtBQUVBLElBQU0saUJBQTZDO0FBQUEsRUFDakQsR0FBRztBQUFBLEVBQ0g7QUFDRjtBQUNBLElBQU8sY0FBUTsiLAogICJuYW1lcyI6IFtdCn0K
@@ -0,0 +1,52 @@
1
+ // src/no-enum.ts
2
+ import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
3
+ var ruleId = "no-enum";
4
+ var NO_ENUM = "NO_ENUM";
5
+ var createRule = ESLintUtils.RuleCreator((name) => name);
6
+ function isJsonSchemaProperty(node) {
7
+ if (!node) {
8
+ return false;
9
+ }
10
+ if (node.type === TSESTree.AST_NODE_TYPES.Property && node.key.type === TSESTree.AST_NODE_TYPES.Identifier && node.key.name === "properties") {
11
+ return true;
12
+ }
13
+ return isJsonSchemaProperty(node.parent);
14
+ }
15
+ var rule = createRule({
16
+ name: ruleId,
17
+ meta: {
18
+ type: "problem",
19
+ docs: {
20
+ description: "Disallow the use of `enum` in TypeScript"
21
+ },
22
+ schema: [],
23
+ messages: {
24
+ [NO_ENUM]: "Avoid using `enum` in TypeScript."
25
+ }
26
+ },
27
+ defaultOptions: [],
28
+ create(context) {
29
+ return {
30
+ TSEnumDeclaration(node) {
31
+ context.report({
32
+ node,
33
+ messageId: NO_ENUM
34
+ });
35
+ },
36
+ Property(node) {
37
+ if (node.key.type === TSESTree.AST_NODE_TYPES.Identifier && node.key.name === "enum" && node.value.type === TSESTree.AST_NODE_TYPES.ArrayExpression && !isJsonSchemaProperty(node.parent)) {
38
+ context.report({
39
+ node,
40
+ messageId: NO_ENUM
41
+ });
42
+ }
43
+ }
44
+ };
45
+ }
46
+ });
47
+ var no_enum_default = rule;
48
+ export {
49
+ no_enum_default as default,
50
+ ruleId
51
+ };
52
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL25vLWVudW0udHMiXSwKICAibWFwcGluZ3MiOiAiO0FBUUEsU0FBUyxhQUFhLGdCQUFnQjtBQUUvQixJQUFNLFNBQVM7QUFDdEIsSUFBTSxVQUFVO0FBRWhCLElBQU0sYUFBYSxZQUFZLFlBQVksQ0FBQyxTQUFTLElBQUk7QUFFekQsU0FBUyxxQkFBcUIsTUFBK0I7QUFDM0QsTUFBSSxDQUFDLE1BQU07QUFDVCxXQUFPO0FBQUEsRUFDVDtBQUNBLE1BQ0UsS0FBSyxTQUFTLFNBQVMsZUFBZSxZQUN0QyxLQUFLLElBQUksU0FBUyxTQUFTLGVBQWUsY0FDMUMsS0FBSyxJQUFJLFNBQVMsY0FDbEI7QUFDQSxXQUFPO0FBQUEsRUFDVDtBQUNBLFNBQU8scUJBQXFCLEtBQUssTUFBTTtBQUN6QztBQUVBLElBQU0sT0FBK0MsV0FBVztBQUFBLEVBQzlELE1BQU07QUFBQSxFQUNOLE1BQU07QUFBQSxJQUNKLE1BQU07QUFBQSxJQUNOLE1BQU07QUFBQSxNQUNKLGFBQWE7QUFBQSxJQUNmO0FBQUEsSUFDQSxRQUFRLENBQUM7QUFBQSxJQUNULFVBQVU7QUFBQSxNQUNSLENBQUMsT0FBTyxHQUFHO0FBQUEsSUFDYjtBQUFBLEVBQ0Y7QUFBQSxFQUNBLGdCQUFnQixDQUFDO0FBQUEsRUFDakIsT0FBTyxTQUFTO0FBQ2QsV0FBTztBQUFBLE1BQ0wsa0JBQWtCLE1BQWtDO0FBQ2xELGdCQUFRLE9BQU87QUFBQSxVQUNiO0FBQUEsVUFDQSxXQUFXO0FBQUEsUUFDYixDQUFDO0FBQUEsTUFDSDtBQUFBLE1BQ0EsU0FBUyxNQUF5QjtBQUNoQyxZQUNFLEtBQUssSUFBSSxTQUFTLFNBQVMsZUFBZSxjQUMxQyxLQUFLLElBQUksU0FBUyxVQUNsQixLQUFLLE1BQU0sU0FBUyxTQUFTLGVBQWUsbUJBQzVDLENBQUMscUJBQXFCLEtBQUssTUFBTSxHQUNqQztBQUNBLGtCQUFRLE9BQU87QUFBQSxZQUNiO0FBQUEsWUFDQSxXQUFXO0FBQUEsVUFDYixDQUFDO0FBQUEsUUFDSDtBQUFBLE1BQ0Y7QUFBQSxJQUNGO0FBQUEsRUFDRjtBQUNGLENBQUM7QUFFRCxJQUFPLGtCQUFROyIsCiAgIm5hbWVzIjogW10KfQo=
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ export declare const ruleId = "no-enum";
3
+ declare const NO_ENUM = "NO_ENUM";
4
+ declare const rule: ESLintUtils.RuleModule<typeof NO_ENUM>;
5
+ export default rule;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@checkdigit/eslint-plugin","version":"7.2.0-PR.66-49d4","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.10.0","@typescript-eslint/utils":"^8.10.0","ts-api-utils":"^1.3.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^5.5.1","@checkdigit/typescript-config":"^8.0.0","@eslint/js":"^9.13.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.10.0","@typescript-eslint/rule-tester":"^8.10.0","eslint":"^9.13.0","eslint-config-prettier":"^9.1.0","eslint-import-resolver-typescript":"^3.6.3","eslint-plugin-eslint-plugin":"^6.2.0","eslint-plugin-import":"^2.31.0","eslint-plugin-no-only-tests":"^3.3.0","eslint-plugin-no-secrets":"^1.0.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.10.0"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
1
+ {"name":"@checkdigit/eslint-plugin","version":"7.2.0-PR.79-490a","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.10.0","@typescript-eslint/utils":"^8.10.0","ts-api-utils":"^1.3.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^5.5.1","@checkdigit/typescript-config":"^8.0.0","@eslint/js":"^9.13.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.10.0","@typescript-eslint/rule-tester":"^8.10.0","eslint":"^9.13.0","eslint-config-prettier":"^9.1.0","eslint-import-resolver-typescript":"^3.6.3","eslint-plugin-eslint-plugin":"^6.2.0","eslint-plugin-import":"^2.31.0","eslint-plugin-no-only-tests":"^3.3.0","eslint-plugin-no-secrets":"^1.0.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.10.0"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
package/src/index.ts CHANGED
@@ -23,7 +23,7 @@ import requireTypeOutOfTypeOnlyImports, {
23
23
  } from './require-type-out-of-type-only-imports';
24
24
  import filePathComment from './file-path-comment';
25
25
  import noCardNumbers from './no-card-numbers';
26
- import noSideEffects from './no-side-effects';
26
+ import noEnum from './no-enum';
27
27
  import noTestImport from './no-test-import';
28
28
  import noUuid from './no-uuid';
29
29
  import noWallabyComment from './no-wallaby-comment';
@@ -35,11 +35,11 @@ import requireStrictAssert from './require-strict-assert';
35
35
  const rules: Record<string, TSESLint.LooseRuleDefinition> = {
36
36
  'file-path-comment': filePathComment,
37
37
  'no-card-numbers': noCardNumbers,
38
+ 'no-enum': noEnum,
38
39
  'no-uuid': noUuid,
39
40
  'require-strict-assert': requireStrictAssert,
40
41
  'no-test-import': noTestImport,
41
42
  'no-wallaby-comment': noWallabyComment,
42
- 'no-side-effects': noSideEffects,
43
43
  'regular-expression-comment': regexComment,
44
44
  'require-assert-predicate-rejects-throws': requireAssertPredicateRejectsThrows,
45
45
  'object-literal-response': objectLiteralResponse,
@@ -63,11 +63,11 @@ const configs: Record<string, TSESLint.FlatConfig.Config> = {
63
63
  },
64
64
  rules: {
65
65
  '@checkdigit/no-card-numbers': 'error',
66
+ '@checkdigit/no-enum': 'error',
66
67
  '@checkdigit/file-path-comment': 'error',
67
68
  '@checkdigit/no-uuid': 'error',
68
69
  '@checkdigit/require-strict-assert': 'error',
69
70
  '@checkdigit/no-wallaby-comment': 'error',
70
- '@checkdigit/no-side-effects': ['error', { excludedIdentifiers: ['assert', 'debug', 'log', 'promisify'] }],
71
71
  '@checkdigit/regular-expression-comment': 'error',
72
72
  '@checkdigit/require-assert-predicate-rejects-throws': 'error',
73
73
  '@checkdigit/object-literal-response': 'error',
@@ -87,11 +87,11 @@ const configs: Record<string, TSESLint.FlatConfig.Config> = {
87
87
  },
88
88
  rules: {
89
89
  '@checkdigit/no-card-numbers': 'error',
90
+ '@checkdigit/no-enum': 'error',
90
91
  '@checkdigit/file-path-comment': 'off',
91
92
  '@checkdigit/no-uuid': 'error',
92
93
  '@checkdigit/require-strict-assert': 'error',
93
94
  '@checkdigit/no-wallaby-comment': 'off',
94
- '@checkdigit/no-side-effects': 'error',
95
95
  '@checkdigit/regular-expression-comment': 'error',
96
96
  '@checkdigit/require-assert-predicate-rejects-throws': 'error',
97
97
  '@checkdigit/object-literal-response': 'error',
package/src/no-enum.ts ADDED
@@ -0,0 +1,68 @@
1
+ // no-enum.ts
2
+
3
+ /*
4
+ * Copyright (c) 2021-2024 Check Digit, LLC
5
+ *
6
+ * This code is licensed under the MIT license (see LICENSE.txt for details).
7
+ */
8
+
9
+ import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';
10
+
11
+ export const ruleId = 'no-enum';
12
+ const NO_ENUM = 'NO_ENUM';
13
+
14
+ const createRule = ESLintUtils.RuleCreator((name) => name);
15
+
16
+ function isJsonSchemaProperty(node?: TSESTree.Node): boolean {
17
+ if (!node) {
18
+ return false;
19
+ }
20
+ if (
21
+ node.type === TSESTree.AST_NODE_TYPES.Property &&
22
+ node.key.type === TSESTree.AST_NODE_TYPES.Identifier &&
23
+ node.key.name === 'properties'
24
+ ) {
25
+ return true;
26
+ }
27
+ return isJsonSchemaProperty(node.parent);
28
+ }
29
+
30
+ const rule: ESLintUtils.RuleModule<typeof NO_ENUM> = createRule({
31
+ name: ruleId,
32
+ meta: {
33
+ type: 'problem',
34
+ docs: {
35
+ description: 'Disallow the use of `enum` in TypeScript',
36
+ },
37
+ schema: [],
38
+ messages: {
39
+ [NO_ENUM]: 'Avoid using `enum` in TypeScript.',
40
+ },
41
+ },
42
+ defaultOptions: [],
43
+ create(context) {
44
+ return {
45
+ TSEnumDeclaration(node: TSESTree.TSEnumDeclaration) {
46
+ context.report({
47
+ node,
48
+ messageId: NO_ENUM,
49
+ });
50
+ },
51
+ Property(node: TSESTree.Property) {
52
+ if (
53
+ node.key.type === TSESTree.AST_NODE_TYPES.Identifier &&
54
+ node.key.name === 'enum' &&
55
+ node.value.type === TSESTree.AST_NODE_TYPES.ArrayExpression &&
56
+ !isJsonSchemaProperty(node.parent)
57
+ ) {
58
+ context.report({
59
+ node,
60
+ messageId: NO_ENUM,
61
+ });
62
+ }
63
+ },
64
+ };
65
+ },
66
+ });
67
+
68
+ export default rule;
@@ -1,68 +0,0 @@
1
- // src/no-side-effects.ts
2
- import { ESLintUtils } from "@typescript-eslint/utils";
3
- import { TSESTree } from "@typescript-eslint/typescript-estree";
4
- var ruleId = "no-side-effects";
5
- var NO_SIDE_EFFECTS = "NO_SIDE_EFFECTS";
6
- function isExpressionStatement(node) {
7
- return node.type === TSESTree.AST_NODE_TYPES.ExpressionStatement;
8
- }
9
- function isAwaitExpression(statement) {
10
- return isExpressionStatement(statement) && statement.expression.type === TSESTree.AST_NODE_TYPES.AwaitExpression;
11
- }
12
- function isCallExpressionCalleeMemberExpression(statement, excludedIdentifiers) {
13
- return isExpressionStatement(statement) && statement.expression.type === TSESTree.AST_NODE_TYPES.CallExpression && statement.expression.callee.type === TSESTree.AST_NODE_TYPES.MemberExpression && statement.expression.callee.object.type === TSESTree.AST_NODE_TYPES.Identifier && !excludedIdentifiers.includes(statement.expression.callee.object.name);
14
- }
15
- function isVariableDeclarationAwaitExpression(node) {
16
- return node.type === TSESTree.AST_NODE_TYPES.VariableDeclaration && node.declarations.length > 0 && node.declarations[0]?.init?.type === TSESTree.AST_NODE_TYPES.AwaitExpression;
17
- }
18
- function isVariableDeclarationCallExpression(node, excludedIdentifiers) {
19
- return node.type === TSESTree.AST_NODE_TYPES.VariableDeclaration && node.declarations.length > 0 && node.declarations[0]?.init?.type === TSESTree.AST_NODE_TYPES.CallExpression && (node.declarations[0].init.callee.type === TSESTree.AST_NODE_TYPES.Identifier && !excludedIdentifiers.includes(node.declarations[0].init.callee.name) || node.declarations[0].init.callee.type === TSESTree.AST_NODE_TYPES.MemberExpression);
20
- }
21
- var createRule = ESLintUtils.RuleCreator((name) => name);
22
- var rule = createRule({
23
- name: ruleId,
24
- meta: {
25
- type: "problem",
26
- docs: {
27
- description: "Ensure no side effects can occur at the module-level"
28
- },
29
- schema: [
30
- {
31
- type: "object",
32
- properties: {
33
- excludedIdentifiers: {
34
- type: "array",
35
- items: { type: "string" }
36
- }
37
- },
38
- additionalProperties: false
39
- }
40
- ],
41
- messages: {
42
- [NO_SIDE_EFFECTS]: "No side effects can occur at the module-level"
43
- }
44
- },
45
- defaultOptions: [{ excludedIdentifiers: [""] }],
46
- create(context) {
47
- const options = context.options[0];
48
- const excludedIdentifiers = options.excludedIdentifiers.length > 0 ? options.excludedIdentifiers : [];
49
- return {
50
- Program(node) {
51
- node.body.forEach((statement) => {
52
- if (isAwaitExpression(statement) || isCallExpressionCalleeMemberExpression(statement, excludedIdentifiers) || isVariableDeclarationAwaitExpression(statement) || isVariableDeclarationCallExpression(statement, excludedIdentifiers)) {
53
- context.report({
54
- node: statement,
55
- messageId: NO_SIDE_EFFECTS
56
- });
57
- }
58
- });
59
- }
60
- };
61
- }
62
- });
63
- var no_side_effects_default = rule;
64
- export {
65
- no_side_eff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QUFRLENBQUMsY0FBYztBQUMvQixjQUNFLGtCQUFrQixTQUFTLEtBQzNCLHVDQUF1QyxXQUFXLG1CQUFtQixLQUNyRSxxQ0FBcUMsU0FBUyxLQUM5QyxvQ0FBb0MsV0FBVyxtQkFBbUIsR0FDbEU7QUFDQSxvQkFBUSxPQUFPO0FBQUEsY0FDYixNQUFNO0FBQUEsY0FDTixXQUFXO0FBQUEsWUFDYixDQUFDO0FBQUEsVUFDSDtBQUFBLFFBQ0YsQ0FBQztBQUFBLE1BQ0g7QUFBQSxJQUNGO0FBQUEsRUFDRjtBQUNGLENBQUM7QUFFRCxJQUFPLDBCQUFROyIsCiAgIm5hbWVzIjogW10KfQo=
@@ -1,5 +0,0 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- export declare const ruleId = "no-side-effects";
3
- declare const createRule: ReturnType<typeof ESLintUtils.RuleCreator>;
4
- declare const rule: ReturnType<typeof createRule>;
5
- export default rule;
@@ -1,111 +0,0 @@
1
- // no-side-effects.ts
2
-
3
- /*
4
- * Copyright (c) 2022-2024 Check Digit, LLC
5
- *
6
- * This code is licensed under the MIT license (see LICENSE.txt for details).
7
- */
8
-
9
- import { ESLintUtils } from '@typescript-eslint/utils';
10
- import { TSESTree } from '@typescript-eslint/typescript-estree';
11
-
12
- interface RuleOptions {
13
- excludedIdentifiers: string[];
14
- }
15
-
16
- export const ruleId = 'no-side-effects';
17
- const NO_SIDE_EFFECTS = 'NO_SIDE_EFFECTS';
18
-
19
- // Type guard to check if a node is an ExpressionStatement
20
- function isExpressionStatement(node: TSESTree.Node): node is TSESTree.ExpressionStatement {
21
- return node.type === TSESTree.AST_NODE_TYPES.ExpressionStatement;
22
- }
23
-
24
- // Type guard to check if a node is an AwaitExpression
25
- function isAwaitExpression(statement: TSESTree.Node): boolean {
26
- return isExpressionStatement(statement) && statement.expression.type === TSESTree.AST_NODE_TYPES.AwaitExpression;
27
- }
28
-
29
- // To check if it is a call expression with a member expression i.e. module.method()
30
- function isCallExpressionCalleeMemberExpression(statement: TSESTree.Node, excludedIdentifiers: string[]): boolean {
31
- return (
32
- isExpressionStatement(statement) &&
33
- statement.expression.type === TSESTree.AST_NODE_TYPES.CallExpression &&
34
- statement.expression.callee.type === TSESTree.AST_NODE_TYPES.MemberExpression &&
35
- statement.expression.callee.object.type === TSESTree.AST_NODE_TYPES.Identifier &&
36
- !excludedIdentifiers.includes(statement.expression.callee.object.name)
37
- );
38
- }
39
-
40
- // To check if it is a variable declaration with an await expression i.e. const configuration = await someFunction();
41
- function isVariableDeclarationAwaitExpression(node: TSESTree.Node): boolean {
42
- return (
43
- node.type === TSESTree.AST_NODE_TYPES.VariableDeclaration &&
44
- node.declarations.length > 0 &&
45
- node.declarations[0]?.init?.type === TSESTree.AST_NODE_TYPES.AwaitExpression
46
- );
47
- }
48
-
49
- // To check if it is a variable declaration with a call expression
50
- function isVariableDeclarationCallExpression(node: TSESTree.Node, excludedIdentifiers: string[]): boolean {
51
- return (
52
- node.type === TSESTree.AST_NODE_TYPES.VariableDeclaration &&
53
- node.declarations.length > 0 &&
54
- node.declarations[0]?.init?.type === TSESTree.AST_NODE_TYPES.CallExpression &&
55
- ((node.declarations[0].init.callee.type === TSESTree.AST_NODE_TYPES.Identifier &&
56
- !excludedIdentifiers.includes(node.declarations[0].init.callee.name)) ||
57
- node.declarations[0].init.callee.type === TSESTree.AST_NODE_TYPES.MemberExpression)
58
- );
59
- }
60
-
61
- const createRule: ReturnType<typeof ESLintUtils.RuleCreator> = ESLintUtils.RuleCreator((name) => name);
62
-
63
- const rule: ReturnType<typeof createRule> = createRule({
64
- name: ruleId,
65
- meta: {
66
- type: 'problem',
67
- docs: {
68
- description: 'Ensure no side effects can occur at the module-level',
69
- },
70
- schema: [
71
- {
72
- type: 'object',
73
- properties: {
74
- excludedIdentifiers: {
75
- type: 'array',
76
- items: { type: 'string' },
77
- },
78
- },
79
- additionalProperties: false,
80
- },
81
- ],
82
- messages: {
83
- [NO_SIDE_EFFECTS]: 'No side effects can occur at the module-level',
84
- },
85
- },
86
- defaultOptions: [{ excludedIdentifiers: [''] }],
87
- create(context) {
88
- const options: RuleOptions = context.options[0] as RuleOptions;
89
- const excludedIdentifiers = options.excludedIdentifiers.length > 0 ? options.excludedIdentifiers : [];
90
-
91
- return {
92
- Program(node: TSESTree.Program) {
93
- node.body.forEach((statement) => {
94
- if (
95
- isAwaitExpression(statement) ||
96
- isCallExpressionCalleeMemberExpression(statement, excludedIdentifiers) ||
97
- isVariableDeclarationAwaitExpression(statement) ||
98
- isVariableDeclarationCallExpression(statement, excludedIdentifiers)
99
- ) {
100
- context.report({
101
- node: statement,
102
- messageId: NO_SIDE_EFFECTS,
103
- });
104
- }
105
- });
106
- },
107
- };
108
- },
109
- });
110
-
111
- export default rule;