@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,88 +0,0 @@
1
- import { Linter } from "eslint";
2
-
3
- const config: Linter.RulesRecord = {
4
- /**
5
- * Disallow non-import statements appearing before import statements.
6
- *
7
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
8
- */
9
- "import/first": "error",
10
- /**
11
- * Require a newline after the last import/require.
12
- *
13
- * 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md
14
- */
15
- "import/newline-after-import": "warn",
16
- /**
17
- * Disallow import of modules using absolute paths.
18
- *
19
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-absolute-path.md
20
- */
21
- "import/no-absolute-path": "error",
22
- /**
23
- * Disallow cyclical dependencies between modules.
24
- *
25
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
26
- */
27
- "import/no-cycle": "error",
28
- /**
29
- * Disallow default exports.
30
- *
31
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md
32
- */
33
- "import/no-default-export": "error",
34
- /**
35
- * Disallow the use of extraneous packages.
36
- *
37
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
38
- */
39
- "import/no-extraneous-dependencies": [
40
- "error",
41
- { includeInternal: true, includeTypes: true }
42
- ],
43
- /**
44
- * Disallow mutable exports.
45
- *
46
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md
47
- */
48
- "import/no-mutable-exports": "error",
49
- /**
50
- * Disallow importing packages through relative paths.
51
- *
52
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-packages.md
53
- */
54
- "import/no-relative-packages": "warn",
55
- /**
56
- * Disallow a module from importing itself.
57
- *
58
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-self-import.md
59
- */
60
- "import/no-self-import": "error",
61
- /**
62
- * Ensures that there are no useless path segments.
63
- *
64
- * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-useless-path-segments.md
65
- */
66
- "import/no-useless-path-segments": ["error"],
67
- /**
68
- * Enforce a module import order convention.
69
- *
70
- * 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
71
- */
72
- "import/order": [
73
- "warn",
74
- {
75
- groups: [
76
- "builtin", // Node.js built-in modules
77
- "external", // Packages
78
- "internal", // Aliased modules
79
- "parent", // Relative parent
80
- "sibling", // Relative sibling
81
- "index" // Relative index
82
- ],
83
- "newlines-between": "never"
84
- }
85
- ]
86
- };
87
-
88
- export default config;
@@ -1,8 +0,0 @@
1
- import { Linter } from "eslint";
2
-
3
- const config: Linter.RulesRecord = {
4
- // This rule has been deprecated, but not yet removed.
5
- "jsx-a11y/no-onchange": "off"
6
- };
7
-
8
- export default config;
@@ -1,12 +0,0 @@
1
- import { Linter } from "eslint";
2
-
3
- const config: Linter.RulesRecord = {
4
- /**
5
- * Require TSDoc comments conform to the TSDoc specification.
6
- *
7
- * 🚫 Not fixable - https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
8
- */
9
- "tsdoc/syntax": "error"
10
- };
11
-
12
- export default config;
@@ -1,23 +0,0 @@
1
- import { Linter } from "eslint";
2
-
3
- const config: Linter.RulesRecord = {
4
- /**
5
- * Require consistent filename case for all linted files.
6
- *
7
- * 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
8
- */
9
- "unicorn/filename-case": [
10
- "error",
11
- {
12
- case: "kebabCase"
13
- }
14
- ],
15
- /**
16
- * Require using the `node:` protocol when importing Node.js built-in modules.
17
- *
18
- * 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
19
- */
20
- "unicorn/prefer-node-protocol": "warn"
21
- };
22
-
23
- export default config;
@@ -1,144 +0,0 @@
1
- import { Linter } from "eslint";
2
- import {
3
- RESTRICTED_GLOBALS,
4
- RESTRICTED_MODULES,
5
- RESTRICTED_SYNTAX
6
- } from "../constants";
7
- import importRules from "../rules/import";
8
- import stormRules from "../rules/storm";
9
- import tsDocsRules from "../rules/ts-docs";
10
- import unicornRules from "../rules/unicorn";
11
-
12
- const config: Linter.Config = {
13
- root: true,
14
- overrides: [
15
- {
16
- files: ["*.ts", "*.tsx"],
17
- extends: ["plugin:@nx/typescript"],
18
- rules: {}
19
- }
20
- ],
21
- parser: "@typescript-eslint/parser",
22
- extends: [
23
- "eslint:recommended",
24
- "plugin:@typescript-eslint/recommended",
25
- "prettier"
26
- ],
27
- plugins: ["sonarjs", "unicorn", "promise", "import", "eslint-plugin-tsdoc"],
28
- rules: {
29
- // Disallows if statements as the only statement in else blocks
30
- // https://eslint.org/docs/rules/no-lonely-if
31
- "no-lonely-if": "error",
32
- // Disallows the use of console
33
- // https://eslint.org/docs/rules/no-console
34
- "no-console": "error",
35
- // Requires method and property shorthand syntax for object literals
36
- // https://eslint.org/docs/rules/object-shorthand
37
- "object-shorthand": ["error", "always"],
38
- // Disallows loops with a body that allows only one iteration
39
- // https://eslint.org/docs/rules/no-unreachable-loop
40
- "no-unreachable-loop": "error",
41
- "sonarjs/no-one-iteration-loop": "off", // similar to 'no-unreachable-loop' but reports less cases
42
- "prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
43
-
44
- "sonarjs/no-unused-collection": "error",
45
- "sonarjs/no-identical-conditions": "error",
46
- "sonarjs/no-inverted-boolean-check": "error",
47
- "sonarjs/no-use-of-empty-return-value": "error",
48
- "sonarjs/no-gratuitous-expressions": "error",
49
- "sonarjs/no-nested-switch": "error",
50
- "unicorn/no-lonely-if": "error",
51
- "sonarjs/no-collapsible-if": "off", // same as 'unicorn/no-lonely-if'
52
- "unicorn/no-array-push-push": "error",
53
- "unicorn/no-instanceof-array": "error",
54
- "unicorn/no-empty-file": "error",
55
- "unicorn/no-useless-fallback-in-spread": "error",
56
- "unicorn/prefer-array-find": "error",
57
- "unicorn/no-useless-spread": "error",
58
- "unicorn/prefer-includes": "error",
59
-
60
- // Disallows specified syntax
61
- // https://eslint.org/docs/rules/no-restricted-syntax
62
- "no-restricted-syntax": ["error", ...RESTRICTED_SYNTAX],
63
- "no-else-return": ["error", { allowElseIf: false }],
64
- "promise/no-nesting": "error",
65
-
66
- "import/extensions": ["error", "ignorePackages"], // Bob when bundling requires to have `.js` extension
67
- "import/no-default-export": "error",
68
- "import/prefer-default-export": "off", // disable opposite of 'import/no-default-export'
69
- "unicorn/filename-case": "error",
70
-
71
- "@typescript-eslint/no-unused-vars": [
72
- "error",
73
- {
74
- argsIgnorePattern: "^_",
75
- varsIgnorePattern: "^_" // allow underscores in destructuring
76
- }
77
- ],
78
-
79
- // Enforce the style of numeric separators by correctly grouping digits
80
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/numeric-separators-style.md
81
- "unicorn/numeric-separators-style": "error",
82
- // Prefer using the node: protocol when importing Node.js builtin modules
83
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-node-protocol.md
84
- "unicorn/prefer-node-protocol": "error",
85
- // Reports any imports that come after non-import statements
86
- // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
87
- "import/first": "error",
88
- // Disallow shorthand type conversions
89
- // https://eslint.org/docs/latest/rules/no-implicit-coercion
90
- "no-implicit-coercion": [
91
- "error",
92
- {
93
- disallowTemplateShorthand: true,
94
- // in TypeScript `!!` is preferable https://www.typescriptlang.org/docs/handbook/2/narrowing.html#truthiness-narrowing
95
- boolean: false
96
- }
97
- ],
98
- // Disallow specified modules when loaded by `import` declarations
99
- // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-restricted-import.md
100
- "n/no-restricted-import": ["error", RESTRICTED_MODULES],
101
- // Disallow specified modules when loaded by require
102
- // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-restricted-require.md
103
- "n/no-restricted-require": ["error", RESTRICTED_MODULES],
104
- "no-restricted-modules": "off", // deprecated in favor of corresponding rules from `eslint-plugin-n`
105
-
106
- // Disallow specified global variables
107
- // https://eslint.org/docs/latest/rules/no-restricted-globals
108
- "no-restricted-globals": ["error", ...RESTRICTED_GLOBALS],
109
-
110
- "@typescript-eslint/no-explicit-any": "error",
111
- "prefer-const": ["error", { destructuring: "all" }],
112
- "import/no-duplicates": "error",
113
- "import/newline-after-import": "off", // prettified by prettier-plugin-sort-imports
114
- "prefer-object-has-own": "error",
115
- "logical-assignment-operators": [
116
- "error",
117
- "always",
118
- { enforceForIfStatements: true }
119
- ],
120
- "@typescript-eslint/prefer-optional-chain": "error",
121
- yoda: "error",
122
- "unicorn/prefer-export-from": ["error", { ignoreUsedVariables: true }],
123
- "promise/no-multiple-resolved": "error",
124
- "unicorn/prefer-logical-operator-over-ternary": "error",
125
- "no-unused-expressions": "off",
126
- "@typescript-eslint/no-unused-expressions": "error",
127
- "no-negated-condition": "off",
128
- "unicorn/no-negated-condition": "error",
129
- "unicorn/no-array-for-each": "error",
130
- "unicorn/prefer-string-trim-start-end": "error",
131
- "no-self-compare": "error",
132
- eqeqeq: ["error", "always", { null: "ignore" }],
133
- "import/no-useless-path-segments": "error",
134
- "require-await": "off",
135
- "no-return-await": "off",
136
-
137
- ...importRules,
138
- ...unicornRules,
139
- ...tsDocsRules,
140
- ...stormRules
141
- }
142
- };
143
-
144
- export default config;
@@ -1,179 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { checks } from "@manypkg/cli/src/checks";
3
- import { Options } from "@manypkg/cli/src/checks/utils";
4
- import { ExitError } from "@manypkg/cli/src/errors";
5
- import { npmTagAll } from "@manypkg/cli/src/npm-tag";
6
- import { runCmd } from "@manypkg/cli/src/run";
7
- import { upgradeDependency } from "@manypkg/cli/src/upgrade";
8
- import { install, writePackage } from "@manypkg/cli/src/utils";
9
- import { Package, Packages, getPackages } from "@manypkg/get-packages";
10
- import pLimit from "p-limit";
11
- import spawn from "spawndamnit";
12
-
13
- type RootPackage = Package & {
14
- packageJson: {
15
- manypkg?: Options;
16
- };
17
- };
18
- type PackagesWithConfig = Packages & {
19
- rootPackage?: RootPackage;
20
- };
21
-
22
- const defaultOptions = {
23
- defaultBranch: "main"
24
- };
25
-
26
- const runChecks = (
27
- allWorkspaces: Map<string, Package>,
28
- rootWorkspace: RootPackage | undefined,
29
- shouldFix: boolean,
30
- options: Options
31
- ) => {
32
- let hasErrored = false;
33
- let requiresInstall = false;
34
- const ignoredRules = new Set(options.ignoredRules || []);
35
- for (const [ruleName, check] of Object.entries(checks)) {
36
- if (ignoredRules.has(ruleName)) {
37
- continue;
38
- }
39
-
40
- if (check.type === "all") {
41
- for (const [, workspace] of allWorkspaces) {
42
- const errors = check.validate(
43
- workspace,
44
- allWorkspaces,
45
- rootWorkspace,
46
- options
47
- );
48
- if (shouldFix && check.fix !== undefined) {
49
- for (const error of errors) {
50
- const output = check.fix(error as any, options) || {
51
- requiresInstall: false
52
- };
53
- if (output.requiresInstall) {
54
- requiresInstall = true;
55
- }
56
- }
57
- } else {
58
- for (const error of errors) {
59
- hasErrored = true;
60
- console.error(check.print(error as any, options));
61
- }
62
- }
63
- }
64
- }
65
- if (check.type === "root" && rootWorkspace) {
66
- const errors = check.validate(rootWorkspace, allWorkspaces, options);
67
- if (shouldFix && check.fix !== undefined) {
68
- for (const error of errors) {
69
- const output = check.fix(error as any, options) || {
70
- requiresInstall: false
71
- };
72
- if (output.requiresInstall) {
73
- requiresInstall = true;
74
- }
75
- }
76
- } else {
77
- for (const error of errors) {
78
- hasErrored = true;
79
- console.error(check.print(error as any, options));
80
- }
81
- }
82
- }
83
- }
84
- return { requiresInstall, hasErrored };
85
- };
86
-
87
- const execLimit = pLimit(4);
88
-
89
- async function execCmd(args: string[]) {
90
- const { packages } = await getPackages(process.cwd());
91
- let highestExitCode = 0;
92
- await Promise.all(
93
- packages.map(pkg => {
94
- return execLimit(async () => {
95
- const { code } = await spawn(args[0], args.slice(1), {
96
- cwd: pkg.dir,
97
- stdio: "inherit"
98
- });
99
- highestExitCode = Math.max(code, highestExitCode);
100
- });
101
- })
102
- );
103
- throw new ExitError(highestExitCode);
104
- }
105
-
106
- export async function runManypkg(
107
- manypkgType: string,
108
- manypkgArgs: string[],
109
- manypkgFix = true
110
- ) {
111
- if (manypkgType === "exec") {
112
- return execCmd(manypkgArgs.slice(0));
113
- }
114
- if (manypkgType === "run") {
115
- return runCmd(manypkgArgs.slice(0), process.cwd());
116
- }
117
- if (manypkgType === "upgrade") {
118
- return upgradeDependency(manypkgArgs.slice(0));
119
- }
120
- if (manypkgType === "npm-tag") {
121
- return npmTagAll(manypkgArgs.slice(0));
122
- }
123
-
124
- if (manypkgType !== "check" && manypkgType !== "fix") {
125
- console.error(
126
- `command ${manypkgType} not found, only check, exec, run, upgrade, npm-tag and fix exist`
127
- );
128
- process.exit(1);
129
- }
130
-
131
- const { packages, rootPackage, rootDir } = (await getPackages(
132
- process.env["STORM_WORKSPACE_ROOT"]
133
- ? process.env["STORM_WORKSPACE_ROOT"]
134
- : process.cwd()
135
- )) as PackagesWithConfig;
136
-
137
- const options: Options = {
138
- ...defaultOptions,
139
- ...rootPackage?.packageJson.manypkg
140
- };
141
-
142
- const packagesByName = new Map<string, Package>(
143
- packages.map(x => [x.packageJson.name, x])
144
- );
145
-
146
- console.log(`🔍 Checking ${packages.length} packages...`);
147
- if (rootPackage) {
148
- packagesByName.set(rootPackage.packageJson.name, rootPackage);
149
- }
150
- const { hasErrored, requiresInstall } = runChecks(
151
- packagesByName,
152
- rootPackage,
153
- manypkgFix,
154
- options
155
- );
156
-
157
- if (manypkgFix) {
158
- await Promise.all(
159
- [...packagesByName].map(async ([_, workspace]) => {
160
- writePackage(workspace);
161
- })
162
- );
163
- if (requiresInstall) {
164
- await install("pnpm", rootDir);
165
- }
166
-
167
- if (hasErrored) {
168
- console.log("🎉 Fixed workspace packages!");
169
- } else {
170
- console.log("🎉 Workspace packages are valid!");
171
- }
172
- } else if (hasErrored) {
173
- console.info(
174
- "⚠️ The above errors may be fixable if the --manypkg-fix flag is used"
175
- );
176
- } else {
177
- console.log("🎉 Workspace packages are valid!");
178
- }
179
- }
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "module": "ESNext",
5
- "forceConsistentCasingInFileNames": true,
6
- "strict": false,
7
- "allowJs": true,
8
- "noImplicitOverride": true,
9
- "noPropertyAccessFromIndexSignature": false,
10
- "noImplicitReturns": true,
11
- "noFallthroughCasesInSwitch": true,
12
- "esModuleInterop": true
13
- },
14
- "files": [],
15
- "include": [],
16
- "references": [
17
- {
18
- "path": "./tsconfig.lib.json"
19
- },
20
- {
21
- "path": "./tsconfig.spec.json"
22
- }
23
- ]
24
- }
package/tsconfig.lib.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "target": "es2022",
5
- "outDir": "../../dist/out-tsc",
6
- "declaration": true,
7
- "types": ["node"]
8
- },
9
- "include": ["src/**/*.ts", "src/**/*.js", "bin/**/*"],
10
- "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
11
- }
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "types": ["jest", "node"]
6
- },
7
- "include": [
8
- "jest.config.ts",
9
- "src/**/*.test.ts",
10
- "src/**/*.spec.ts",
11
- "src/**/*.d.ts"
12
- ]
13
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes