@storm-software/linting-tools 1.44.8 → 1.44.9

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 (43) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +201 -0
  3. package/README.md +1 -1
  4. package/bin/lint.js +334927 -0
  5. package/package.json +1 -1
  6. package/src/cli/index.js +328523 -0
  7. package/src/eslint/graphql/{index.ts → index.js} +7 -4
  8. package/src/eslint/{rules/storm.ts → javascript/index.js} +136 -3
  9. package/src/eslint/jest/index.js +19 -0
  10. package/src/eslint/json/index.js +90 -0
  11. package/src/eslint/next/index.js +90 -0
  12. package/src/eslint/{rules/react.ts → react/index.js} +39 -3
  13. package/src/eslint/typescript/index.js +558 -0
  14. package/src/manypkg/index.js +34729 -0
  15. package/.eslintrc.json +0 -97
  16. package/jest.config.ts +0 -11
  17. package/project.json +0 -120
  18. package/src/alex/index.ts +0 -67
  19. package/src/cli/index.ts +0 -300
  20. package/src/eslint/constants.ts +0 -87
  21. package/src/eslint/index.ts +0 -7
  22. package/src/eslint/javascript/index.ts +0 -22
  23. package/src/eslint/jest/index.ts +0 -16
  24. package/src/eslint/json/index.ts +0 -32
  25. package/src/eslint/next/index.ts +0 -25
  26. package/src/eslint/react/index.ts +0 -25
  27. package/src/eslint/rules/import.ts +0 -85
  28. package/src/eslint/rules/jsx-a11y.ts +0 -8
  29. package/src/eslint/rules/ts-docs.ts +0 -12
  30. package/src/eslint/rules/unicorn.ts +0 -23
  31. package/src/eslint/typescript/index.ts +0 -132
  32. package/src/manypkg/index.ts +0 -164
  33. package/tsconfig.json +0 -23
  34. package/tsconfig.spec.json +0 -13
  35. /package/{src/alex → alex}/.alexignore +0 -0
  36. /package/{src/alex → alex}/.alexrc +0 -0
  37. /package/{src/biome → biome}/biome.json +0 -0
  38. /package/{src/cspell → cspell}/config.json +0 -0
  39. /package/{src/cspell → cspell}/dictionary.txt +0 -0
  40. /package/{src/ls-lint → ls-lint}/.ls-lint.yml +0 -0
  41. /package/{src/prettier → prettier}/.prettierignore +0 -0
  42. /package/{src/prettier → prettier}/config.json +0 -0
  43. /package/{src/taplo → taplo}/.taplo.toml +0 -0
