Skip to content

Commit 4b71921

Browse files
authored
Update eslint defineConfig args (#1320)
1 parent d109d4d commit 4b71921

File tree

19 files changed

+151
-158
lines changed

19 files changed

+151
-158
lines changed

.pkgs/configs/eslint.js

Lines changed: 113 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -88,130 +88,124 @@ const p11tGroups = {
8888
},
8989
groups: ["id", "type", "meta", "alias", "rules", "unknown"],
9090
};
91-
export const strictTypeChecked = defineConfig([
92-
{
93-
ignores: GLOB_JS,
94-
},
95-
{
96-
extends: [
97-
js.configs.recommended,
98-
...tseslint.configs.strict,
91+
export const strictTypeChecked = defineConfig({
92+
ignores: GLOB_JS,
93+
}, {
94+
extends: [
95+
js.configs.recommended,
96+
...tseslint.configs.strict,
97+
],
98+
files: GLOB_TS,
99+
rules: {
100+
eqeqeq: ["error", "smart"],
101+
"no-console": "error",
102+
"no-else-return": "error",
103+
"no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }],
104+
"no-implicit-coercion": ["error", { allow: ["!!"] }],
105+
"prefer-object-has-own": "error",
106+
"no-restricted-syntax": [
107+
"error",
108+
{
109+
message: "no typescript named import",
110+
selector: "ImportDeclaration[source.value='typescript'] ImportSpecifier",
111+
},
99112
],
100-
files: GLOB_TS,
101-
rules: {
102-
eqeqeq: ["error", "smart"],
103-
"no-console": "error",
104-
"no-else-return": "error",
105-
"no-fallthrough": ["error", { commentPattern: ".*intentional fallthrough.*" }],
106-
"no-implicit-coercion": ["error", { allow: ["!!"] }],
107-
"prefer-object-has-own": "error",
108-
"no-restricted-syntax": [
109-
"error",
110-
{
111-
message: "no typescript named import",
112-
selector: "ImportDeclaration[source.value='typescript'] ImportSpecifier",
113-
},
114-
],
115-
"@typescript-eslint/ban-ts-comment": [
116-
"error",
117-
{
118-
"ts-check": false,
119-
"ts-expect-error": "allow-with-description",
120-
"ts-ignore": true,
121-
"ts-nocheck": true,
122-
},
123-
],
124-
"@typescript-eslint/ban-types": "off",
125-
"@typescript-eslint/consistent-type-exports": "error",
126-
"@typescript-eslint/consistent-type-imports": "error",
127-
"@typescript-eslint/explicit-function-return-type": "off",
128-
"@typescript-eslint/no-confusing-void-expression": "off",
129-
"@typescript-eslint/no-empty-object-type": "off",
130-
"@typescript-eslint/no-misused-promises": "warn",
131-
"@typescript-eslint/no-namespace": "off",
132-
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
133-
"@typescript-eslint/no-unused-vars": ["warn", { caughtErrors: "all" }],
134-
"@typescript-eslint/strict-boolean-expressions": ["error", {
135-
allowAny: false,
136-
allowNullableBoolean: false,
137-
allowNullableEnum: false,
138-
allowNullableNumber: false,
139-
allowNullableObject: false,
140-
allowNullableString: false,
141-
allowNumber: true,
142-
allowString: false,
143-
}],
144-
},
145-
},
146-
{
147-
extends: [
148-
jsdoc({ config: "flat/recommended-typescript-error" }),
149-
pluginDeMorgan.configs.recommended,
150-
pluginPerfectionist.configs["recommended-natural"],
151-
pluginRegexp.configs["flat/recommended"],
113+
"@typescript-eslint/ban-ts-comment": [
114+
"error",
115+
{
116+
"ts-check": false,
117+
"ts-expect-error": "allow-with-description",
118+
"ts-ignore": true,
119+
"ts-nocheck": true,
120+
},
152121
],
153-
files: GLOB_TS,
154-
plugins: {
155-
["@stylistic"]: stylistic,
156-
["function"]: pluginFunction,
157-
["unicorn"]: pluginUnicorn,
158-
},
159-
rules: {
160-
"function/function-return-boolean": ["error", { pattern: "/^(is|has|can|should)/" }],
161-
"@stylistic/arrow-parens": ["warn", "always"],
162-
"@stylistic/no-multi-spaces": ["warn"],
163-
"@stylistic/operator-linebreak": "off",
164-
"@stylistic/quote-props": ["error", "as-needed"],
165-
"perfectionist/sort-exports": "off",
166-
"perfectionist/sort-imports": "off",
167-
"perfectionist/sort-interfaces": [
168-
"warn",
169-
{ ...p11tOptions, ...p11tGroups },
170-
],
171-
"perfectionist/sort-intersection-types": "off",
172-
"perfectionist/sort-modules": "off",
173-
"perfectionist/sort-named-exports": "off",
174-
"perfectionist/sort-named-imports": "off",
175-
"perfectionist/sort-object-types": [
176-
"warn",
177-
{ ...p11tOptions, ...p11tGroups },
178-
],
179-
"perfectionist/sort-objects": [
180-
"warn",
181-
{ ...p11tOptions, ...p11tGroups },
182-
],
183-
"perfectionist/sort-switch-case": "off",
184-
"perfectionist/sort-union-types": "off",
185-
"jsdoc/check-param-names": "warn",
186-
"jsdoc/check-tag-names": "warn",
187-
"jsdoc/informative-docs": "off",
188-
"jsdoc/lines-before-block": "off",
189-
"jsdoc/require-jsdoc": "off",
190-
"jsdoc/require-param": "warn",
191-
"jsdoc/require-param-description": "warn",
192-
"jsdoc/require-returns": "off",
193-
"jsdoc/require-yields": "warn",
194-
"jsdoc/tag-lines": "off",
195-
"unicorn/template-indent": [
196-
"warn",
197-
{
198-
comments: templateIndentTags,
199-
tags: templateIndentTags,
200-
},
201-
],
202-
},
122+
"@typescript-eslint/ban-types": "off",
123+
"@typescript-eslint/consistent-type-exports": "error",
124+
"@typescript-eslint/consistent-type-imports": "error",
125+
"@typescript-eslint/explicit-function-return-type": "off",
126+
"@typescript-eslint/no-confusing-void-expression": "off",
127+
"@typescript-eslint/no-empty-object-type": "off",
128+
"@typescript-eslint/no-misused-promises": "warn",
129+
"@typescript-eslint/no-namespace": "off",
130+
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
131+
"@typescript-eslint/no-unused-vars": ["warn", { caughtErrors: "all" }],
132+
"@typescript-eslint/strict-boolean-expressions": ["error", {
133+
allowAny: false,
134+
allowNullableBoolean: false,
135+
allowNullableEnum: false,
136+
allowNullableNumber: false,
137+
allowNullableObject: false,
138+
allowNullableString: false,
139+
allowNumber: true,
140+
allowString: false,
141+
}],
203142
},
204-
]);
205-
export const disableTypeChecked = defineConfig([
206-
{
207-
extends: [
208-
tseslint.configs.disableTypeChecked,
143+
}, {
144+
extends: [
145+
jsdoc({ config: "flat/recommended-typescript-error" }),
146+
pluginDeMorgan.configs.recommended,
147+
pluginPerfectionist.configs["recommended-natural"],
148+
pluginRegexp.configs["flat/recommended"],
149+
],
150+
files: GLOB_TS,
151+
plugins: {
152+
["@stylistic"]: stylistic,
153+
["function"]: pluginFunction,
154+
["unicorn"]: pluginUnicorn,
155+
},
156+
rules: {
157+
"function/function-return-boolean": ["error", { pattern: "/^(is|has|can|should)/" }],
158+
"@stylistic/arrow-parens": ["warn", "always"],
159+
"@stylistic/no-multi-spaces": ["warn"],
160+
"@stylistic/operator-linebreak": "off",
161+
"@stylistic/quote-props": ["error", "as-needed"],
162+
"perfectionist/sort-exports": "off",
163+
"perfectionist/sort-imports": "off",
164+
"perfectionist/sort-interfaces": [
165+
"warn",
166+
{ ...p11tOptions, ...p11tGroups },
209167
],
210-
rules: {
211-
"function/function-return-boolean": "off",
212-
},
168+
"perfectionist/sort-intersection-types": "off",
169+
"perfectionist/sort-modules": "off",
170+
"perfectionist/sort-named-exports": "off",
171+
"perfectionist/sort-named-imports": "off",
172+
"perfectionist/sort-object-types": [
173+
"warn",
174+
{ ...p11tOptions, ...p11tGroups },
175+
],
176+
"perfectionist/sort-objects": [
177+
"warn",
178+
{ ...p11tOptions, ...p11tGroups },
179+
],
180+
"perfectionist/sort-switch-case": "off",
181+
"perfectionist/sort-union-types": "off",
182+
"jsdoc/check-param-names": "warn",
183+
"jsdoc/check-tag-names": "warn",
184+
"jsdoc/informative-docs": "off",
185+
"jsdoc/lines-before-block": "off",
186+
"jsdoc/require-jsdoc": "off",
187+
"jsdoc/require-param": "warn",
188+
"jsdoc/require-param-description": "warn",
189+
"jsdoc/require-returns": "off",
190+
"jsdoc/require-yields": "warn",
191+
"jsdoc/tag-lines": "off",
192+
"unicorn/template-indent": [
193+
"warn",
194+
{
195+
comments: templateIndentTags,
196+
tags: templateIndentTags,
197+
},
198+
],
199+
},
200+
});
201+
export const disableTypeChecked = defineConfig({
202+
extends: [
203+
tseslint.configs.disableTypeChecked,
204+
],
205+
rules: {
206+
"function/function-return-boolean": "off",
213207
},
214-
]);
208+
});
215209
/**
216210
* Common ESLint JS rules to disable that are problematic when using TypeScript.
217211
*/

.pkgs/configs/eslint.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const p11tGroups = {
9898
groups: ["id", "type", "meta", "alias", "rules", "unknown"],
9999
};
100100

101-
export const strictTypeChecked: Linter.Config[] = defineConfig([
101+
export const strictTypeChecked: Linter.Config[] = defineConfig(
102102
{
103103
ignores: GLOB_JS,
104104
},
@@ -217,9 +217,9 @@ export const strictTypeChecked: Linter.Config[] = defineConfig([
217217
],
218218
},
219219
},
220-
]);
220+
);
221221

222-
export const disableTypeChecked: Linter.Config[] = defineConfig([
222+
export const disableTypeChecked: Linter.Config[] = defineConfig(
223223
{
224224
extends: [
225225
tseslint.configs.disableTypeChecked,
@@ -228,7 +228,7 @@ export const disableTypeChecked: Linter.Config[] = defineConfig([
228228
"function/function-return-boolean": "off",
229229
},
230230
},
231-
]);
231+
);
232232

233233
/**
234234
* Common ESLint JS rules to disable that are problematic when using TypeScript.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import eslintJs from "@eslint/js";
8181
import { defineConfig } from "eslint/config";
8282
import tseslint from "typescript-eslint";
8383

84-
export default defineConfig([
84+
export default defineConfig(
8585
{
8686
files: ["**/*.ts", "**/*.tsx"],
8787

@@ -111,7 +111,7 @@ export default defineConfig([
111111
"@eslint-react/no-missing-key": "warn",
112112
},
113113
},
114-
]);
114+
);
115115
```
116116

117117
[Full Installation Guide ↗](https://eslint-react.xyz/docs/getting-started/typescript)

apps/website/content/docs/getting-started/javascript.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
2929
import eslintReact from "@eslint-react/eslint-plugin";
3030
import { defineConfig } from "eslint/config";
3131

32-
export default defineConfig([
32+
export default defineConfig(
3333
{
3434
files: ["**/*.js", "**/*.jsx"],
3535

@@ -56,7 +56,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
5656
"@eslint-react/no-missing-key": "warn",
5757
},
5858
},
59-
]);
59+
);
6060
```
6161
</Step>
6262

apps/website/content/docs/getting-started/typescript.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
2929
import { defineConfig } from "eslint/config";
3030
import tseslint from "typescript-eslint";
3131

32-
export default defineConfig([
32+
export default defineConfig(
3333
{
3434
files: ["**/*.ts", "**/*.tsx"],
3535

@@ -59,7 +59,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";
5959
"@eslint-react/no-missing-key": "warn",
6060
},
6161
},
62-
]);
62+
);
6363
```
6464
</Step>
6565

apps/website/eslint.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ const GLOB_IGNORES = [
2525
const dirname = fileURLToPath(new URL(".", import.meta.url));
2626
const gitignore = fileURLToPath(new URL(".gitignore", import.meta.url));
2727

28-
export default defineConfig([
29-
// @ts-expect-error - types issue
28+
export default defineConfig(
3029
includeIgnoreFile(gitignore, "Imported .gitignore patterns"),
3130
globalIgnores(GLOB_IGNORES),
3231
{
@@ -89,4 +88,4 @@ export default defineConfig([
8988
"no-undef": "off",
9089
},
9190
},
92-
]);
91+
);

eslint.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import tseslint from "typescript-eslint";
2121
const dirname = fileURLToPath(new URL(".", import.meta.url));
2222
const gitignore = fileURLToPath(new URL(".gitignore", import.meta.url));
2323

24-
export default defineConfig([
24+
export default defineConfig(
2525
includeIgnoreFile(gitignore, "Imported .gitignore patterns") as never,
2626
globalIgnores([
2727
...GLOB_IGNORES,
@@ -106,4 +106,4 @@ export default defineConfig([
106106
},
107107
},
108108
disableProblematicEslintJsRules,
109-
]);
109+
);

examples/next/eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const GLOB_CONFIG = ["**/*.config.{js,mjs,ts,tsx}"];
1717

1818
const gitignore = fileURLToPath(new URL(".gitignore", import.meta.url));
1919

20-
export default defineConfig([
20+
export default defineConfig(
2121
includeIgnoreFile(gitignore, "Imported .gitignore patterns"),
2222
{
2323
files: GLOB_TS,
@@ -68,4 +68,4 @@ export default defineConfig([
6868
"no-console": "off",
6969
},
7070
},
71-
]);
71+
);

examples/react-dom-js/eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import globals from "globals";
88
import JSCONFIG_APP from "./jsconfig.app.json" with { type: "json" };
99
import JSCONFIG_NODE from "./jsconfig.node.json" with { type: "json" };
1010

11-
export default defineConfig([
11+
export default defineConfig(
1212
// base configuration for browser environment source files
1313
{
1414
files: JSCONFIG_APP.include,
@@ -56,4 +56,4 @@ export default defineConfig([
5656
eslintPluginReactRefresh.configs.recommended,
5757
],
5858
},
59-
]);
59+
);

0 commit comments

Comments
 (0)