@storm-software/linting-tools 1.30.2 → 1.30.4

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +201 -0
  3. package/README.md +1 -1
  4. package/bin/lint.js +327122 -0
  5. package/package.json +1 -1
  6. package/src/cli/index.js +326741 -0
  7. package/src/eslint/graphql/{index.ts → index.js} +12 -4
  8. package/src/eslint/{rules/storm.ts → javascript/index.js} +144 -3
  9. package/src/eslint/jest/index.js +24 -0
  10. package/src/eslint/{constants.ts → json/index.js} +52 -39
  11. package/src/eslint/next/index.js +95 -0
  12. package/src/eslint/{rules/react.ts → react/index.js} +44 -3
  13. package/src/eslint/typescript/index.js +577 -0
  14. package/src/manypkg/index.js +30474 -0
  15. package/jest.config.ts +0 -11
  16. package/project.json +0 -96
  17. package/src/alex/index.ts +0 -82
  18. package/src/cli/index.ts +0 -289
  19. package/src/eslint/index.ts +0 -7
  20. package/src/eslint/javascript/index.ts +0 -22
  21. package/src/eslint/jest/index.ts +0 -16
  22. package/src/eslint/json/index.ts +0 -37
  23. package/src/eslint/next/index.ts +0 -25
  24. package/src/eslint/react/index.ts +0 -25
  25. package/src/eslint/rules/import.ts +0 -88
  26. package/src/eslint/rules/jsx-a11y.ts +0 -8
  27. package/src/eslint/rules/ts-docs.ts +0 -12
  28. package/src/eslint/rules/unicorn.ts +0 -23
  29. package/src/eslint/typescript/index.ts +0 -144
  30. package/src/manypkg/index.ts +0 -179
  31. package/tsconfig.json +0 -24
  32. package/tsconfig.lib.json +0 -11
  33. package/tsconfig.spec.json +0 -13
  34. /package/{src/alex → alex}/.alexignore +0 -0
  35. /package/{src/alex → alex}/.alexrc +0 -0
  36. /package/{src/biome → biome}/biome.json +0 -0
  37. /package/{src/cspell → cspell}/config.json +0 -0
  38. /package/{src/cspell → cspell}/dictionary.txt +0 -0
  39. /package/{src/prettier → prettier}/.prettierignore +0 -0
  40. /package/{src/prettier → prettier}/config.json +0 -0
  41. /package/{src/tsconfig → tsconfig}/reset.d.ts +0 -0
  42. /package/{src/tsconfig → tsconfig}/tsconfig.root.json +0 -0
@@ -1,6 +1,12 @@
1
- import { Linter } from "eslint";
1
+ import { fileURLToPath as _fileURLToPath } from 'url';
2
+ import _path from 'node:path';
3
+ import { createRequire as topLevelCreateRequire } from 'module';
4
+ const require = topLevelCreateRequire(import.meta.url);
5
+ const __filename = _fileURLToPath(import.meta.url);
6
+ const __dirname = _path.dirname(__filename);
2
7
 