package/.eslintrc.json DELETED
@@ -1,97 +0,0 @@
1
- {
2
- "extends": ["../../.eslintrc.json", "../../.eslintrc.base.json"],
3
- "ignorePatterns": ["!**/*", "node_modules/*"],
4
- "overrides": [
5
- {
6
- "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7
- "rules": {}
8
- },
9
- {
10
- "files": ["*.ts", "*.tsx"],
11
- "rules": {}
12
- },
13
- {
14
- "files": ["*.js", "*.jsx"],
15
- "rules": {}
16
- },
17
- {
18
- "files": ["*.json"],
19
- "parser": "jsonc-eslint-parser",
20
- "rules": {
21
- "@nx/dependency-checks": [
22
- "error",
23
- {
24
- "buildTargets": ["build"],
25
- "ignoredFiles": [
26
- "{projectRoot}/esbuild.config.{js,ts,mjs,mts}",
27
- "{projectRoot}/jest.config.ts"
28
- ],
29
- "ignoredDependencies": [
30
- "@cspell/dict-ada",
31
- "@cspell/dict-aws",
32
- "@cspell/dict-bash",
33
- "@cspell/dict-companies",
34
- "@cspell/dict-cpp",
35
- "@cspell/dict-cryptocurrencies",
36
- "@cspell/dict-csharp",
37
- "@cspell/dict-css",
38
- "@cspell/dict-dart",
39
- "@cspell/dict-django",
40
- "@cspell/dict-docker",
41
- "@cspell/dict-dotnet",
42
- "@cspell/dict-elixir",
43
- "@cspell/dict-en_us",
44
- "@cspell/dict-en-common-misspellings",
45
- "@cspell/dict-en-gb",
46
- "@cspell/dict-filetypes",
47
- "@cspell/dict-fonts",
48
- "@cspell/dict-fsharp",
49
- "@cspell/dict-fullstack",
50
- "@cspell/dict-gaming-terms",
51
- "@cspell/dict-git",
52
- "@cspell/dict-golang",
53
- "@cspell/dict-haskell",
54
- "@cspell/dict-html-symbol-entities",
55
- "@cspell/dict-html",
56
- "@cspell/dict-java",
57
- "@cspell/dict-k8s",
58
- "@cspell/dict-latex",
59
- "@cspell/dict-lorem-ipsum",
60
- "@cspell/dict-lua",
61
- "@cspell/dict-makefile",
62
- "@cspell/dict-node",
63
- "@cspell/dict-npm",
64
- "@cspell/dict-php",
65
- "@cspell/dict-powershell",
66
- "@cspell/dict-public-licenses",
67
- "@cspell/dict-python",
68
- "@cspell/dict-r",
69
- "@cspell/dict-ruby",
70
- "@cspell/dict-rust",
71
- "@cspell/dict-scala",
72
- "@cspell/dict-sql",
73
- "@cspell/dict-software-terms",
74
- "@cspell/dict-svelte",
75
- "@cspell/dict-swift",
76
- "@cspell/dict-typescript",
77
- "@cspell/dict-vue",
78
- "@size-limit/file",
79
- "@size-limit/time",
80
- "size-limit",
81
- "remark-retext",
82
- "remark-parse",
83
- "remark-mdx",
84
- "remark-gfm",
85
- "remark-frontmatter",
86
- "rehype-retext",
87
- "rehype-parse"
88
- ],
89
- "checkMissingDependencies": true,
90
- "checkObsoleteDependencies": true,
91
- "checkVersionMismatches": false
92
- }
93
- ]
94
- }
95
- }
96
- ]
97
- }
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,120 +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": [
10
- "{options.outputPath}"
11
- ],
12
- "options": {
13
- "outputPath": "dist/packages/linting-tools",
14
- "tsConfig": "packages/linting-tools/tsconfig.json",
15
- "project": "packages/linting-tools/package.json",
16
- "main": "packages/linting-tools/src/cli/index.ts",
17
- "additionalEntryPoints": [
18
- "packages/linting-tools/bin/lint.ts",
19
- "packages/linting-tools/src/eslint/graphql/index.ts",
20
- "packages/linting-tools/src/eslint/javascript/index.ts",
21
- "packages/linting-tools/src/eslint/json/index.ts",
22
- "packages/linting-tools/src/eslint/jest/index.ts",
23
- "packages/linting-tools/src/eslint/next/index.ts",
24
- "packages/linting-tools/src/eslint/react/index.ts",
25
- "packages/linting-tools/src/eslint/typescript/index.ts",
26
- "packages/linting-tools/src/manypkg/index.ts"
27
- ],
28
- "deleteOutputPath": true,
29
- "bundle": true,
30
- "sourcemap": false,
31
- "minify": false,
32
- "skipTypeCheck": true,
33
- "thirdParty": true,
34
- "format": [
35
- "esm"
36
- ],
37
- "external": [
38
- "nx"
39
- ],
40
- "esbuildOptions": {
41
- "legalComments": "inline",
42
- "banner": {
43
- "js": "const require = (await import('node:module')).createRequire(import.meta.url);const __filename = (await import('node:url')).fileURLToPath(import.meta.url);const __dirname = (await import('node:path')).dirname(__filename);"
44
- }
45
- },
46
- "assets": [
47
- {
48
- "input": "packages/linting-tools",
49
- "glob": "README.md",
50
- "output": "."
51
- },
52
- {
53
- "input": "packages/linting-tools",
54
- "glob": "CHANGELOG.md",
55
- "output": "."
56
- },
57
- {
58
- "input": "",
59
- "glob": "LICENSE",
60
- "output": "."
61
- },
62
- {
63
- "input": "packages/linting-tools",
64
- "glob": "bin/**/*",
65
- "output": "."
66
- },
67
- {
68
- "input": "packages/linting-tools/src",
69
- "glob": "alex/**/.{alexrc,alexignore}",
70
- "output": "."
71
- },
72
- {
73
- "input": "packages/linting-tools/src",
74
- "glob": "biome/biome.json",
75
- "output": "."
76
- },
77
- {
78
- "input": "packages/linting-tools/src",
79
- "glob": "taplo/*",
80
- "output": "."
81
- },
82
- {
83
- "input": "packages/linting-tools/src",
84
- "glob": "ls-lint/*",
85
- "output": "."
86
- },
87
- {
88
- "input": "packages/linting-tools/src",
89
- "glob": "cspell/**/dictionary.txt",
90
- "output": "."
91
- },
92
- {
93
- "input": "packages/linting-tools/src",
94
- "glob": "cspell/**/*.json",
95
- "output": "."
96
- },
97
- {
98
- "input": "packages/linting-tools/node_modules",
99
- "glob": "@cspell/**/cspell-ext.json",
100
- "output": "cspell"
101
- },
102
- {
103
- "input": "packages/linting-tools/src",
104
- "glob": "prettier/**/*.*",
105
- "output": "."
106
- },
107
- {
108
- "input": "packages/linting-tools/src",
109
- "glob": "tsconfig/**/*.*",
110
- "output": "."
111
- }
112
- ]
113
- }
114
- }
115
- },
116
- "tags": [
117
- "type:util",
118
- "scope:tools"
119
- ]
120
- }
package/src/alex/index.ts DELETED
@@ -1,67 +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 { type PluggableList, unified } from "unified";
7
- import { engine } from "unified-engine";
8
- import vfileReporter from "vfile-reporter";
9
-
10
- Error.stackTraceLimit = Infinity;
11
-
12
- export const runAlex = (
13
- rcName = "@storm-software/linting-tools/alex/.alexrc",
14
- ignoreName = "@storm-software/linting-tools/alex/.alexignore"
15
- ) => {
16
- return new Promise((resolve: (value: unknown) => void, reject: (reason?: any) => void) =>
17
- engine(
18
- {
19
- processor: unified(),
20
- files: ["**/*.{txt,js,jsx,ts,tsx,md,mdx,json}"],
21
- extensions: ["txt", "text", "md", "mdx", "markdown", "mkd", "mkdn", "mkdown", "ron"],
22
- configTransform: transform,
23
- out: false,
24
- output: false,
25
- rcName,
26
- rcPath: undefined,
27
- packageField: "alex",
28
- color: true,
29
- reporter: vfileReporter,
30
- reporterOptions: {
31
- verbose: false
32
- },
33
- quiet: true,
34
- ignoreName,
35
- ignorePatterns: ["**/CODE_OF_CONDUCT.md", "**/dist/**", "**/node_modules/**"],
36
- silent: false,
37
- silentlyIgnore: true,
38
- frail: true,
39
- defaultConfig: transform({})
40
- },
41
- (error, code) => {
42
- if (error) {
43
- console.error(error.message);
44
- return reject(code);
45
- }
46
- return resolve(code);
47
- }
48
- )
49
- );
50
- };
51
-
52
- const transform = (options: any) => {
53
- return {
54
- plugins: [
55
- retextEnglish,
56
- [retextProfanities, { sureness: options.profanitySureness }],
57
- [retextEquality, { noBinary: options.noBinary }],
58
- [
59
- filter,
60
- {
61
- allow: options.allow,
62
- deny: options.deny
63
- }
64
- ]
65
- ] as PluggableList
66
- };
67
- };
package/src/cli/index.ts DELETED
@@ -1,300 +0,0 @@
1
- import {
2
- findWorkspaceRootSafe,
3
- writeDebug,
4
- writeError,
5
- writeFatal,
6
- writeInfo,
7
- writeSuccess,
8
- writeTrace
9
- } from "@storm-software/config-tools";
10
- import type { StormConfig } from "@storm-software/config";
11
- import { lint } from "cspell";
12
- import { parseCircular, parseDependencyTree, prettyCircular } from "dpdm";
13
- import { runAlex } from "../alex";
14
- import { runManypkg } from "../manypkg";
15
- import { Command, Option } from "commander";
16
-
17
- let _config: Partial<StormConfig> = {};
18
-
19
- export function createProgram(config: StormConfig) {
20
- try {
21
- _config = config;
22
- writeInfo(config, "⚡ Running Storm Linting Tools");
23
-
24
- const root = findWorkspaceRootSafe();
25
- process.env.STORM_WORKSPACE_ROOT ??= root;
26
- process.env.NX_WORKSPACE_ROOT_PATH ??= root;
27
- root && process.chdir(root);
28
-
29
- const program = new Command("storm-lint");
30
- program.version("1.0.0", "-v --version", "display CLI version");
31
-
32
- program
33
- .description("⚡ Lint the Storm Workspace")
34
- .showHelpAfterError()
35
- .showSuggestionAfterError();
36
-
37
- const cspellConfig = new Option("--cspell-config <file>", "CSpell config file path").default(
38
- "@storm-software/linting-tools/cspell/config.js"
39
- );
40
-
41
- program
42
- .command("cspell")
43
- .description("Run spell-check lint for the workspace.")
44
- .addOption(cspellConfig)
45
- .action(cspellAction);
46
-
47
- const alexConfig = new Option("--alex-config <file>", "Alex.js config file path").default(
48
- "@storm-software/linting-tools/alex/.alexrc"
49
- );
50
-
51
- const alexIgnore = new Option("--alex-ignore <file>", "Alex.js Ignore file path").default(
52
- "@storm-software/linting-tools/alex/.alexignore"
53
- );
54
-
55
- program
56
- .command("alex")
57
- .description("Run spell-check lint for the workspace.")
58
- .addOption(alexConfig)
59
- .addOption(alexIgnore)
60
- .action(alexAction);
61
-
62
- program
63
- .command("deps-version")
64
- .description("Run dependency version consistency lint for the workspace.")
65
- .action(depsVersionAction);
66
-
67
- program
68
- .command("circular-deps")
69
- .description("Run circular dependency lint for the workspace.")
70
- .action(circularDepsAction);
71
-
72
- const manypkgType = new Option("--manypkg-type <type>", "The manypkg command to run").default(
73
- "check"
74
- );
75
-
76
- const manypkgArgs = new Option(
77
- "--manypkg-args <args>",
78
- "The args provided to the manypkg command"
79
- ).default([]);
80
-
81
- const manypkgFix = new Option(
82
- "--manypkg-fix <args>",
83
- "The args provided to the manypkg command"
84
- ).default(true);
85
-
86
- program
87
- .command("manypkg")
88
- .description("Run package lint with Manypkg for the workspace.")
89
- .addOption(manypkgType)
90
- .addOption(manypkgArgs)
91
- .addOption(manypkgFix)
92
- .action(manypkgAction);
93
-
94
- const skipCspell = new Option("--skip-cspell", "Should skip CSpell linting");
95
-
96
- const skipAlex = new Option("--skip-alex", "Should skip Alex language linting");
97
-
98
- const skipDepsVersion = new Option(
99
- "--skip-deps-version",
100
- "Should skip dependency version consistency linting"
101
- );
102
-
103
- const skipCircularDeps = new Option(
104
- "--skip-circular-deps",
105
- "Should skip circular dependency linting"
106
- );
107
-
108
- const skipManypkg = new Option("--skip-manypkg", "Should skip Manypkg linting");
109
-
110
- program
111
- .command("all")
112
- .description("Run all linters for the workspace.")
113
- .addOption(skipCspell)
114
- .addOption(skipAlex)
115
- .addOption(skipDepsVersion)
116
- .addOption(skipCircularDeps)
117
- .addOption(skipManypkg)
118
- .addOption(cspellConfig)
119
- .addOption(alexConfig)
120
- .addOption(alexIgnore)
121
- .addOption(manypkgType)
122
- .addOption(manypkgArgs)
123
- .addOption(manypkgFix)
124
- .action(allAction);
125
-
126
- return program;
127
- } catch (e) {
128
- writeFatal(config, `A fatal error occurred while running the program: ${e.message}`);
129
- process.exit(1);
130
- }
131
- }
132
-
133
- async function allAction({
134
- skipCspell,
135
- skipAlex,
136
- skipDepsVersion,
137
- skipCircularDeps,
138
- skipManypkg,
139
- cspellConfig,
140
- alexConfig,
141
- alexIgnore,
142
- manypkgType,
143
- manypkgArgs,
144
- manypkgFix
145
- }: {
146
- skipCspell: boolean;
147
- skipAlex: boolean;
148
- skipDepsVersion: boolean;
149
- skipCircularDeps: boolean;
150
- skipManypkg: boolean;
151
- cspellConfig: string;
152
- alexConfig: string;
153
- alexIgnore: string;
154
- manypkgType: string;
155
- manypkgArgs: string[];
156
- manypkgFix: boolean;
157
- }) {
158
- try {
159
- writeInfo(_config, "⚡ Linting the Storm Workspace");
160
-
161
- const promises = [] as Promise<any>[];
162
- if (!skipCspell) {
163
- promises.push(cspellAction(cspellConfig));
164
- }
165
-
166
- if (!skipAlex) {
167
- promises.push(alexAction(alexConfig, alexIgnore));
168
- }
169
-
170
- if (!skipDepsVersion) {
171
- promises.push(depsVersionAction());
172
- }
173
-
174
- if (!skipCircularDeps) {
175
- promises.push(circularDepsAction());
176
- }
177
-
178
- if (!skipManypkg) {
179
- promises.push(manypkgAction(manypkgType, manypkgArgs, manypkgFix));
180
- }
181
-
182
- await Promise.all(promises);
183
- writeSuccess(_config, "Successfully linted the workspace ✅");
184
- } catch (e) {
185
- writeFatal(_config, `A fatal error occurred while linting the workspace: ${e.message}`);
186
- process.exit(1);
187
- }
188
- }
189
-
190
- async function cspellAction(cspellConfig: string) {
191
- try {
192
- console.log("⚡Linting the workspace spelling");
193
- const result = await lint(["**/*.{txt,js,jsx,ts,tsx,md,mdx}"], {
194
- cache: true,
195
- summary: true,
196
- issues: true,
197
- progress: false,
198
- relative: true,
199
- dot: true,
200
- debug: true,
201
- gitignore: true,
202
- root: process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.cwd(),
203
- defaultConfiguration: false,
204
- config: cspellConfig
205
- });
206
- if (result.errors) {
207
- writeError(_config, "Spelling linting has failed ❌");
208
- process.exit(1);
209
- }
210
-
211
- writeSuccess(_config, "Spelling linting is complete ✅");
212
- } catch (e) {
213
- console.error(e);
214
- process.exit(1);
215
- }
216
- }
217
-
218
- async function alexAction(alexConfig: string, alexIgnore: string) {
219
- try {
220
- writeInfo(_config, "⚡ Linting the workspace language with alexjs.com");
221
-
222
- if (await runAlex(alexConfig, alexIgnore)) {
223
- writeError(_config, "Language linting has failed ❌");
224
- process.exit(1);
225
- }
226
-
227
- writeSuccess(_config, "Language linting is complete ✅");
228
- } catch (e) {
229
- writeFatal(
230
- _config,
231
- `A fatal error occurred while language linting the workspace: ${e.message}`
232
- );
233
- process.exit(1);
234
- }
235
- }
236
-
237
- async function depsVersionAction() {
238
- try {
239
- writeInfo(_config, "⚡ Linting the workspace dependency version consistency");
240
-
241
- const { CDVC } = await import("check-dependency-version-consistency");
242
- const cdvc = new CDVC(".", { fix: true });
243
-
244
- // Show output for dependencies we fixed.
245
- if (cdvc.hasMismatchingDependenciesFixable) {
246
- writeDebug(_config, cdvc.toFixedSummary());
247
- }
248
-
249
- // Show output for dependencies that still have mismatches.
250
- if (cdvc.hasMismatchingDependenciesNotFixable) {
251
- writeError(_config, "Dependency version consistency linting has failed ❌");
252
- writeError(_config, cdvc.toMismatchSummary());
253
- process.exit(1);
254
- }
255
-
256
- writeSuccess(_config, "Dependency Version linting is complete ✅");
257
- } catch (e) {
258
- writeFatal(
259
- _config,
260
- `A fatal error occurred while dependency Version linting the workspace: ${e.message}`
261
- );
262
- process.exit(1);
263
- }
264
- }
265
-
266
- async function circularDepsAction() {
267
- try {
268
- writeInfo(_config, "⚡ Linting the workspace circular dependency");
269
-
270
- const tree = await parseDependencyTree("**/*.*", {
271
- tsconfig: "./tsconfig.base.json",
272
- transform: true,
273
- skipDynamicImports: false
274
- });
275
-
276
- const circulars = parseCircular(tree);
277
- writeTrace(_config, prettyCircular(circulars));
278
-
279
- writeSuccess(_config, "Circular dependency linting is complete ✅");
280
- } catch (e) {
281
- writeFatal(
282
- _config,
283
- `A fatal error occurred while circular dependency linting the workspace: ${e.message}`
284
- );
285
- process.exit(1);
286
- }
287
- }
288
-
289
- async function manypkgAction(manypkgType = "check", manypkgArgs: string[], manypkgFix: boolean) {
290
- try {
291
- writeInfo(_config, "⚡ Linting the workspace's packages with Manypkg");
292
-
293
- await runManypkg(manypkgType, manypkgArgs, manypkgFix);
294
-
295
- writeSuccess(_config, "Manypkg linting is complete ✅");
296
- } catch (e) {
297
- writeFatal(_config, `A fatal error occurred while manypkg linting the workspace: ${e.message}`);
298
- process.exit(1);
299
- }
300
- }
@@ -1,87 +0,0 @@
1
- export const RESTRICTED_SYNTAX = [
2
- {
3
- // ❌ readFile(…, { encoding: … })
4
- selector:
5
- "CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]",
6
- message: "Specify encoding as last argument instead of object with encoding key"
7
- },
8
- {
9
- // ❌ readFile(…, {})
10
- selector:
11
- "CallExpression[callee.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]",
12
- message: "Specify encoding as last argument"
13
- },
14
- {
15
- // ❌ readFileSync(…).toString(…)
16
- selector: "CallExpression[callee.name=readFileSync][parent.property.name=toString]",
17
- message: "toString is redundant, specify encoding as last argument"
18
- },
19
- {
20
- // ❌ ….readFile(…, { encoding: … })
21
- selector:
22
- "CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=1] Property[key.name=encoding]",
23
- message: "Specify encoding as last argument instead of object with encoding key"
24
- },
25
- {
26
- // ❌ ….readFile(…, {})
27
- selector:
28
- "CallExpression[callee.type=MemberExpression][callee.property.name=/readFileSync|readFile|writeFileSync|writeFile/] > .arguments:last-child[type=ObjectExpression][properties.length=0]",
29
- message: "Specify encoding as last argument"
30
- },
31
- {
32
- // ❌ Boolean(…)
33
- selector: "CallExpression[callee.name=Boolean][arguments.1.elements.length!=0]",
34
- message:
35
- "Prefer `!!…` over `Boolean(…)` because TypeScript infers a narrow literal boolean `type: true` instead of `type: boolean`."
36
- },
37
- {
38
- // ❌ process.browser
39
- selector:
40
- "ExpressionStatement[expression.object.name=process][expression.property.name=browser]",
41
- message: "`process.browser` is deprecated, use `!!globalThis.window`"
42
- }
43
- // {
44
- // // ❌ let { foo: { bar } } = baz
45
- // // ✅ let { bar } = baz.foo
46
- // // ✅ let { foo: { bar } } = await baz
47
- // selector:
48
- // 'VariableDeclarator[init.type!=AwaitExpression] > ObjectPattern[properties.length=1][properties.0.value.type=ObjectPattern]',
49
- // message: 'Do not use nested destructuring.',
50
- // },
51
- ];
52
-
53
- export const REACT_RESTRICTED_SYNTAX = [
54
- ...RESTRICTED_SYNTAX,
55
- {
56
- // ❌ useMemo(…, [])
57
- selector:
58
- "CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]",
59
- message:
60
- "`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead."
61
- }
62
- ];
63
-
64
- export const RESTRICTED_GLOBALS = ["stop", { name: "isNaN", message: "Use Number.isNaN instead" }];
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." }
81
- ];
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}";
@@ -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";