Skip to content

Commit 1e09a7b

Browse files
committed
feat: move to stylistic/ts for type-annotation-spacing rule
1 parent e83d478 commit 1e09a7b

File tree

4 files changed

+119
-92
lines changed

4 files changed

+119
-92
lines changed

flat.js

Lines changed: 85 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,100 +4,98 @@ const reactPlugin = require("eslint-plugin-react");
44
const tsPlugin = require("@typescript-eslint/eslint-plugin");
55
const typescriptParser = require("@typescript-eslint/parser");
66
const prettierConfig = require("eslint-config-prettier");
7+
const stylisticTs = require("@stylistic/eslint-plugin-ts");
78

89
/**
910
* @type {Array<import('eslint').Linter.Config>}
1011
*/
11-
module.exports = [
12-
{
13-
...reactHooksPlugin.configs.recommended,
14-
...reactPlugin.configs.flat.recommended,
15-
...prettierConfig,
16-
settings: {
17-
react: {
18-
version: "detect",
19-
},
20-
},
21-
plugins: {
22-
jsdoc,
23-
"@typescript-eslint": tsPlugin,
24-
"react-hooks": reactHooksPlugin,
12+
module.exports = {
13+
name: "@grafana/eslint-config/flat",
14+
...reactHooksPlugin.configs.recommended,
15+
...reactPlugin.configs.flat.recommended,
16+
...prettierConfig,
17+
settings: {
18+
react: {
19+
version: "detect",
2520
},
26-
languageOptions: {
27-
parser: typescriptParser,
28-
ecmaVersion: 2019,
29-
sourceType: "module",
30-
parserOptions: {
31-
ecmaFeatures: {
32-
jsx: true,
33-
},
21+
},
22+
plugins: {
23+
jsdoc,
24+
"@typescript-eslint": tsPlugin,
25+
"react-hooks": reactHooksPlugin,
26+
"@stylistic/ts": stylisticTs,
27+
},
28+
languageOptions: {
29+
parser: typescriptParser,
30+
ecmaVersion: 2019,
31+
sourceType: "module",
32+
parserOptions: {
33+
ecmaFeatures: {
34+
jsx: true,
3435
},
3536
},
36-
rules: {
37-
curly: "error",
38-
"dot-notation": "off",
39-
"eol-last": "error",
40-
eqeqeq: ["error", "always", { null: "ignore" }],
41-
"guard-for-in": "off",
42-
"jsdoc/check-alignment": "error",
43-
"new-parens": "error",
44-
"no-array-constructor": "error",
45-
"no-bitwise": "off",
46-
"no-caller": "error",
47-
"no-cond-assign": "error",
48-
"no-console": ["error", { allow: ["error", "log", "warn", "info"] }],
49-
"no-debugger": "error",
50-
"no-empty": "off",
51-
"no-eval": "error",
52-
"no-fallthrough": "off",
53-
"no-new-wrappers": "error",
54-
"no-redeclare": "error",
55-
"no-restricted-imports": ["error", "moment"],
56-
"no-shadow": "off",
57-
"no-unused-expressions": "off",
58-
"no-unused-labels": "error",
59-
"no-var": "error",
60-
radix: "error",
61-
"sort-keys": "off",
62-
"spaced-comment": ["off", "always"],
63-
"use-isnan": "error",
64-
"no-duplicate-imports": "error",
65-
"@typescript-eslint/no-unused-expressions": [
66-
"error",
67-
{ allowShortCircuit: true, allowTernary: true },
68-
],
69-
"@typescript-eslint/array-type": ["error", { default: "array-simple" }],
70-
"@typescript-eslint/naming-convention": [
71-
"error",
72-
{
73-
selector: "interface",
74-
format: ["PascalCase"],
75-
custom: {
76-
regex: "^I[A-Z]",
77-
match: false,
78-
},
37+
},
38+
rules: {
39+
curly: "error",
40+
"dot-notation": "off",
41+
"eol-last": "error",
42+
eqeqeq: ["error", "always", { null: "ignore" }],
43+
"guard-for-in": "off",
44+
"jsdoc/check-alignment": "error",
45+
"new-parens": "error",
46+
"no-array-constructor": "error",
47+
"no-bitwise": "off",
48+
"no-caller": "error",
49+
"no-cond-assign": "error",
50+
"no-console": ["error", { allow: ["error", "log", "warn", "info"] }],
51+
"no-debugger": "error",
52+
"no-empty": "off",
53+
"no-eval": "error",
54+
"no-fallthrough": "off",
55+
"no-new-wrappers": "error",
56+
"no-redeclare": "error",
57+
"no-restricted-imports": ["error", "moment"],
58+
"no-shadow": "off",
59+
"no-unused-expressions": "off",
60+
"no-unused-labels": "error",
61+
"no-var": "error",
62+
radix: "error",
63+
"sort-keys": "off",
64+
"spaced-comment": ["off", "always"],
65+
"use-isnan": "error",
66+
"no-duplicate-imports": "error",
67+
"@typescript-eslint/no-unused-expressions": [
68+
"error",
69+
{ allowShortCircuit: true, allowTernary: true },
70+
],
71+
"@typescript-eslint/array-type": ["error", { default: "array-simple" }],
72+
"@typescript-eslint/naming-convention": [
73+
"error",
74+
{
75+
selector: "interface",
76+
format: ["PascalCase"],
77+
custom: {
78+
regex: "^I[A-Z]",
79+
match: false,
7980
},
80-
],
81-
"@typescript-eslint/consistent-type-assertions": "error",
82-
"@typescript-eslint/no-inferrable-types": "error",
83-
"@typescript-eslint/no-namespace": [
84-
"error",
85-
{ allowDeclarations: false },
86-
],
87-
"@typescript-eslint/no-unused-vars": "off",
88-
"@typescript-eslint/no-use-before-define": "off",
89-
"@typescript-eslint/triple-slash-reference": "error",
90-
"@typescript-eslint/type-annotation-spacing": [
91-
"error",
92-
{
93-
after: true,
94-
before: false,
95-
overrides: {
96-
arrow: { after: true, before: true },
97-
},
81+
},
82+
],
83+
"@typescript-eslint/consistent-type-assertions": "error",
84+
"@typescript-eslint/no-inferrable-types": "error",
85+
"@typescript-eslint/no-namespace": ["error", { allowDeclarations: false }],
86+
"@typescript-eslint/no-unused-vars": "off",
87+
"@typescript-eslint/no-use-before-define": "off",
88+
"@typescript-eslint/triple-slash-reference": "error",
89+
"@stylistic/ts/type-annotation-spacing": [
90+
"error",
91+
{
92+
after: true,
93+
before: false,
94+
overrides: {
95+
arrow: { after: true, before: true },
9896
},
99-
],
100-
"react-hooks/exhaustive-deps": "error",
101-
},
97+
},
98+
],
99+
"react-hooks/exhaustive-deps": "error",
102100
},
103-
];
101+
};

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
version: "detect",
1212
},
1313
},
14-
plugins: ["jsdoc", "@typescript-eslint", "react-hooks"],
14+
plugins: ["jsdoc", "@typescript-eslint", "@stylistic/ts", "react-hooks"],
1515
extends: [
1616
"plugin:react-hooks/recommended",
1717
"plugin:react/recommended",
@@ -69,7 +69,7 @@ module.exports = {
6969
"@typescript-eslint/no-unused-vars": "off",
7070
"@typescript-eslint/no-use-before-define": "off",
7171
"@typescript-eslint/triple-slash-reference": "error",
72-
"@typescript-eslint/type-annotation-spacing": [
72+
"@stylistic/ts/type-annotation-spacing": [
7373
"error",
7474
{
7575
after: true,

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"flat.js"
2424
],
2525
"devDependencies": {
26+
"@stylistic/eslint-plugin-ts": "^2.9.0",
27+
"@types/eslint": "^9.0.0",
2628
"@typescript-eslint/eslint-plugin": "^8.9.0",
2729
"@typescript-eslint/parser": "^8.9.0",
2830
"eslint": "^9.0.0",
@@ -33,6 +35,7 @@
3335
"typescript": "^5.5.0"
3436
},
3537
"peerDependencies": {
38+
"@stylistic/eslint-plugin-ts": ">=2.9.0",
3639
"@typescript-eslint/eslint-plugin": ">=6.18.0",
3740
"@typescript-eslint/parser": ">=6.18.0",
3841
"eslint": ">=8.0.0",

yarn.lock

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ __metadata:
9696
version: 0.0.0-use.local
9797
resolution: "@grafana/eslint-config@workspace:."
9898
dependencies:
99+
"@stylistic/eslint-plugin-ts": "npm:^2.9.0"
100+
"@types/eslint": "npm:^9.0.0"
99101
"@typescript-eslint/eslint-plugin": "npm:^8.9.0"
100102
"@typescript-eslint/parser": "npm:^8.9.0"
101103
eslint: "npm:^9.0.0"
@@ -105,6 +107,7 @@ __metadata:
105107
eslint-plugin-react-hooks: "npm:^5.0.0"
106108
typescript: "npm:^5.5.0"
107109
peerDependencies:
110+
"@stylistic/eslint-plugin-ts": ^2.9.0
108111
"@typescript-eslint/eslint-plugin": ">=6.18.0"
109112
"@typescript-eslint/parser": ">=6.18.0"
110113
eslint: ">=8.0.0"
@@ -181,14 +184,37 @@ __metadata:
181184
languageName: node
182185
linkType: hard
183186

184-
"@types/estree@npm:^1.0.6":
187+
"@stylistic/eslint-plugin-ts@npm:^2.9.0":
188+
version: 2.9.0
189+
resolution: "@stylistic/eslint-plugin-ts@npm:2.9.0"
190+
dependencies:
191+
"@typescript-eslint/utils": "npm:^8.8.0"
192+
eslint-visitor-keys: "npm:^4.1.0"
193+
espree: "npm:^10.2.0"
194+
peerDependencies:
195+
eslint: ">=8.40.0"
196+
checksum: 10c0/c76ba9ee5069cb07af3661ede7b283cb5dd0c07d47fba82e329a97f0cf4d886fedc4e22acee9b8295cf278cdf39992484dfce8e0ff4bc1ea8c0b7cbbaaf08b12
197+
languageName: node
198+
linkType: hard
199+
200+
"@types/eslint@npm:^9.0.0":
201+
version: 9.6.1
202+
resolution: "@types/eslint@npm:9.6.1"
203+
dependencies:
204+
"@types/estree": "npm:*"
205+
"@types/json-schema": "npm:*"
206+
checksum: 10c0/69ba24fee600d1e4c5abe0df086c1a4d798abf13792d8cfab912d76817fe1a894359a1518557d21237fbaf6eda93c5ab9309143dee4c59ef54336d1b3570420e
207+
languageName: node
208+
linkType: hard
209+
210+
"@types/estree@npm:*, @types/estree@npm:^1.0.6":
185211
version: 1.0.6
186212
resolution: "@types/estree@npm:1.0.6"
187213
checksum: 10c0/cdfd751f6f9065442cd40957c07fd80361c962869aa853c1c2fd03e101af8b9389d8ff4955a43a6fcfa223dd387a089937f95be0f3eec21ca527039fd2d9859a
188214
languageName: node
189215
linkType: hard
190216

191-
"@types/json-schema@npm:^7.0.15":
217+
"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.15":
192218
version: 7.0.15
193219
resolution: "@types/json-schema@npm:7.0.15"
194220
checksum: 10c0/a996a745e6c5d60292f36731dd41341339d4eeed8180bb09226e5c8d23759067692b1d88e5d91d72ee83dfc00d3aca8e7bd43ea120516c17922cbcb7c3e252db
@@ -287,7 +313,7 @@ __metadata:
287313
languageName: node
288314
linkType: hard
289315

290-
"@typescript-eslint/utils@npm:8.9.0":
316+
"@typescript-eslint/utils@npm:8.9.0, @typescript-eslint/utils@npm:^8.8.0":
291317
version: 8.9.0
292318
resolution: "@typescript-eslint/utils@npm:8.9.0"
293319
dependencies:

0 commit comments

Comments
 (0)