@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
package/jest.config.ts DELETED
@@ -1,11 +0,0 @@
1
- /* eslint-disable */
2
- export default {
3
- displayName: "linting-tools",
4
- preset: "../../jest.preset.js",
5
- testEnvironment: "node",
6
- transform: {
7
- "^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
8
- },
9
- moduleFileExtensions: ["ts", "js", "html"],
10
- coverageDirectory: "../../coverage/packages/linting-tools"
11
- };
package/project.json DELETED
@@ -1,96 +0,0 @@
1
- {
2
- "name": "linting-tools",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/linting-tools/src",
5
- "projectType": "library",
6
- "targets": {
7
- "build": {
8
- "executor": "@nx/esbuild:esbuild",
9
- "outputs": ["{options.outputPath}"],
10
- "options": {
11
- "outputPath": "dist/packages/linting-tools",
12
- "tsConfig": "packages/linting-tools/tsconfig.json",
13
- "project": "packages/linting-tools/package.json",
14
- "main": "packages/linting-tools/src/cli/index.ts",
15
- "additionalEntryPoints": [
16
- "packages/linting-tools/bin/lint.ts",
17
- "packages/linting-tools/src/eslint/graphql/index.ts",
18
- "packages/linting-tools/src/eslint/javascript/index.ts",
19
- "packages/linting-tools/src/eslint/json/index.ts",
20
- "packages/linting-tools/src/eslint/jest/index.ts",
21
- "packages/linting-tools/src/eslint/next/index.ts",
22
- "packages/linting-tools/src/eslint/react/index.ts",
23
- "packages/linting-tools/src/eslint/typescript/index.ts",
24
- "packages/linting-tools/src/manypkg/index.ts"
25
- ],
26
- "deleteOutputPath": true,
27
- "bundle": true,
28
- "sourcemap": false,
29
- "minify": false,
30
- "skipTypeCheck": false,
31
- "thirdParty": true,
32
- "format": ["esm"],
33
- "esbuildOptions": {
34
- "banner": {
35
- "js": "import { fileURLToPath as _fileURLToPath } from 'url';\nimport _path from 'node:path';\nimport { createRequire as topLevelCreateRequire } from 'module';\nconst require = topLevelCreateRequire(import.meta.url);\nconst __filename = _fileURLToPath(import.meta.url);\nconst __dirname = _path.dirname(__filename);"
36
- }
37
- },
38
- "assets": [
39
- {
40
- "input": "packages/linting-tools",
41
- "glob": "README.md",
42
- "output": "/"
43
- },
44
- {
45
- "input": "packages/linting-tools",
46
- "glob": "CHANGELOG.md",
47
- "output": "/"
48
- },
49
- {
50
- "input": "",
51
- "glob": "LICENSE",
52
- "output": "/"
53
- },
54
- {
55
- "input": "packages/linting-tools",
56
- "glob": "bin/**/*",
57
- "output": "."
58
- },
59
- {
60
- "input": "packages/linting-tools/src",
61
- "glob": "alex/**/.{alexrc,alexignore}",
62
- "output": "."
63
- },
64
- {
65
- "input": "packages/linting-tools/src",
66
- "glob": "biome/biome.json",
67
- "output": "."
68
- },
69
- {
70
- "input": "packages/linting-tools/src",
71
- "glob": "cspell/**/dictionary.txt",
72
- "output": "."
73
- },
74
- {
75
- "input": "packages/linting-tools/src",
76
- "glob": "cspell/**/*.json",
77
- "output": "."
78
- },
79
- {
80
- "input": "packages/linting-tools/src",
81
- "glob": "prettier/**/*.*",
82
- "output": "."
83
- },
84
- {
85
- "input": "packages/linting-tools/src",
86
- "glob": "tsconfig/**/*.*",
87
- "output": "."
88
- }
89
- ]
90
- }
91
- },
92
- "lint": {},
93
- "test": {}
94
- },
95
- "tags": ["type:util", "scope:tools"]
96
- }
package/src/alex/index.ts DELETED
@@ -1,82 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { filter } from "alex/filter";
3
- import retextEnglish from "retext-english";
4
- import retextEquality from "retext-equality";
5
- import retextProfanities from "retext-profanities";
6
- import supportsColor from "supports-color";
7
- import { PluggableList, unified } from "unified";
8
- import { engine } from "unified-engine";
9
- import vfileReporter from "vfile-reporter";
10
-
11
- Error.stackTraceLimit = Infinity;
12
-
13
- export const runAlex = (
14
- rcName = "@storm-software/linting-tools/alex/.alexrc",
15
- ignoreName = "@storm-software/linting-tools/alex/.alexignore"
16
- ) => {
17
- return new Promise(
18
- (resolve: (value: unknown) => void, reject: (reason?: any) => void) =>
19
- engine(
20
- {
21
- processor: unified(),
22
- files: ["**/*.{txt,js,jsx,ts,tsx,md,mdx,json}"],
23
- extensions: [
24
- "txt",
25
- "text",
26
- "md",
27
- "markdown",
28
- "mkd",
29
- "mkdn",
30
- "mkdown",
31
- "ron"
32
- ],
33
- configTransform: transform,
34
- out: false,
35
- output: false,
36
- rcName,
37
- rcPath: undefined,
38
- packageField: "alex",
39
- color: Boolean(supportsColor.stderr),
40
- reporter: vfileReporter,
41
- reporterOptions: {
42
- verbose: false
43
- },
44
- quiet: true,
45
- ignoreName,
46
- ignorePatterns: [
47
- "**/CODE_OF_CONDUCT.md",
48
- "**/dist/**",
49
- "**/node_modules/**"
50
- ],
51
- silent: false,
52
- silentlyIgnore: true,
53
- frail: true,
54
- defaultConfig: transform({})
55
- },
56
- (error, code) => {
57
- if (error) {
58
- console.error(error.message);
59
- return reject(code);
60
- }
61
- return resolve(code);
62
- }
63
- )
64
- );
65
- };
66
-
67
- const transform = (options: any) => {
68
- return {
69
- plugins: [
70
- retextEnglish,
71
- [retextProfanities, { sureness: options.profanitySureness }],
72
- [retextEquality, { noBinary: options.noBinary }],
73
- [
74
- filter,
75
- {
76
- allow: options.allow,
77
- deny: options.deny
78
- }
79
- ]
80
- ] as PluggableList
81
- };
82
- };
package/src/cli/index.ts DELETED
@@ -1,289 +0,0 @@
1
- import {
2
- type StormConfig,
3
- findWorkspaceRootSafe,
4
- writeDebug,
5
- writeError,
6
- writeFatal,
7
- writeInfo,
8
- writeSuccess,
9
- writeTrace
10
- } from "@storm-software/config-tools";
11
- import { Command, Option } from "commander";
12
- import { lint } from "cspell";
13
- import { parseCircular, parseDependencyTree, prettyCircular } from "dpdm";
14
- import { runAlex } from "../alex";
15
- import { runManypkg } from "../manypkg";
16
- export { findWorkspaceRootSafe } from "@storm-software/config-tools";
17
-
18
- let _config: Partial<StormConfig> = {};
19
-
20
- export function createProgram(config: StormConfig) {
21
- try {
22
- _config = config;
23
- writeInfo(config, "⚡ Running Storm Linting Tools");
24
-
25
- const root = findWorkspaceRootSafe();
26
- process.env.STORM_WORKSPACE_ROOT ??= root;
27
- process.env.NX_WORKSPACE_ROOT_PATH ??= root;
28
- root && process.chdir(root);
29
-
30
- const program = new Command("storm-lint");
31
- program.version("1.0.0", "-v --version", "display CLI version");
32
-
33
- program
34
- .description("⚡ Lint the Storm Workspace")
35
- .showHelpAfterError()
36
- .showSuggestionAfterError();
37
-
38
- const cspellConfig = new Option("--cspell-config <file>", "CSpell config file path").default(
39
- "@storm-software/linting-tools/cspell/config.js"
40
- );
41
-
42
- program
43
- .command("cspell")
44
- .description("Run spell-check lint for the workspace.")
45
- .addOption(cspellConfig)
46
- .action(cspellAction);
47
-
48
- const alexConfig = new Option("--alex-config <file>", "Alex.js config file path").default(
49
- "@storm-software/linting-tools/alex/.alexrc"
50
- );
51
-
52
- const alexIgnore = new Option("--alex-ignore <file>", "Alex.js Ignore file path").default(
53
- "@storm-software/linting-tools/alex/.alexignore"
54
- );
55
-
56
- program
57
- .command("alex")
58
- .description("Run spell-check lint for the workspace.")
59
- .addOption(alexConfig)
60
- .addOption(alexIgnore)
61
- .action(alexAction);
62
-
63
- program
64
- .command("deps-version")
65
- .description("Run dependency version consistency lint for the workspace.")
66
- .action(depsVersionAction);
67
-
68
- program
69
- .command("circular-deps")
70
- .description("Run circular dependency lint for the workspace.")
71
- .action(circularDepsAction);
72
-
73
- const manypkgType = new Option("--manypkg-type <type>", "The manypkg command to run").default(
74
- "check"
75
- );
76
-
77
- const manypkgArgs = new Option(
78
- "--manypkg-args <args>",
79
- "The args provided to the manypkg command"
80
- ).default([]);
81
-
82
- const manypkgFix = new Option(
83
- "--manypkg-fix <args>",
84
- "The args provided to the manypkg command"
85
- ).default(true);
86
-
87
- program
88
- .command("manypkg")
89
- .description("Run package lint with Manypkg for the workspace.")
90
- .addOption(manypkgType)
91
- .addOption(manypkgArgs)
92
- .addOption(manypkgFix)
93
- .action(manypkgAction);
94
-
95
- const cspellSkip = new Option("--skip-cspell", "Should skip CSpell linting");
96
-
97
- const alexSkip = new Option("--skip-alex", "Should skip Alex language linting");
98
-
99
- const depsVersionSkip = new Option(
100
- "--skip-deps-version",
101
- "Should skip dependency version consistency linting"
102
- );
103
-
104
- const circularDepsSkip = new Option(
105
- "--skip-circular-deps",
106
- "Should skip circular dependency linting"
107
- );
108
-
109
- const manypkgSkip = new Option("--skip-manypkg", "Should skip Manypkg linting");
110
-
111
- program
112
- .command("all")
113
- .description("Run all linters for the workspace.")
114
- .addOption(cspellSkip)
115
- .addOption(alexSkip)
116
- .addOption(depsVersionSkip)
117
- .addOption(circularDepsSkip)
118
- .addOption(manypkgSkip)
119
- .addOption(cspellConfig)
120
- .addOption(alexConfig)
121
- .addOption(alexIgnore)
122
- .addOption(manypkgType)
123
- .addOption(manypkgArgs)
124
- .addOption(manypkgFix)
125
- .action(allAction);
126
-
127
- return program;
128
- } catch (e) {
129
- writeFatal(config, `A fatal error occurred while running the program: ${e.message}`);
130
- process.exit(1);
131
- }
132
- }
133
-
134
- async function allAction(
135
- cspellSkip: boolean,
136
- alexSkip: boolean,
137
- depsVersionSkip: boolean,
138
- circularDepsSkip: boolean,
139
- manypkgSkip: boolean,
140
- cspellConfig: string,
141
- alexConfig: string,
142
- alexIgnore: string,
143
- manypkgType: string,
144
- manypkgArgs: string[],
145
- manypkgFix: boolean
146
- ) {
147
- try {
148
- writeInfo(_config, "⚡ Linting the Storm Workspace");
149
-
150
- const promises = [];
151
- if (!cspellSkip) {
152
- promises.push(cspellAction(cspellConfig));
153
- }
154
-
155
- if (!alexSkip) {
156
- promises.push(alexAction(alexConfig, alexIgnore));
157
- }
158
-
159
- if (!depsVersionSkip) {
160
- promises.push(depsVersionAction());
161
- }
162
-
163
- if (!circularDepsSkip) {
164
- promises.push(circularDepsAction());
165
- }
166
-
167
- if (!manypkgSkip) {
168
- promises.push(manypkgAction(manypkgType, manypkgArgs, manypkgFix));
169
- }
170
-
171
- await Promise.all(promises);
172
- writeSuccess(_config, "Successfully linted the workspace ✅");
173
- } catch (e) {
174
- writeFatal(_config, `A fatal error occurred while linting the workspace: ${e.message}`);
175
- process.exit(1);
176
- }
177
- }
178
-
179
- async function cspellAction(cspellConfig: string) {
180
- try {
181
- console.log("⚡Linting the workspace spelling");
182
- const result = await lint(["**/*.{txt,js,jsx,ts,tsx,md,mdx}"], {
183
- cache: true,
184
- summary: true,
185
- issues: true,
186
- progress: false,
187
- relative: true,
188
- dot: true,
189
- debug: true,
190
- gitignore: true,
191
- root: process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.cwd(),
192
- defaultConfiguration: false,
193
- config: cspellConfig
194
- });
195
- if (result.errors) {
196
- writeError(_config, "Spelling linting has failed ❌");
197
- process.exit(1);
198
- }
199
-
200
- writeSuccess(_config, "Spelling linting is complete ✅");
201
- } catch (e) {
202
- console.error(e);
203
- process.exit(1);
204
- }
205
- }
206
-
207
- async function alexAction(alexConfig: string, alexIgnore: string) {
208
- try {
209
- writeInfo(_config, "⚡ Linting the workspace language with alexjs.com");
210
-
211
- if (await runAlex(alexConfig, alexIgnore)) {
212
- writeError(_config, "Language linting has failed ❌");
213
- process.exit(1);
214
- }
215
-
216
- writeSuccess(_config, "Language linting is complete ✅");
217
- } catch (e) {
218
- writeFatal(
219
- _config,
220
- `A fatal error occurred while language linting the workspace: ${e.message}`
221
- );
222
- process.exit(1);
223
- }
224
- }
225
-
226
- async function depsVersionAction() {
227
- try {
228
- writeInfo(_config, "⚡ Linting the workspace dependency version consistency");
229
-
230
- const { CDVC } = await import("check-dependency-version-consistency");
231
- const cdvc = new CDVC(".", { fix: true });
232
-
233
- // Show output for dependencies we fixed.
234
- if (cdvc.hasMismatchingDependenciesFixable) {
235
- writeDebug(_config, cdvc.toFixedSummary());
236
- }
237
-
238
- // Show output for dependencies that still have mismatches.
239
- if (cdvc.hasMismatchingDependenciesNotFixable) {
240
- writeError(_config, "Dependency version consistency linting has failed ❌");
241
- writeError(_config, cdvc.toMismatchSummary());
242
- process.exit(1);
243
- }
244
-
245
- writeSuccess(_config, "Dependency Version linting is complete ✅");
246
- } catch (e) {
247
- writeFatal(
248
- _config,
249
- `A fatal error occurred while dependency Version linting the workspace: ${e.message}`
250
- );
251
- process.exit(1);
252
- }
253
- }
254
-
255
- async function circularDepsAction() {
256
- try {
257
- writeInfo(_config, "⚡ Linting the workspace circular dependency");
258
-
259
- const tree = await parseDependencyTree("**/*.*", {
260
- tsconfig: "./tsconfig.base.json",
261
- transform: true,
262
- skipDynamicImports: false
263
- });
264
-
265
- const circulars = parseCircular(tree);
266
- writeTrace(_config, prettyCircular(circulars));
267
-
268
- writeSuccess(_config, "Circular dependency linting is complete ✅");
269
- } catch (e) {
270
- writeFatal(
271
- _config,
272
- `A fatal error occurred while circular dependency linting the workspace: ${e.message}`
273
- );
274
- process.exit(1);
275
- }
276
- }
277
-
278
- async function manypkgAction(manypkgType = "check", manypkgArgs: string[], manypkgFix: boolean) {
279
- try {
280
- writeInfo(_config, "⚡ Linting the workspace's packages with Manypkg");
281
-
282
- await runManypkg(manypkgType, manypkgArgs, manypkgFix);
283
-
284
- writeSuccess(_config, "Manypkg linting is complete ✅");
285
- } catch (e) {
286
- writeFatal(_config, `A fatal error occurred while manypkg linting the workspace: ${e.message}`);
287
- process.exit(1);
288
- }
289
- }
@@ -1,7 +0,0 @@
1
- export * from "./graphql";
2
- export * from "./javascript";
3
- export * from "./jest";
4
- export * from "./json";
5
- export * from "./next";
6
- export * from "./react";
7
- export * from "./typescript";
@@ -1,22 +0,0 @@
1
- import { Linter } from "eslint";
2
- import importRules from "../rules/import";
3
- import stormRules from "../rules/storm";
4
- import unicornRules from "../rules/unicorn";
5
-
6
- const config: Linter.Config = {
7
- root: true,
8
- overrides: [
9
- {
10
- files: ["*.js", "*.jsx"],
11
- extends: ["plugin:@nx/javascript"],
12
- plugins: ["unicorn", "import"],
13
- rules: {
14
- ...importRules,
15
- ...unicornRules,
16
- ...stormRules
17
- }
18
- }
19
- ]
20
- };
21
-
22
- export default config;
@@ -1,16 +0,0 @@
1
- import { Linter } from "eslint";
2
-
3
- const config: Linter.Config = {
4
- root: true,
5
- overrides: [
6
- {
7
- files: ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
8
- env: {
9
- jest: true
10
- },
11
- rules: {}
12
- }
13
- ]
14
- };
15
-
16
- export default config;
@@ -1,37 +0,0 @@
1
- import { Linter } from "eslint";
2
- import { CODE_BLOCK } from "../constants";
3
-
4
- const JSONC_FILES = [
5
- "tsconfig.json",
6
- "tsconfig.base.json",
7
- "nx.json",
8
- ".vscode/launch.json"
9
- ];
10
- const config: Linter.Config = {
11
- root: true,
12
- overrides: [
13
- {
14
- files: "*.json",
15
- excludedFiles: JSONC_FILES,
16
- extends: "plugin:jsonc/recommended-with-json"
17
- },
18
- {
19
- files: ["*.jsonc", ...JSONC_FILES],
20
- extends: "plugin:jsonc/recommended-with-jsonc"
21
- },
22
- {
23
- files: "*.json5",
24
- extends: "plugin:jsonc/recommended-with-json5"
25
- },
26
- {
27
- files: "*.json{,c,5}",
28
- excludedFiles: CODE_BLOCK,
29
- plugins: ["unicorn"],
30
- rules: {
31
- "unicorn/filename-case": "error"
32
- }
33
- }
34
- ]
35
- };
36
-
37
- export default config;
@@ -1,25 +0,0 @@
1
- import { JS_FILES } from "../constants";
2
-
3
- const babelOptions = {
4
- presets: (() => {
5
- try {
6
- require.resolve("next/babel");
7
- return ["next/babel"];
8
- } catch (e) {
9
- return [];
10
- }
11
- })()
12
- };
13
-
14
- const config = {
15
- root: true,
16
- extends: ["plugin:@next/next/recommended"],
17
- overrides: [
18
- {
19
- files: JS_FILES,
20
- parserOptions: { babelOptions }
21
- }
22
- ]
23
- };
24
-
25
- export default config;
@@ -1,25 +0,0 @@
1
- import { Linter } from "eslint";
2
- import reactRules from "../rules/react";
3
- import jsxA11yRules from "../rules/ts-docs";
4
-
5
- const config: Linter.Config = {
6
- root: true,
7
- extends: [
8
- "plugin:react/recommended",
9
- "plugin:react-hooks/recommended",
10
- "plugin:jsx-a11y/recommended",
11
- "plugin:import/react",
12
- "prettier"
13
- ],
14
- settings: {
15
- react: {
16
- version: "detect"
17
- }
18
- },
19
- rules: {
20
- ...jsxA11yRules,
21
- ...reactRules
22
- }
23
- };
24
-
25
- export default config;