3
- const config: Linter.Config = {
8
+ // packages/linting-tools/src/eslint/graphql/index.ts
9
+ var config = {
4
10
  root: true,
5
11
  overrides: [
6
12
  {
@@ -121,5 +127,7 @@ const config: Linter.Config = {
121
127
  }
122
128
  ]
123
129
  };
124
-
125
- export default config;
130
+ var graphql_default = config;
131
+ export {
132
+ graphql_default as default
133
+ };
@@ -1,6 +1,105 @@
1
- import { Linter } from "eslint";
1
+ import { fileURLToPath as _fileURLToPath } from 'url';
2
+ import _path from 'node:path';
3
+ import { createRequire as topLevelCreateRequire } from 'module';
4
+ const require = topLevelCreateRequire(import.meta.url);
5
+ const __filename = _fileURLToPath(import.meta.url);
6
+ const __dirname = _path.dirname(__filename);
2
7
 
3
- const config: Linter.RulesRecord = {
8
+ // packages/linting-tools/src/eslint/rules/import.ts
9
+ var config = {
10
+ /**
11
+ * Disallow non-import statements appearing before import statements.
12
+ *
13
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
14
+ */
15
+ "import/first": "error",
16
+ /**
17
+ * Require a newline after the last import/require.
18
+ *
19
+ * 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md
20
+ */
21
+ "import/newline-after-import": "warn",
22
+ /**
23
+ * Disallow import of modules using absolute paths.
24
+ *
25
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-absolute-path.md
26
+ */
27
+ "import/no-absolute-path": "error",
28
+ /**
29
+ * Disallow cyclical dependencies between modules.
30
+ *
31
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
32
+ */
33
+ "import/no-cycle": "error",
34
+ /**
35
+ * Disallow default exports.
36
+ *
37
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md
38
+ */
39
+ "import/no-default-export": "error",
40
+ /**
41
+ * Disallow the use of extraneous packages.
42
+ *
43
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
44
+ */
45
+ "import/no-extraneous-dependencies": [
46
+ "error",
47
+ { includeInternal: true, includeTypes: true }
48
+ ],
49
+ /**
50
+ * Disallow mutable exports.
51
+ *
52
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md
53
+ */
54
+ "import/no-mutable-exports": "error",
55
+ /**
56
+ * Disallow importing packages through relative paths.
57
+ *
58
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-packages.md
59
+ */
60
+ "import/no-relative-packages": "warn",
61
+ /**
62
+ * Disallow a module from importing itself.
63
+ *
64
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-self-import.md
65
+ */
66
+ "import/no-self-import": "error",
67
+ /**
68
+ * Ensures that there are no useless path segments.
69
+ *
70
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-useless-path-segments.md
71
+ */
72
+ "import/no-useless-path-segments": ["error"],
73
+ /**
74
+ * Enforce a module import order convention.
75
+ *
76
+ * 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
77
+ */
78
+ "import/order": [
79
+ "warn",
80
+ {
81
+ groups: [
82
+ "builtin",
83
+ // Node.js built-in modules
84
+ "external",
85
+ // Packages
86
+ "internal",
87
+ // Aliased modules
88
+ "parent",
89
+ // Relative parent
90
+ "sibling",
91
+ // Relative sibling
92
+ "index"
93
+ // Relative index
94
+ ],
95
+ "newlines-between": "never"
96
+ }
97
+ ]
98
+ };
99
+ var import_default = config;
100
+
101
+ // packages/linting-tools/src/eslint/rules/storm.ts
102
+ var config2 = {
4
103
  /**
5
104
  * Require return statements in array methods callbacks.
6
105
  *
@@ -231,5 +330,47 @@ const config: Linter.RulesRecord = {
231
330
  */
232
331
  yoda: "warn"
233
332
  };
333
+ var storm_default = config2;
234
334
 
235
- export default config;
335
+ // packages/linting-tools/src/eslint/rules/unicorn.ts
336
+ var config3 = {
337
+ /**
338
+ * Require consistent filename case for all linted files.
339
+ *
340
+ * 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
341
+ */
342
+ "unicorn/filename-case": [
343
+ "error",
344
+ {
345
+ case: "kebabCase"
346
+ }
347
+ ],
348
+ /**
349
+ * Require using the `node:` protocol when importing Node.js built-in modules.
350
+ *
351
+ * 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
352
+ */
353
+ "unicorn/prefer-node-protocol": "warn"
354
+ };
355
+ var unicorn_default = config3;
356
+
357
+ // packages/linting-tools/src/eslint/javascript/index.ts
358
+ var config4 = {
359
+ root: true,
360
+ overrides: [
361
+ {
362
+ files: ["*.js", "*.jsx"],
363
+ extends: ["plugin:@nx/javascript"],
364
+ plugins: ["unicorn", "import"],
365
+ rules: {
366
+ ...import_default,
367
+ ...unicorn_default,
368
+ ...storm_default
369
+ }
370
+ }
371
+ ]
372
+ };
373
+ var javascript_default = config4;
374
+ export {
375
+ javascript_default as default
376
+ };
@@ -0,0 +1,24 @@
1
+ import { fileURLToPath as _fileURLToPath } from 'url';
2
+ import _path from 'node:path';
3
+ import { createRequire as topLevelCreateRequire } from 'module';
4
+ const require = topLevelCreateRequire(import.meta.url);
5
+ const __filename = _fileURLToPath(import.meta.url);
6
+ const __dirname = _path.dirname(__filename);
7
+
8
+ // packages/linting-tools/src/eslint/jest/index.ts
9
+ var config = {
10
+ root: true,
11
+ overrides: [
12
+ {
13
+ files: ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
14
+ env: {
15
+ jest: true
16
+ },
17
+ rules: {}
18
+ }
19
+ ]
20
+ };
21
+ var jest_default = config;
22
+ export {
23
+ jest_default as default
24
+ };
@@ -1,4 +1,12 @@
1
- export const RESTRICTED_SYNTAX = [
1
+ import { fileURLToPath as _fileURLToPath } from 'url';
2
+ import _path from 'node:path';
3
+ import { createRequire as topLevelCreateRequire } from 'module';
4
+ const require = topLevelCreateRequire(import.meta.url);
5
+ const __filename = _fileURLToPath(import.meta.url);
6
+ const __dirname = _path.dirname(__filename);
7
+
8
+ // packages/linting-tools/src/eslint/constants.ts
9
+ var RESTRICTED_SYNTAX = [
2
10
  {
3
11
  // ❌ readFile(…, { encoding: … })
4
12
  selector: `CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]`,
@@ -26,15 +34,12 @@ export const RESTRICTED_SYNTAX = [
26
34
  },
27
35
  {
28
36
  // ❌ Boolean(…)
29
- selector:
30
- "CallExpression[callee.name=Boolean][arguments.1.elements.length!=0]",
31
- message:
32
- "Prefer `!!…` over `Boolean(…)` because TypeScript infers a narrow literal boolean `type: true` instead of `type: boolean`."
37
+ selector: "CallExpression[callee.name=Boolean][arguments.1.elements.length!=0]",
38
+ message: "Prefer `!!\u2026` over `Boolean(\u2026)` because TypeScript infers a narrow literal boolean `type: true` instead of `type: boolean`."
33
39
  },
34
40
  {
35
41
  // ❌ process.browser
36
- selector:
37
- "ExpressionStatement[expression.object.name=process][expression.property.name=browser]",
42
+ selector: "ExpressionStatement[expression.object.name=process][expression.property.name=browser]",
38
43
  message: "`process.browser` is deprecated, use `!!globalThis.window`"
39
44
  }
40
45
  // {
@@ -46,42 +51,50 @@ export const RESTRICTED_SYNTAX = [
46
51
  // message: 'Do not use nested destructuring.',
47
52
  // },
48
53
  ];
49
-
50
- export const REACT_RESTRICTED_SYNTAX = [
54
+ var REACT_RESTRICTED_SYNTAX = [
51
55
  ...RESTRICTED_SYNTAX,
52
56
  {
53
57
  // ❌ useMemo(…, [])
54
- selector:
55
- "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
56
- message:
57
- "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
58
+ selector: "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
59
+ message: "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
58
60
  }
59
61
  ];
62
+ var CODE_BLOCK = "**/*.md{,x}/*";
60
63
 
61
- export const RESTRICTED_GLOBALS = [
62
- "stop",
63
- { name: "isNaN", message: "Use Number.isNaN instead" }
64
- ];
65
-
66
- export const RESTRICTED_MODULES = [
67
- { name: "axios", message: "Use `fetch/node-fetch` instead." },
68
- { name: "moment", message: "Use `dayjs/date-fns` instead." },
69
- { name: "classnames", message: "Use `clsx` instead because it is faster." },
70
- {
71
- name: "lodash/isString.js",
72
- message: "Use `typeof yourVar === 'string'` instead."
73
- },
74
- { name: "lodash/isArray.js", message: "Use `Array.isArray` instead." },
75
- { name: "lodash/flatten.js", message: "Use `Array#flat()` instead." },
76
- {
77
- name: "lodash/compact.js",
78
- message: "Use `Array#filter(Boolean)` instead."
79
- },
80
- { name: "lodash/identity.js", message: "Use `(value) => value` instead." }
64
+ // packages/linting-tools/src/eslint/json/index.ts
65
+ var JSONC_FILES = [
66
+ "tsconfig.json",
67
+ "tsconfig.base.json",
68
+ "nx.json",
69
+ ".vscode/launch.json"
81
70
  ];
82
-
83
- export const JS_FILES = ["*.js?(x)", "*.mjs"];
84
-
85
- export const CODE_BLOCK = "**/*.md{,x}/*";
86
- export const CODE_FILE = "*.{,c,m}{j,t}s{,x}";
87
- export const TS_FILE = "*.{,c,m}ts{,x}";
71
+ var config = {
72
+ root: true,
73
+ overrides: [
74
+ {
75
+ files: "*.json",
76
+ excludedFiles: JSONC_FILES,
77
+ extends: "plugin:jsonc/recommended-with-json"
78
+ },
79
+ {
80
+ files: ["*.jsonc", ...JSONC_FILES],
81
+ extends: "plugin:jsonc/recommended-with-jsonc"
82
+ },
83
+ {
84
+ files: "*.json5",
85
+ extends: "plugin:jsonc/recommended-with-json5"
86
+ },
87
+ {
88
+ files: "*.json{,c,5}",
89
+ excludedFiles: CODE_BLOCK,
90
+ plugins: ["unicorn"],
91
+ rules: {
92
+ "unicorn/filename-case": "error"
93
+ }
94
+ }
95
+ ]
96
+ };
97
+ var json_default = config;
98
+ export {
99
+ json_default as default
100
+ };
@@ -0,0 +1,95 @@
1
+ import { fileURLToPath as _fileURLToPath } from 'url';
2
+ import _path from 'node:path';
3
+ import { createRequire as topLevelCreateRequire } from 'module';
4
+ const require = topLevelCreateRequire(import.meta.url);
5
+ const __filename = _fileURLToPath(import.meta.url);
6
+ const __dirname = _path.dirname(__filename);
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined")
11
+ return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+
15
+ // packages/linting-tools/src/eslint/constants.ts
16
+ var RESTRICTED_SYNTAX = [
17
+ {
18
+ // ❌ readFile(…, { encoding: … })
19
+ selector: `CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]`,
20
+ message: `Specify encoding as last argument instead of object with encoding key`
21
+ },
22
+ {
23
+ // ❌ readFile(…, {})
24
+ selector: `CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]`,
25
+ message: "Specify encoding as last argument"
26
+ },
27
+ {
28
+ // ❌ readFileSync(…).toString(…)
29
+ selector: `CallExpression[callee.name=readFileSync][parent.property.name=toString]`,
30
+ message: `toString is redundant, specify encoding as last argument`
31
+ },
32
+ {
33
+ // ❌ ….readFile(…, { encoding: … })
34
+ selector: `CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]`,
35
+ message: `Specify encoding as last argument instead of object with encoding key`
36
+ },
37
+ {
38
+ // ❌ ….readFile(…, {})
39
+ selector: `CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]`,
40
+ message: "Specify encoding as last argument"
41
+ },
42
+ {
43
+ // ❌ Boolean(…)
44
+ selector: "CallExpression[callee.name=Boolean][arguments.1.elements.length!=0]",
45
+ message: "Prefer `!!\u2026` over `Boolean(\u2026)` because TypeScript infers a narrow literal boolean `type: true` instead of `type: boolean`."
46
+ },
47
+ {
48
+ // ❌ process.browser
49
+ selector: "ExpressionStatement[expression.object.name=process][expression.property.name=browser]",
50
+ message: "`process.browser` is deprecated, use `!!globalThis.window`"
51
+ }
52
+ // {
53
+ // // ❌ let { foo: { bar } } = baz
54
+ // // ✅ let { bar } = baz.foo
55
+ // // ✅ let { foo: { bar } } = await baz
56
+ // selector:
57
+ // 'VariableDeclarator[init.type!=AwaitExpression] > ObjectPattern[properties.length=1][properties.0.value.type=ObjectPattern]',
58
+ // message: 'Do not use nested destructuring.',
59
+ // },
60
+ ];
61
+ var REACT_RESTRICTED_SYNTAX = [
62
+ ...RESTRICTED_SYNTAX,
63
+ {
64
+ // ❌ useMemo(…, [])
65
+ selector: "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
66
+ message: "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
67
+ }
68
+ ];
69
+ var JS_FILES = ["*.js?(x)", "*.mjs"];
70
+
71
+ // packages/linting-tools/src/eslint/next/index.ts
72
+ var babelOptions = {
73
+ presets: (() => {
74
+ try {
75
+ __require.resolve("next/babel");
76
+ return ["next/babel"];
77
+ } catch (e) {
78
+ return [];
79
+ }
80
+ })()
81
+ };
82
+ var config = {
83
+ root: true,
84
+ extends: ["plugin:@next/next/recommended"],
85
+ overrides: [
86
+ {
87
+ files: JS_FILES,
88
+ parserOptions: { babelOptions }
89
+ }
90
+ ]
91
+ };
92
+ var next_default = config;
93
+ export {
94
+ next_default as default
95
+ };
@@ -1,6 +1,12 @@
1
- import { Linter } from "eslint";
1
+ import { fileURLToPath as _fileURLToPath } from 'url';
2
+ import _path from 'node:path';
3
+ import { createRequire as topLevelCreateRequire } from 'module';
4
+ const require = topLevelCreateRequire(import.meta.url);
5
+ const __filename = _fileURLToPath(import.meta.url);
6
+ const __dirname = _path.dirname(__filename);
2
7
 
3
- const config: Linter.RulesRecord = {
8
+ // packages/linting-tools/src/eslint/rules/react.ts
9
+ var config = {
4
10
  // We recommend using TypeScript over `prop-types`, as `prop-types` can add
5
11
  // to a project's build size.
6
12
  "react/prop-types": "off",
@@ -99,5 +105,40 @@ const config: Linter.RulesRecord = {
99
105
  */
100
106
  "react/self-closing-comp": "warn"
101
107
  };
108
+ var react_default = config;
102
109
 
103
- export default config;
110
+ // packages/linting-tools/src/eslint/rules/ts-docs.ts
111
+ var config2 = {
112
+ /**
113
+ * Require TSDoc comments conform to the TSDoc specification.
114
+ *
115
+ * 🚫 Not fixable - https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
116
+ */
117
+ "tsdoc/syntax": "error"
118
+ };
119
+ var ts_docs_default = config2;
120
+
121
+ // packages/linting-tools/src/eslint/react/index.ts
122
+ var config3 = {
123
+ root: true,
124
+ extends: [
125
+ "plugin:react/recommended",
126
+ "plugin:react-hooks/recommended",
127
+ "plugin:jsx-a11y/recommended",
128
+ "plugin:import/react",
129
+ "prettier"
130
+ ],
131
+ settings: {
132
+ react: {
133
+ version: "detect"
134
+ }
135
+ },
136
+ rules: {
137
+ ...ts_docs_default,
138
+ ...react_default
139
+ }
140
+ };
141
+ var react_default2 = config3;
142
+ export {
143
+ react_default2 as default
144
+ };