@qq99/eslint-plugin-solid 0.18.0-no-reactive-read-in-effect-callback.0
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/LICENSE +21 -0
- package/README.md +289 -0
- package/dist/chunk-4UZNJ5MS.mjs +32 -0
- package/dist/chunk-4UZNJ5MS.mjs.map +1 -0
- package/dist/chunk-EBU4C5NV.mjs +77 -0
- package/dist/chunk-EBU4C5NV.mjs.map +1 -0
- package/dist/chunk-LE6SW2M3.mjs +6231 -0
- package/dist/chunk-LE6SW2M3.mjs.map +1 -0
- package/dist/chunk-MHDQJMLE.mjs +39 -0
- package/dist/chunk-MHDQJMLE.mjs.map +1 -0
- package/dist/configs/recommended.d.mts +109 -0
- package/dist/configs/recommended.d.ts +109 -0
- package/dist/configs/recommended.js +5877 -0
- package/dist/configs/recommended.js.map +1 -0
- package/dist/configs/recommended.mjs +5 -0
- package/dist/configs/recommended.mjs.map +1 -0
- package/dist/configs/typescript.d.mts +103 -0
- package/dist/configs/typescript.d.ts +103 -0
- package/dist/configs/typescript.js +6246 -0
- package/dist/configs/typescript.js.map +1 -0
- package/dist/configs/typescript.mjs +6 -0
- package/dist/configs/typescript.mjs.map +1 -0
- package/dist/configs/v2-strict.d.mts +130 -0
- package/dist/configs/v2-strict.d.ts +130 -0
- package/dist/configs/v2-strict.js +6317 -0
- package/dist/configs/v2-strict.js.map +1 -0
- package/dist/configs/v2-strict.mjs +7 -0
- package/dist/configs/v2-strict.mjs.map +1 -0
- package/dist/configs/v2.d.mts +127 -0
- package/dist/configs/v2.d.ts +127 -0
- package/dist/configs/v2.js +6289 -0
- package/dist/configs/v2.js.map +1 -0
- package/dist/configs/v2.mjs +6 -0
- package/dist/configs/v2.mjs.map +1 -0
- package/dist/index.d.mts +740 -0
- package/dist/index.d.ts +740 -0
- package/dist/index.js +6365 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +42 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +109 -0
- package/src/compat.ts +53 -0
- package/src/configs/recommended.ts +48 -0
- package/src/configs/typescript.ts +21 -0
- package/src/configs/v2-strict.ts +28 -0
- package/src/configs/v2.ts +68 -0
- package/src/deps.d.ts +1 -0
- package/src/index.ts +29 -0
- package/src/plugin.ts +92 -0
- package/src/rules/components-return-once.ts +209 -0
- package/src/rules/event-handlers.ts +397 -0
- package/src/rules/imports.ts +338 -0
- package/src/rules/jsx-no-duplicate-props.ts +110 -0
- package/src/rules/jsx-no-script-url.ts +61 -0
- package/src/rules/jsx-no-undef.ts +230 -0
- package/src/rules/jsx-uses-vars.ts +66 -0
- package/src/rules/no-accessor-as-prop.ts +147 -0
- package/src/rules/no-array-handlers.ts +57 -0
- package/src/rules/no-boolean-enumerated-attribute.ts +209 -0
- package/src/rules/no-browser-globals-in-server-function.ts +108 -0
- package/src/rules/no-destructure.ts +245 -0
- package/src/rules/no-innerhtml.ts +143 -0
- package/src/rules/no-invalid-server-capture.ts +104 -0
- package/src/rules/no-module-scope-reactive-primitive.ts +69 -0
- package/src/rules/no-proxy-apis.ts +96 -0
- package/src/rules/no-react-deps.ts +68 -0
- package/src/rules/no-react-specific-props.ts +60 -0
- package/src/rules/no-reactive-read-in-effect-callback.ts +570 -0
- package/src/rules/no-restated-default-options.ts +96 -0
- package/src/rules/no-single-arg-create-effect.ts +56 -0
- package/src/rules/no-store-mutation-outside-setter.ts +137 -0
- package/src/rules/no-unknown-namespaces.ts +140 -0
- package/src/rules/no-unused-signal.ts +119 -0
- package/src/rules/no-write-in-pure-computation.ts +231 -0
- package/src/rules/prefer-classlist.ts +93 -0
- package/src/rules/prefer-for.ts +93 -0
- package/src/rules/prefer-onSettled-for-side-effects.ts +101 -0
- package/src/rules/prefer-show.ts +102 -0
- package/src/rules/prefer-structured-class.ts +117 -0
- package/src/rules/reactivity.ts +1730 -0
- package/src/rules/removed-api.ts +212 -0
- package/src/rules/require-async-server-function.ts +122 -0
- package/src/rules/self-closing-comp.ts +150 -0
- package/src/rules/style-prop.ts +140 -0
- package/src/rules/valid-use-server.ts +192 -0
- package/src/rules/validate-jsx-nesting.ts +1 -0
- package/src/utils/reactive-imports.ts +382 -0
- package/src/utils/reactive-types.ts +272 -0
- package/src/utils/reactive-values.ts +162 -0
- package/src/utils.ts +442 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_typescript
|
|
3
|
+
} from "./chunk-4UZNJ5MS.mjs";
|
|
4
|
+
import {
|
|
5
|
+
require_v2_strict
|
|
6
|
+
} from "./chunk-MHDQJMLE.mjs";
|
|
7
|
+
import {
|
|
8
|
+
require_v2
|
|
9
|
+
} from "./chunk-EBU4C5NV.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__commonJS,
|
|
12
|
+
__toESM,
|
|
13
|
+
init_plugin,
|
|
14
|
+
plugin,
|
|
15
|
+
require_recommended
|
|
16
|
+
} from "./chunk-LE6SW2M3.mjs";
|
|
17
|
+
|
|
18
|
+
// src/index.ts
|
|
19
|
+
var require_index = __commonJS({
|
|
20
|
+
"src/index.ts"(exports, module) {
|
|
21
|
+
init_plugin();
|
|
22
|
+
var import_recommended = __toESM(require_recommended());
|
|
23
|
+
var import_typescript = __toESM(require_typescript());
|
|
24
|
+
var import_v2 = __toESM(require_v2());
|
|
25
|
+
var import_v2_strict = __toESM(require_v2_strict());
|
|
26
|
+
var pluginWithConfigs = {
|
|
27
|
+
...plugin,
|
|
28
|
+
configs: {
|
|
29
|
+
recommended: import_recommended.default,
|
|
30
|
+
typescript: import_typescript.default,
|
|
31
|
+
v2: import_v2.default,
|
|
32
|
+
"v2-strict": import_v2_strict.default,
|
|
33
|
+
// aliases kept for compatibility with the 0.14.x flat config names
|
|
34
|
+
"flat/recommended": import_recommended.default,
|
|
35
|
+
"flat/typescript": import_typescript.default
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
module.exports = pluginWithConfigs;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
export default require_index();
|
|
42
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * FIXME: remove this comments and import when below issue is fixed.\n * This import is necessary for type generation due to a bug in the TypeScript compiler.\n * See: https://github.com/microsoft/TypeScript/issues/42873\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { TSESLint } from \"@typescript-eslint/utils\";\n\nimport { plugin } from \"./plugin\";\nimport recommendedConfig from \"./configs/recommended\";\nimport typescriptConfig from \"./configs/typescript\";\nimport v2Config from \"./configs/v2\";\nimport v2StrictConfig from \"./configs/v2-strict\";\n\nconst pluginWithConfigs = {\n ...plugin,\n configs: {\n recommended: recommendedConfig,\n typescript: typescriptConfig,\n v2: v2Config,\n \"v2-strict\": v2StrictConfig,\n // aliases kept for compatibility with the 0.14.x flat config names\n \"flat/recommended\": recommendedConfig,\n \"flat/typescript\": typescriptConfig,\n },\n};\n\n// Must be `export = ` for eslint to load everything\nexport = pluginWithConfigs;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAQA;AACA,6BAA8B;AAC9B,4BAA6B;AAC7B,oBAAqB;AACrB,2BAA2B;AAE3B,QAAM,oBAAoB;AAAA,MACxB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,aAAa,mBAAAA;AAAA,QACb,YAAY,kBAAAC;AAAA,QACZ,IAAI,UAAAC;AAAA,QACJ,aAAa,iBAAAC;AAAA;AAAA,QAEb,oBAAoB,mBAAAH;AAAA,QACpB,mBAAmB,kBAAAC;AAAA,MACrB;AAAA,IACF;AAGA,qBAAS;AAAA;AAAA;","names":["recommendedConfig","typescriptConfig","v2Config","v2StrictConfig"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qq99/eslint-plugin-solid",
|
|
3
|
+
"version": "0.18.0-no-reactive-read-in-effect-callback.0",
|
|
4
|
+
"description": "Solid-specific linting rules for ESLint.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eslint",
|
|
7
|
+
"eslintplugin",
|
|
8
|
+
"solid",
|
|
9
|
+
"solidjs",
|
|
10
|
+
"reactivity"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/solidjs-community/eslint-plugin-solid"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "Josh Wilson <joshwilsonvu@gmail.com>",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": {
|
|
21
|
+
"import": "./dist/index.d.mts",
|
|
22
|
+
"require": "./dist/index.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./configs/recommended": {
|
|
28
|
+
"types": {
|
|
29
|
+
"import": "./dist/configs/recommended.d.mts",
|
|
30
|
+
"require": "./dist/configs/recommended.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"import": "./dist/configs/recommended.mjs",
|
|
33
|
+
"require": "./dist/configs/recommended.js"
|
|
34
|
+
},
|
|
35
|
+
"./configs/typescript": {
|
|
36
|
+
"types": {
|
|
37
|
+
"import": "./dist/configs/typescript.d.mts",
|
|
38
|
+
"require": "./dist/configs/typescript.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"import": "./dist/configs/typescript.mjs",
|
|
41
|
+
"require": "./dist/configs/typescript.js"
|
|
42
|
+
},
|
|
43
|
+
"./configs/v2": {
|
|
44
|
+
"types": {
|
|
45
|
+
"import": "./dist/configs/v2.d.mts",
|
|
46
|
+
"require": "./dist/configs/v2.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"import": "./dist/configs/v2.mjs",
|
|
49
|
+
"require": "./dist/configs/v2.js"
|
|
50
|
+
},
|
|
51
|
+
"./configs/v2-strict": {
|
|
52
|
+
"types": {
|
|
53
|
+
"import": "./dist/configs/v2-strict.d.mts",
|
|
54
|
+
"require": "./dist/configs/v2-strict.d.ts"
|
|
55
|
+
},
|
|
56
|
+
"import": "./dist/configs/v2-strict.mjs",
|
|
57
|
+
"require": "./dist/configs/v2-strict.js"
|
|
58
|
+
},
|
|
59
|
+
"./package.json": "./package.json"
|
|
60
|
+
},
|
|
61
|
+
"main": "dist/index.js",
|
|
62
|
+
"types": "dist/index.d.ts",
|
|
63
|
+
"files": [
|
|
64
|
+
"src",
|
|
65
|
+
"dist",
|
|
66
|
+
"README.md"
|
|
67
|
+
],
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@typescript-eslint/utils": "^8.0.0",
|
|
70
|
+
"estraverse": "^5.3.0",
|
|
71
|
+
"is-html": "^2.0.0",
|
|
72
|
+
"kebab-case": "^1.0.2",
|
|
73
|
+
"known-css-properties": "^0.30.0",
|
|
74
|
+
"style-to-object": "^1.0.6"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@babel/core": "^8.0.0",
|
|
78
|
+
"@babel/eslint-parser": "^8.0.1",
|
|
79
|
+
"@microsoft/api-extractor": "^7.47.6",
|
|
80
|
+
"@types/estraverse": "^5.1.7",
|
|
81
|
+
"@types/is-html": "^2.0.2",
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^8.67.0",
|
|
83
|
+
"@typescript-eslint/parser": "^8.67.0",
|
|
84
|
+
"eslint": "^10.0.0",
|
|
85
|
+
"markdown-magic": "^3.3.0",
|
|
86
|
+
"prettier": "^2.8.8",
|
|
87
|
+
"tsup": "^8.5.1",
|
|
88
|
+
"tsx": "^4.17.0",
|
|
89
|
+
"vitest": "^4.0.0"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"eslint": "^9.0.0 || ^10.0.0",
|
|
93
|
+
"typescript": ">=4.8.4"
|
|
94
|
+
},
|
|
95
|
+
"engines": {
|
|
96
|
+
"node": ">=22.0.0"
|
|
97
|
+
},
|
|
98
|
+
"scripts": {
|
|
99
|
+
"build": "tsup",
|
|
100
|
+
"test": "vitest --run",
|
|
101
|
+
"test:all": "PARSER=all vitest --run",
|
|
102
|
+
"test:babel": "PARSER=babel vitest --run",
|
|
103
|
+
"test:ts": "PARSER=ts vitest --run",
|
|
104
|
+
"test:watch": "vitest",
|
|
105
|
+
"turbo:build": "tsup",
|
|
106
|
+
"turbo:docs": "PARSER=none tsx scripts/docs.mts",
|
|
107
|
+
"turbo:test": "vitest --run"
|
|
108
|
+
}
|
|
109
|
+
}
|
package/src/compat.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type TSESLint, type TSESTree, ASTUtils } from "@typescript-eslint/utils";
|
|
2
|
+
|
|
3
|
+
export type CompatContext =
|
|
4
|
+
| {
|
|
5
|
+
sourceCode: Readonly<TSESLint.SourceCode>;
|
|
6
|
+
getSourceCode: undefined;
|
|
7
|
+
getScope: undefined;
|
|
8
|
+
markVariableAsUsed: undefined;
|
|
9
|
+
}
|
|
10
|
+
| {
|
|
11
|
+
sourceCode?: Readonly<TSESLint.SourceCode>;
|
|
12
|
+
getSourceCode: () => Readonly<TSESLint.SourceCode>;
|
|
13
|
+
getScope: () => TSESLint.Scope.Scope;
|
|
14
|
+
markVariableAsUsed: (name: string) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function getSourceCode(context: CompatContext) {
|
|
18
|
+
if (typeof context.getSourceCode === "function") {
|
|
19
|
+
return context.getSourceCode();
|
|
20
|
+
}
|
|
21
|
+
return context.sourceCode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getScope(context: CompatContext, node: TSESTree.Node): TSESLint.Scope.Scope {
|
|
25
|
+
const sourceCode = getSourceCode(context);
|
|
26
|
+
|
|
27
|
+
if (typeof sourceCode.getScope === "function") {
|
|
28
|
+
return sourceCode.getScope(node); // >= v8, I think
|
|
29
|
+
}
|
|
30
|
+
if (typeof context.getScope === "function") {
|
|
31
|
+
return context.getScope();
|
|
32
|
+
}
|
|
33
|
+
return context.sourceCode.getScope(node);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function findVariable(
|
|
37
|
+
context: CompatContext,
|
|
38
|
+
node: TSESTree.Identifier
|
|
39
|
+
): TSESLint.Scope.Variable | null {
|
|
40
|
+
return ASTUtils.findVariable(getScope(context, node), node);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function markVariableAsUsed(
|
|
44
|
+
context: CompatContext,
|
|
45
|
+
name: string,
|
|
46
|
+
node: TSESTree.Node
|
|
47
|
+
): void {
|
|
48
|
+
if (typeof context.markVariableAsUsed === "function") {
|
|
49
|
+
context.markVariableAsUsed(name);
|
|
50
|
+
} else {
|
|
51
|
+
getSourceCode(context).markVariableAsUsed(name, node);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
|
|
3
|
+
import { plugin } from "../plugin";
|
|
4
|
+
|
|
5
|
+
const recommended = {
|
|
6
|
+
plugins: {
|
|
7
|
+
solid: plugin,
|
|
8
|
+
},
|
|
9
|
+
languageOptions: {
|
|
10
|
+
sourceType: "module",
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaFeatures: {
|
|
13
|
+
jsx: true,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
// identifier usage is important
|
|
19
|
+
"solid/jsx-no-duplicate-props": 2,
|
|
20
|
+
"solid/jsx-no-undef": 2,
|
|
21
|
+
"solid/jsx-uses-vars": 2,
|
|
22
|
+
"solid/no-unknown-namespaces": 2,
|
|
23
|
+
// security problems
|
|
24
|
+
"solid/no-innerhtml": 2,
|
|
25
|
+
"solid/jsx-no-script-url": 2,
|
|
26
|
+
// reactivity
|
|
27
|
+
"solid/components-return-once": 1,
|
|
28
|
+
"solid/no-destructure": 2,
|
|
29
|
+
"solid/prefer-for": 2,
|
|
30
|
+
"solid/reactivity": 1,
|
|
31
|
+
"solid/event-handlers": 1,
|
|
32
|
+
// these rules are mostly style suggestions
|
|
33
|
+
"solid/imports": 1,
|
|
34
|
+
"solid/style-prop": 1,
|
|
35
|
+
"solid/no-react-deps": 1,
|
|
36
|
+
"solid/no-react-specific-props": 1,
|
|
37
|
+
"solid/self-closing-comp": 1,
|
|
38
|
+
"solid/no-array-handlers": 0,
|
|
39
|
+
// handled by Solid compiler, opt-in style suggestion
|
|
40
|
+
"solid/prefer-show": 0,
|
|
41
|
+
// only necessary for resource-constrained environments
|
|
42
|
+
"solid/no-proxy-apis": 0,
|
|
43
|
+
// deprecated
|
|
44
|
+
"solid/prefer-classlist": 0,
|
|
45
|
+
},
|
|
46
|
+
} satisfies TSESLint.FlatConfig.Config;
|
|
47
|
+
|
|
48
|
+
export = recommended;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
import type { Linter } from "eslint";
|
|
3
|
+
|
|
4
|
+
import recommended from "./recommended";
|
|
5
|
+
|
|
6
|
+
const typescript = {
|
|
7
|
+
// no files; either apply to all files, or let users spread in this config
|
|
8
|
+
// and specify matching patterns. This is eslint-plugin-react's take.
|
|
9
|
+
plugins: recommended.plugins,
|
|
10
|
+
// no languageOptions; ESLint's default parser can't parse TypeScript,
|
|
11
|
+
// and parsers are configured in languageOptions, so let the user handle
|
|
12
|
+
// this rather than cause potential conflicts
|
|
13
|
+
rules: {
|
|
14
|
+
...recommended.rules,
|
|
15
|
+
"solid/jsx-no-undef": [2, { typescriptEnabled: true }] satisfies Linter.RuleEntry,
|
|
16
|
+
// namespaces taken care of by TS
|
|
17
|
+
"solid/no-unknown-namespaces": 0,
|
|
18
|
+
},
|
|
19
|
+
} satisfies TSESLint.FlatConfig.Config;
|
|
20
|
+
|
|
21
|
+
export = typescript;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
|
|
3
|
+
import v2 from "./v2";
|
|
4
|
+
|
|
5
|
+
// Everything in the v2 config, plus opinionated rules that are valid patterns
|
|
6
|
+
// in some apps (e.g. client-only) but hazards in others. Intended for teams
|
|
7
|
+
// that want the plugin's strongest opinions.
|
|
8
|
+
const v2Strict = {
|
|
9
|
+
plugins: v2.plugins,
|
|
10
|
+
languageOptions: v2.languageOptions,
|
|
11
|
+
settings: v2.settings,
|
|
12
|
+
rules: {
|
|
13
|
+
...v2.rules,
|
|
14
|
+
// module-scope reactive state is shared across SSR requests
|
|
15
|
+
"solid/no-module-scope-reactive-primitive": 2,
|
|
16
|
+
// side-effectful setup in component bodies belongs in onSettled;
|
|
17
|
+
// warn-level because detection is a heuristic over a known-call list
|
|
18
|
+
"solid/prefer-onSettled-for-side-effects": 1,
|
|
19
|
+
// restating default prop/option values is noise
|
|
20
|
+
"solid/no-restated-default-options": 2,
|
|
21
|
+
// graduate the class-string heuristic to an error
|
|
22
|
+
"solid/prefer-structured-class": 2,
|
|
23
|
+
// graduate the half-unused signal check to an error
|
|
24
|
+
"solid/no-unused-signal": 2,
|
|
25
|
+
},
|
|
26
|
+
} satisfies TSESLint.FlatConfig.Config;
|
|
27
|
+
|
|
28
|
+
export = v2Strict;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
|
|
3
|
+
import { plugin } from "../plugin";
|
|
4
|
+
import recommended from "./recommended";
|
|
5
|
+
|
|
6
|
+
// The Solid 2.0 config. Sets `settings.solid.version: 2`, which switches
|
|
7
|
+
// version-aware rules (reactivity, imports, no-unknown-namespaces,
|
|
8
|
+
// event-handlers, jsx-no-undef) into strict 2.0 semantics, and enables the
|
|
9
|
+
// 2.0-specific rules. Errors are reserved for near-certain bugs; heuristics
|
|
10
|
+
// stay warnings. This is the config the official templates ship.
|
|
11
|
+
const v2 = {
|
|
12
|
+
plugins: {
|
|
13
|
+
solid: plugin,
|
|
14
|
+
},
|
|
15
|
+
languageOptions: {
|
|
16
|
+
sourceType: "module",
|
|
17
|
+
parserOptions: {
|
|
18
|
+
ecmaFeatures: {
|
|
19
|
+
jsx: true,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
settings: {
|
|
24
|
+
solid: { version: 2 },
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
...recommended.rules,
|
|
28
|
+
// 1.x APIs that no longer exist; prescriptive migration guidance
|
|
29
|
+
"solid/removed-api": 2,
|
|
30
|
+
// 2.0 requires the split createEffect(compute, effect) form
|
|
31
|
+
"solid/no-single-arg-create-effect": 2,
|
|
32
|
+
// the store read proxy is read-only; mutations go through the setter's draft
|
|
33
|
+
"solid/no-store-mutation-outside-setter": 2,
|
|
34
|
+
// writes inside memos/compute halves create cycles and throw in 2.0 dev
|
|
35
|
+
"solid/no-write-in-pure-computation": 2,
|
|
36
|
+
// the apply half receives a value outside tracking; reads must happen in compute
|
|
37
|
+
"solid/no-reactive-read-in-effect-callback": 2,
|
|
38
|
+
// signals that are never written (or never read) aren't being used as signals
|
|
39
|
+
"solid/no-unused-signal": 1,
|
|
40
|
+
// uncalled accessors as DOM attributes render stringified functions
|
|
41
|
+
"solid/no-accessor-as-prop": 2,
|
|
42
|
+
// enumerated attributes (draggable, tristate aria-*) want string tokens;
|
|
43
|
+
// boolean false removes the attribute, a different state than "false"
|
|
44
|
+
"solid/no-boolean-enumerated-attribute": 2,
|
|
45
|
+
// manual class-string building works but defeats granular class toggling
|
|
46
|
+
"solid/prefer-structured-class": 1,
|
|
47
|
+
// graduated from style to correctness in 2.0: only camelCase `onClick` is
|
|
48
|
+
// an event handler; lowercase forms are literal attributes
|
|
49
|
+
"solid/event-handlers": 2,
|
|
50
|
+
// className/htmlFor pass through as literal attributes the DOM ignores
|
|
51
|
+
"solid/no-react-specific-props": 2,
|
|
52
|
+
// server functions are core in 2.0; misplaced/ignored "use server"
|
|
53
|
+
// directives and broken module-level directive files are silent failures
|
|
54
|
+
"solid/valid-use-server": 2,
|
|
55
|
+
// a sync server function returns T during SSR but Promise<T> on the client
|
|
56
|
+
"solid/require-async-server-function": 2,
|
|
57
|
+
// editor-time mirror of the compiler's closure-capture validation
|
|
58
|
+
"solid/no-invalid-server-capture": 2,
|
|
59
|
+
// server functions never run where browser globals exist
|
|
60
|
+
"solid/no-browser-globals-in-server-function": 2,
|
|
61
|
+
// premise no longer exists in 2.0 (rule also self-gates on version)
|
|
62
|
+
"solid/no-react-deps": 0,
|
|
63
|
+
// anti-advice in 2.0: classList was removed in favor of class objects/arrays
|
|
64
|
+
"solid/prefer-classlist": 0,
|
|
65
|
+
},
|
|
66
|
+
} satisfies TSESLint.FlatConfig.Config;
|
|
67
|
+
|
|
68
|
+
export = v2;
|
package/src/deps.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "kebab-case";
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FIXME: remove this comments and import when below issue is fixed.
|
|
3
|
+
* This import is necessary for type generation due to a bug in the TypeScript compiler.
|
|
4
|
+
* See: https://github.com/microsoft/TypeScript/issues/42873
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
8
|
+
|
|
9
|
+
import { plugin } from "./plugin";
|
|
10
|
+
import recommendedConfig from "./configs/recommended";
|
|
11
|
+
import typescriptConfig from "./configs/typescript";
|
|
12
|
+
import v2Config from "./configs/v2";
|
|
13
|
+
import v2StrictConfig from "./configs/v2-strict";
|
|
14
|
+
|
|
15
|
+
const pluginWithConfigs = {
|
|
16
|
+
...plugin,
|
|
17
|
+
configs: {
|
|
18
|
+
recommended: recommendedConfig,
|
|
19
|
+
typescript: typescriptConfig,
|
|
20
|
+
v2: v2Config,
|
|
21
|
+
"v2-strict": v2StrictConfig,
|
|
22
|
+
// aliases kept for compatibility with the 0.14.x flat config names
|
|
23
|
+
"flat/recommended": recommendedConfig,
|
|
24
|
+
"flat/typescript": typescriptConfig,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Must be `export = ` for eslint to load everything
|
|
29
|
+
export = pluginWithConfigs;
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FIXME: remove this comments and import when below issue is fixed.
|
|
3
|
+
* This import is necessary for type generation due to a bug in the TypeScript compiler.
|
|
4
|
+
* See: https://github.com/microsoft/TypeScript/issues/42873
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
8
|
+
|
|
9
|
+
import componentsReturnOnce from "./rules/components-return-once";
|
|
10
|
+
import eventHandlers from "./rules/event-handlers";
|
|
11
|
+
import imports from "./rules/imports";
|
|
12
|
+
import jsxNoDuplicateProps from "./rules/jsx-no-duplicate-props";
|
|
13
|
+
import jsxNoScriptUrl from "./rules/jsx-no-script-url";
|
|
14
|
+
import jsxNoUndef from "./rules/jsx-no-undef";
|
|
15
|
+
import jsxUsesVars from "./rules/jsx-uses-vars";
|
|
16
|
+
import noAccessorAsProp from "./rules/no-accessor-as-prop";
|
|
17
|
+
import noBooleanEnumeratedAttribute from "./rules/no-boolean-enumerated-attribute";
|
|
18
|
+
import noBrowserGlobalsInServerFunction from "./rules/no-browser-globals-in-server-function";
|
|
19
|
+
import noDestructure from "./rules/no-destructure";
|
|
20
|
+
import noInnerHTML from "./rules/no-innerhtml";
|
|
21
|
+
import noInvalidServerCapture from "./rules/no-invalid-server-capture";
|
|
22
|
+
import noModuleScopeReactivePrimitive from "./rules/no-module-scope-reactive-primitive";
|
|
23
|
+
import noProxyApis from "./rules/no-proxy-apis";
|
|
24
|
+
import noReactDeps from "./rules/no-react-deps";
|
|
25
|
+
import noReactSpecificProps from "./rules/no-react-specific-props";
|
|
26
|
+
import noReactiveReadInEffectCallback from "./rules/no-reactive-read-in-effect-callback";
|
|
27
|
+
import noRestatedDefaultOptions from "./rules/no-restated-default-options";
|
|
28
|
+
import noSingleArgCreateEffect from "./rules/no-single-arg-create-effect";
|
|
29
|
+
import noStoreMutationOutsideSetter from "./rules/no-store-mutation-outside-setter";
|
|
30
|
+
import noUnknownNamespaces from "./rules/no-unknown-namespaces";
|
|
31
|
+
import noUnusedSignal from "./rules/no-unused-signal";
|
|
32
|
+
import noWriteInPureComputation from "./rules/no-write-in-pure-computation";
|
|
33
|
+
import preferClasslist from "./rules/prefer-classlist";
|
|
34
|
+
import preferFor from "./rules/prefer-for";
|
|
35
|
+
import preferOnSettledForSideEffects from "./rules/prefer-onSettled-for-side-effects";
|
|
36
|
+
import preferShow from "./rules/prefer-show";
|
|
37
|
+
import preferStructuredClass from "./rules/prefer-structured-class";
|
|
38
|
+
import reactivity from "./rules/reactivity";
|
|
39
|
+
import removedApi from "./rules/removed-api";
|
|
40
|
+
import requireAsyncServerFunction from "./rules/require-async-server-function";
|
|
41
|
+
import selfClosingComp from "./rules/self-closing-comp";
|
|
42
|
+
import styleProp from "./rules/style-prop";
|
|
43
|
+
import validUseServer from "./rules/valid-use-server";
|
|
44
|
+
import noArrayHandlers from "./rules/no-array-handlers";
|
|
45
|
+
// import validateJsxNesting from "./rules/validate-jsx-nesting";
|
|
46
|
+
|
|
47
|
+
// Use require() so that `package.json` doesn't get copied to `dist`
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
49
|
+
const { name, version } = require("../package.json");
|
|
50
|
+
const meta = { name, version };
|
|
51
|
+
|
|
52
|
+
const allRules = {
|
|
53
|
+
"components-return-once": componentsReturnOnce,
|
|
54
|
+
"event-handlers": eventHandlers,
|
|
55
|
+
imports,
|
|
56
|
+
"jsx-no-duplicate-props": jsxNoDuplicateProps,
|
|
57
|
+
"jsx-no-undef": jsxNoUndef,
|
|
58
|
+
"jsx-no-script-url": jsxNoScriptUrl,
|
|
59
|
+
"jsx-uses-vars": jsxUsesVars,
|
|
60
|
+
"no-accessor-as-prop": noAccessorAsProp,
|
|
61
|
+
"no-boolean-enumerated-attribute": noBooleanEnumeratedAttribute,
|
|
62
|
+
"no-browser-globals-in-server-function": noBrowserGlobalsInServerFunction,
|
|
63
|
+
"no-destructure": noDestructure,
|
|
64
|
+
"no-innerhtml": noInnerHTML,
|
|
65
|
+
"no-invalid-server-capture": noInvalidServerCapture,
|
|
66
|
+
"no-module-scope-reactive-primitive": noModuleScopeReactivePrimitive,
|
|
67
|
+
"no-proxy-apis": noProxyApis,
|
|
68
|
+
"no-react-deps": noReactDeps,
|
|
69
|
+
"no-react-specific-props": noReactSpecificProps,
|
|
70
|
+
"no-reactive-read-in-effect-callback": noReactiveReadInEffectCallback,
|
|
71
|
+
"no-restated-default-options": noRestatedDefaultOptions,
|
|
72
|
+
"no-single-arg-create-effect": noSingleArgCreateEffect,
|
|
73
|
+
"no-store-mutation-outside-setter": noStoreMutationOutsideSetter,
|
|
74
|
+
"no-unknown-namespaces": noUnknownNamespaces,
|
|
75
|
+
"no-unused-signal": noUnusedSignal,
|
|
76
|
+
"no-write-in-pure-computation": noWriteInPureComputation,
|
|
77
|
+
"prefer-classlist": preferClasslist,
|
|
78
|
+
"prefer-for": preferFor,
|
|
79
|
+
"prefer-onSettled-for-side-effects": preferOnSettledForSideEffects,
|
|
80
|
+
"prefer-show": preferShow,
|
|
81
|
+
"prefer-structured-class": preferStructuredClass,
|
|
82
|
+
reactivity,
|
|
83
|
+
"removed-api": removedApi,
|
|
84
|
+
"require-async-server-function": requireAsyncServerFunction,
|
|
85
|
+
"self-closing-comp": selfClosingComp,
|
|
86
|
+
"style-prop": styleProp,
|
|
87
|
+
"valid-use-server": validUseServer,
|
|
88
|
+
"no-array-handlers": noArrayHandlers,
|
|
89
|
+
// "validate-jsx-nesting": validateJsxNesting
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const plugin = { meta, rules: allRules };
|