@ncontiero/eslint-config 8.0.1 → 8.2.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/dist/index.d.mts +70 -10
- package/dist/index.mjs +58 -30
- package/package.json +14 -13
package/dist/index.d.mts
CHANGED
|
@@ -51,12 +51,12 @@ interface RuleOptions {
|
|
|
51
51
|
*/
|
|
52
52
|
'accessor-pairs'?: Linter.RuleEntry<AccessorPairs>;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Enforce consistent line breaks for chaining member access
|
|
55
55
|
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-chaining.md
|
|
56
56
|
*/
|
|
57
57
|
'antfu/consistent-chaining'?: Linter.RuleEntry<AntfuConsistentChaining>;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Enforce consistent line breaks inside braces and parentheses
|
|
60
60
|
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/consistent-list-newline.md
|
|
61
61
|
*/
|
|
62
62
|
'antfu/consistent-list-newline'?: Linter.RuleEntry<AntfuConsistentListNewline>;
|
|
@@ -82,22 +82,22 @@ interface RuleOptions {
|
|
|
82
82
|
'antfu/indent-unindent'?: Linter.RuleEntry<AntfuIndentUnindent>;
|
|
83
83
|
/**
|
|
84
84
|
* Prevent importing modules in `dist` folder
|
|
85
|
-
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/no-import-dist.
|
|
85
|
+
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/no-import-dist.md
|
|
86
86
|
*/
|
|
87
87
|
'antfu/no-import-dist'?: Linter.RuleEntry<[]>;
|
|
88
88
|
/**
|
|
89
89
|
* Prevent importing modules in `node_modules` folder by relative or absolute path
|
|
90
|
-
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/no-import-node-modules-by-path.
|
|
90
|
+
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/no-import-node-modules-by-path.md
|
|
91
91
|
*/
|
|
92
92
|
'antfu/no-import-node-modules-by-path'?: Linter.RuleEntry<[]>;
|
|
93
93
|
/**
|
|
94
94
|
* Prevent using top-level await
|
|
95
|
-
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/no-top-level-await.
|
|
95
|
+
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/no-top-level-await.md
|
|
96
96
|
*/
|
|
97
97
|
'antfu/no-top-level-await'?: Linter.RuleEntry<[]>;
|
|
98
98
|
/**
|
|
99
99
|
* Do not use `exports =`
|
|
100
|
-
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/no-ts-export-equal.
|
|
100
|
+
* @see https://github.com/antfu/eslint-plugin-antfu/blob/main/src/rules/no-ts-export-equal.md
|
|
101
101
|
*/
|
|
102
102
|
'antfu/no-ts-export-equal'?: Linter.RuleEntry<[]>;
|
|
103
103
|
/**
|
|
@@ -16486,7 +16486,7 @@ type Yoda = [] | [("always" | "never")] | [("always" | "never"), {
|
|
|
16486
16486
|
exceptRange?: boolean;
|
|
16487
16487
|
onlyEquality?: boolean;
|
|
16488
16488
|
}]; // Names of all the configs
|
|
16489
|
-
type ConfigNames = 'ncontiero/gitignore' | 'ncontiero/ignores' | 'ncontiero/javascript/rules' | 'ncontiero/javascript/cli-rules' | 'ncontiero/javascript/test-rules' | 'ncontiero/comments/rules' | 'ncontiero/
|
|
16489
|
+
type ConfigNames = 'ncontiero/gitignore' | 'ncontiero/ignores' | 'ncontiero/javascript/rules' | 'ncontiero/javascript/cli-rules' | 'ncontiero/javascript/test-rules' | 'ncontiero/comments/rules' | 'ncontiero/command/rules' | 'ncontiero/perfectionist/rules' | 'ncontiero/node/setup' | 'ncontiero/node/rules' | 'ncontiero/promise/setup' | 'ncontiero/promise/rules' | 'ncontiero/jsdoc/setup' | 'ncontiero/jsdoc/rules' | 'ncontiero/imports/rules' | 'ncontiero/imports/allow-default-export' | 'ncontiero/de-morgan' | 'ncontiero/e18e/rules' | 'ncontiero/unicorn/rules' | 'ncontiero/jsx/setup' | 'ncontiero/typescript/setup' | 'ncontiero/typescript/parser' | 'ncontiero/typescript/rules' | 'ncontiero/typescript/dts-rules' | 'ncontiero/typescript/cjs-rules' | 'ncontiero/tanstack-query/setup' | 'ncontiero/tanstack-query/rules' | 'ncontiero/jsonc/recommended' | 'ncontiero/jsonc/recommended' | 'ncontiero/jsonc/recommended' | 'ncontiero/jsonc/rules' | 'ncontiero/sort/package-json' | 'ncontiero/sort/tsconfig' | 'ncontiero/yml/setup' | 'ncontiero/yml/rules' | 'ncontiero/yml/pnpm-workspace' | 'ncontiero/toml/setup' | 'ncontiero/toml/rules' | 'ncontiero/markdown/setup' | 'ncontiero/markdown/processor' | 'ncontiero/markdown/parser' | 'ncontiero/markdown/rules' | 'ncontiero/regexp/rules' | 'ncontiero/react/setup' | 'ncontiero/react/rules' | 'ncontiero/react/typescript' | 'ncontiero/nextjs/setup' | 'ncontiero/nextjs/rules' | 'ncontiero/html/setup' | 'ncontiero/html/rules' | 'ncontiero/tailwindcss/setup' | 'ncontiero/tailwindcss/rules' | 'ncontiero/prettier/setup' | 'ncontiero/prettier/disables' | 'ncontiero/prettier/rules' | 'ncontiero/prettier/markdown' | 'ncontiero/prettier/css' | 'ncontiero/prettier/scss' | 'ncontiero/prettier/less';
|
|
16490
16490
|
//#endregion
|
|
16491
16491
|
//#region src/types.d.ts
|
|
16492
16492
|
type Awaitable<T> = T | Promise<T>;
|
|
@@ -16576,12 +16576,16 @@ interface OptionsTailwindCSS extends OptionsOverrides {
|
|
|
16576
16576
|
/**
|
|
16577
16577
|
* Path to the Tailwind CSS config file.
|
|
16578
16578
|
*
|
|
16579
|
+
* For Tailwind CSS v4 and the css based config, use the `cssGlobalPath` option instead.
|
|
16580
|
+
*
|
|
16581
|
+
* @see [better-tailwindcss settings](https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md#tailwindconfig)
|
|
16579
16582
|
* @default "tailwind.config.ts"
|
|
16580
16583
|
*/
|
|
16581
16584
|
configPath?: string;
|
|
16582
16585
|
/**
|
|
16583
16586
|
* Path to the global CSS file.
|
|
16584
16587
|
*
|
|
16588
|
+
* @see @see [better-tailwindcss settings](https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md#entrypoint)
|
|
16585
16589
|
* @default "src/app/globals.css"
|
|
16586
16590
|
*/
|
|
16587
16591
|
cssGlobalPath?: string;
|
|
@@ -16589,8 +16593,27 @@ interface OptionsTailwindCSS extends OptionsOverrides {
|
|
|
16589
16593
|
* The working directory used to resolve `tailwindcss` and related config files.
|
|
16590
16594
|
* This is useful for monorepos where linting runs from the repository root
|
|
16591
16595
|
* but each project has its own `node_modules` and Tailwind setup.
|
|
16596
|
+
*
|
|
16597
|
+
* @see [better-tailwindcss settings](https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md#cwd)
|
|
16592
16598
|
*/
|
|
16593
16599
|
cwd?: string;
|
|
16600
|
+
/**
|
|
16601
|
+
* The path to the tsconfig file. If not specified, the plugin will try to find it automatically.
|
|
16602
|
+
*
|
|
16603
|
+
* The tsconfig is used to resolve tsconfig [`path`](https://www.typescriptlang.org/tsconfig/#paths) aliases.
|
|
16604
|
+
*
|
|
16605
|
+
* @see [better-tailwindcss settings](https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md#tsconfig)
|
|
16606
|
+
*/
|
|
16607
|
+
tsconfigPath?: string;
|
|
16608
|
+
/**
|
|
16609
|
+
* Tailwind CSS v4 allows you to define custom component classes like `card`, `btn`, `badge` etc.
|
|
16610
|
+
*
|
|
16611
|
+
* If you want to create such classes, you can set this option to true to allow the rule to detect those classes and not report them as unknown classes.
|
|
16612
|
+
*
|
|
16613
|
+
* @see [better-tailwindcss settings](https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md#detectcomponentclasses)
|
|
16614
|
+
* @default false
|
|
16615
|
+
*/
|
|
16616
|
+
detectComponentClasses?: boolean;
|
|
16594
16617
|
}
|
|
16595
16618
|
interface OptionsE18e extends OptionsOverrides {
|
|
16596
16619
|
/**
|
|
@@ -16637,6 +16660,31 @@ interface OptionsConfig {
|
|
|
16637
16660
|
gitignore?: boolean | FlatGitignoreOptions;
|
|
16638
16661
|
/** Core rules. Can't be disabled. */
|
|
16639
16662
|
javascript?: OptionsOverrides;
|
|
16663
|
+
/**
|
|
16664
|
+
* Enable Node.js rules
|
|
16665
|
+
*
|
|
16666
|
+
* @default true
|
|
16667
|
+
*/
|
|
16668
|
+
node?: boolean;
|
|
16669
|
+
/**
|
|
16670
|
+
* Enable JSDoc rules
|
|
16671
|
+
*
|
|
16672
|
+
* @default true
|
|
16673
|
+
*/
|
|
16674
|
+
jsdoc?: boolean;
|
|
16675
|
+
/**
|
|
16676
|
+
* Enable De Morgan rules.
|
|
16677
|
+
*
|
|
16678
|
+
* @see [eslint-plugin-de-morgan](https://github.com/azat-io/eslint-plugin-de-morgan)
|
|
16679
|
+
* @default true
|
|
16680
|
+
*/
|
|
16681
|
+
deMorgan?: boolean;
|
|
16682
|
+
/**
|
|
16683
|
+
* Options for eslint-plugin-promise.
|
|
16684
|
+
*
|
|
16685
|
+
* @default true
|
|
16686
|
+
*/
|
|
16687
|
+
promise?: boolean | OptionsOverrides;
|
|
16640
16688
|
/**
|
|
16641
16689
|
* Enable TypeScript support.
|
|
16642
16690
|
*
|
|
@@ -16659,12 +16707,24 @@ interface OptionsConfig {
|
|
|
16659
16707
|
* @default true
|
|
16660
16708
|
*/
|
|
16661
16709
|
unicorn?: boolean | OptionsUnicorn;
|
|
16710
|
+
/**
|
|
16711
|
+
* Options for eslint-plugin-perfectionist.
|
|
16712
|
+
*
|
|
16713
|
+
* @default true
|
|
16714
|
+
*/
|
|
16715
|
+
perfectionist?: boolean | OptionsOverrides;
|
|
16662
16716
|
/**
|
|
16663
16717
|
* Options for [@e18e/eslint-plugin](https://github.com/e18e/eslint-plugin)
|
|
16664
16718
|
*
|
|
16665
16719
|
* @default true
|
|
16666
16720
|
*/
|
|
16667
16721
|
e18e?: boolean | OptionsE18e;
|
|
16722
|
+
/**
|
|
16723
|
+
* Options for eslint-plugin-import-x.
|
|
16724
|
+
*
|
|
16725
|
+
* @default true
|
|
16726
|
+
*/
|
|
16727
|
+
imports?: boolean | OptionsOverrides;
|
|
16668
16728
|
/**
|
|
16669
16729
|
* Enable JSONC support.
|
|
16670
16730
|
*
|
|
@@ -16759,7 +16819,7 @@ declare function html(options: HTMLOptions): Promise<FlatConfigItem[]>;
|
|
|
16759
16819
|
declare function ignores(userIgnores?: string[], ignoreTypeScript?: boolean): FlatConfigItem[];
|
|
16760
16820
|
//#endregion
|
|
16761
16821
|
//#region src/configs/imports.d.ts
|
|
16762
|
-
declare function imports(options?: OptionsHasNextJs): FlatConfigItem[];
|
|
16822
|
+
declare function imports(options?: OptionsHasNextJs & OptionsOverrides): FlatConfigItem[];
|
|
16763
16823
|
//#endregion
|
|
16764
16824
|
//#region src/configs/javascript.d.ts
|
|
16765
16825
|
declare const restrictedSyntaxJs: string[];
|
|
@@ -16789,13 +16849,13 @@ declare function node(): FlatConfigItem[];
|
|
|
16789
16849
|
*
|
|
16790
16850
|
* @see https://github.com/azat-io/eslint-plugin-perfectionist
|
|
16791
16851
|
*/
|
|
16792
|
-
declare function perfectionist(): FlatConfigItem[];
|
|
16852
|
+
declare function perfectionist(options?: OptionsOverrides): FlatConfigItem[];
|
|
16793
16853
|
//#endregion
|
|
16794
16854
|
//#region src/configs/prettier.d.ts
|
|
16795
16855
|
declare function prettier(options?: PrettierOptions): Promise<FlatConfigItem[]>;
|
|
16796
16856
|
//#endregion
|
|
16797
16857
|
//#region src/configs/promise.d.ts
|
|
16798
|
-
declare function promise(): Promise<FlatConfigItem[]>;
|
|
16858
|
+
declare function promise(options?: OptionsOverrides): Promise<FlatConfigItem[]>;
|
|
16799
16859
|
//#endregion
|
|
16800
16860
|
//#region src/configs/react.d.ts
|
|
16801
16861
|
declare function react(options?: OptionsTypeScriptParserOptions & OptionsTypeScriptWithTypes & OptionsOverrides & OptionsFiles): Promise<FlatConfigItem[]>;
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import pluginNode from "eslint-plugin-n";
|
|
|
7
7
|
import pluginPerfectionist from "eslint-plugin-perfectionist";
|
|
8
8
|
import pluginUnicorn from "eslint-plugin-unicorn";
|
|
9
9
|
import pluginUnusedImports from "eslint-plugin-unused-imports";
|
|
10
|
-
import { isPackageExists } from "local-pkg";
|
|
10
|
+
import { getPackageInfo, isPackageExists } from "local-pkg";
|
|
11
11
|
import globals from "globals";
|
|
12
12
|
import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
|
|
13
13
|
import { configs } from "eslint-plugin-regexp";
|
|
@@ -322,7 +322,7 @@ function ignores(userIgnores = [], ignoreTypeScript = false) {
|
|
|
322
322
|
//#endregion
|
|
323
323
|
//#region src/configs/imports.ts
|
|
324
324
|
function imports(options = {}) {
|
|
325
|
-
const { nextJs = false } = options;
|
|
325
|
+
const { nextJs = false, overrides = {} } = options;
|
|
326
326
|
return [{
|
|
327
327
|
name: "ncontiero/imports/rules",
|
|
328
328
|
plugins: {
|
|
@@ -338,7 +338,8 @@ function imports(options = {}) {
|
|
|
338
338
|
"import/no-mutable-exports": "error",
|
|
339
339
|
"import/no-named-default": "error",
|
|
340
340
|
"import/no-self-import": "error",
|
|
341
|
-
"import/no-webpack-loader-syntax": "error"
|
|
341
|
+
"import/no-webpack-loader-syntax": "error",
|
|
342
|
+
...overrides
|
|
342
343
|
}
|
|
343
344
|
}, {
|
|
344
345
|
files: [
|
|
@@ -443,6 +444,7 @@ function javascript(options = {}) {
|
|
|
443
444
|
"no-shadow-restricted-names": "error",
|
|
444
445
|
"no-sparse-arrays": "error",
|
|
445
446
|
"no-this-before-super": "error",
|
|
447
|
+
"no-throw-literal": "error",
|
|
446
448
|
"no-undef": "error",
|
|
447
449
|
"no-unexpected-multiline": "error",
|
|
448
450
|
"no-unreachable": "error",
|
|
@@ -463,7 +465,7 @@ function javascript(options = {}) {
|
|
|
463
465
|
"no-useless-escape": "error",
|
|
464
466
|
"no-useless-rename": "error",
|
|
465
467
|
"no-var": "error",
|
|
466
|
-
"no-void": "error",
|
|
468
|
+
"no-void": ["error", { allowAsStatement: true }],
|
|
467
469
|
"no-with": "error",
|
|
468
470
|
"object-shorthand": [
|
|
469
471
|
"error",
|
|
@@ -482,6 +484,7 @@ function javascript(options = {}) {
|
|
|
482
484
|
ignoreReadBeforeAssign: true
|
|
483
485
|
}],
|
|
484
486
|
"prefer-exponentiation-operator": "error",
|
|
487
|
+
"prefer-promise-reject-errors": "error",
|
|
485
488
|
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
486
489
|
"prefer-rest-params": "error",
|
|
487
490
|
"prefer-spread": "error",
|
|
@@ -782,7 +785,8 @@ function node() {
|
|
|
782
785
|
*
|
|
783
786
|
* @see https://github.com/azat-io/eslint-plugin-perfectionist
|
|
784
787
|
*/
|
|
785
|
-
function perfectionist() {
|
|
788
|
+
function perfectionist(options = {}) {
|
|
789
|
+
const { overrides = {} } = options;
|
|
786
790
|
return [{
|
|
787
791
|
name: "ncontiero/perfectionist/rules",
|
|
788
792
|
plugins: { perfectionist: pluginPerfectionist },
|
|
@@ -820,7 +824,8 @@ function perfectionist() {
|
|
|
820
824
|
type: "natural"
|
|
821
825
|
}],
|
|
822
826
|
"perfectionist/sort-named-exports": ["warn", { groups: ["type-export", "value-export"] }],
|
|
823
|
-
"perfectionist/sort-named-imports": ["warn", { groups: ["type-import", "value-import"] }]
|
|
827
|
+
"perfectionist/sort-named-imports": ["warn", { groups: ["type-import", "value-import"] }],
|
|
828
|
+
...overrides
|
|
824
829
|
}
|
|
825
830
|
}];
|
|
826
831
|
}
|
|
@@ -892,7 +897,8 @@ async function prettier(options = {}) {
|
|
|
892
897
|
}
|
|
893
898
|
//#endregion
|
|
894
899
|
//#region src/configs/promise.ts
|
|
895
|
-
async function promise() {
|
|
900
|
+
async function promise(options = {}) {
|
|
901
|
+
const { overrides = {} } = options;
|
|
896
902
|
return [{
|
|
897
903
|
...(await interopDefault(import("eslint-plugin-promise"))).configs["flat/recommended"],
|
|
898
904
|
name: "ncontiero/promise/setup"
|
|
@@ -900,7 +906,8 @@ async function promise() {
|
|
|
900
906
|
name: "ncontiero/promise/rules",
|
|
901
907
|
rules: {
|
|
902
908
|
"promise/always-return": ["error", { ignoreLastCallback: true }],
|
|
903
|
-
"promise/no-multiple-resolved": "warn"
|
|
909
|
+
"promise/no-multiple-resolved": "warn",
|
|
910
|
+
...overrides
|
|
904
911
|
}
|
|
905
912
|
}];
|
|
906
913
|
}
|
|
@@ -1260,21 +1267,25 @@ const sortPnpmWorkspace = () => [{
|
|
|
1260
1267
|
//#endregion
|
|
1261
1268
|
//#region src/configs/tailwindcss.ts
|
|
1262
1269
|
async function tailwindcss(options = {}) {
|
|
1263
|
-
const { overrides = {} } = options;
|
|
1264
|
-
const
|
|
1265
|
-
|
|
1266
|
-
|
|
1270
|
+
const { cwd, detectComponentClasses, overrides = {}, tsconfigPath } = options;
|
|
1271
|
+
const cssGlobalPath = options.cssGlobalPath ?? path.join("src", "app", "globals.css");
|
|
1272
|
+
const configPath = options.configPath ?? path.join("tailwind.config.ts");
|
|
1273
|
+
const tailwindV4Rules = {
|
|
1274
|
+
"tailwindcss/enforce-canonical-classes": "error",
|
|
1275
|
+
"tailwindcss/enforce-consistent-important-position": "off",
|
|
1276
|
+
"tailwindcss/enforce-consistent-variable-syntax": "off",
|
|
1277
|
+
"tailwindcss/enforce-shorthand-classes": "off"
|
|
1267
1278
|
};
|
|
1268
|
-
const
|
|
1269
|
-
const configPath = resolvePath(options.configPath ?? path.join("tailwind.config.ts"));
|
|
1270
|
-
const cwd = options.cwd ? resolvePath(options.cwd) : void 0;
|
|
1279
|
+
const isV4 = (await getPackageInfo("tailwindcss"))?.version?.startsWith("4");
|
|
1271
1280
|
return [{
|
|
1272
1281
|
name: "ncontiero/tailwindcss/setup",
|
|
1273
1282
|
plugins: { tailwindcss: await interopDefault(import("eslint-plugin-better-tailwindcss")) },
|
|
1274
|
-
settings: { tailwindcss: {
|
|
1283
|
+
settings: { "better-tailwindcss": {
|
|
1275
1284
|
cwd,
|
|
1285
|
+
detectComponentClasses,
|
|
1276
1286
|
entryPoint: cssGlobalPath,
|
|
1277
|
-
tailwindConfig: configPath
|
|
1287
|
+
tailwindConfig: configPath,
|
|
1288
|
+
tsconfig: tsconfigPath
|
|
1278
1289
|
} }
|
|
1279
1290
|
}, {
|
|
1280
1291
|
files: [GLOB_SRC, GLOB_HTML],
|
|
@@ -1288,13 +1299,15 @@ async function tailwindcss(options = {}) {
|
|
|
1288
1299
|
printWidth: 120
|
|
1289
1300
|
}],
|
|
1290
1301
|
"tailwindcss/enforce-consistent-variable-syntax": "error",
|
|
1302
|
+
"tailwindcss/enforce-consistent-variant-order": "warn",
|
|
1291
1303
|
"tailwindcss/enforce-shorthand-classes": "warn",
|
|
1292
1304
|
"tailwindcss/no-conflicting-classes": "error",
|
|
1293
1305
|
"tailwindcss/no-deprecated-classes": "error",
|
|
1294
1306
|
"tailwindcss/no-duplicate-classes": "error",
|
|
1295
1307
|
"tailwindcss/no-restricted-classes": "error",
|
|
1296
|
-
"tailwindcss/no-unknown-classes": "
|
|
1308
|
+
"tailwindcss/no-unknown-classes": "warn",
|
|
1297
1309
|
"tailwindcss/no-unnecessary-whitespace": "warn",
|
|
1310
|
+
...isV4 ? tailwindV4Rules : {},
|
|
1298
1311
|
...overrides
|
|
1299
1312
|
}
|
|
1300
1313
|
}];
|
|
@@ -1368,27 +1381,34 @@ async function typescript(options = {}) {
|
|
|
1368
1381
|
const typeAwareRules = {
|
|
1369
1382
|
"dot-notation": "off",
|
|
1370
1383
|
"no-implied-eval": "off",
|
|
1384
|
+
"no-throw-literal": "off",
|
|
1385
|
+
"prefer-promise-reject-errors": "off",
|
|
1386
|
+
"require-await": "off",
|
|
1371
1387
|
"ts/await-thenable": "error",
|
|
1372
1388
|
"ts/dot-notation": ["error", { allowKeywords: true }],
|
|
1373
1389
|
"ts/no-floating-promises": "error",
|
|
1374
1390
|
"ts/no-for-in-array": "error",
|
|
1375
1391
|
"ts/no-implied-eval": "error",
|
|
1376
|
-
"ts/no-misused-promises": "error",
|
|
1392
|
+
"ts/no-misused-promises": ["error", { checksVoidReturn: { attributes: false } }],
|
|
1393
|
+
"ts/no-unnecessary-type-arguments": "error",
|
|
1377
1394
|
"ts/no-unnecessary-type-assertion": "error",
|
|
1378
1395
|
"ts/no-unsafe-argument": "error",
|
|
1379
1396
|
"ts/no-unsafe-assignment": "error",
|
|
1380
1397
|
"ts/no-unsafe-call": "error",
|
|
1381
1398
|
"ts/no-unsafe-member-access": "error",
|
|
1382
1399
|
"ts/no-unsafe-return": "error",
|
|
1400
|
+
"ts/only-throw-error": "error",
|
|
1401
|
+
"ts/prefer-promise-reject-errors": "error",
|
|
1383
1402
|
"ts/promise-function-async": "error",
|
|
1403
|
+
"ts/require-await": "error",
|
|
1384
1404
|
"ts/restrict-plus-operands": "error",
|
|
1385
1405
|
"ts/restrict-template-expressions": "error",
|
|
1386
|
-
"ts/return-await": ["error", "
|
|
1406
|
+
"ts/return-await": ["error", "always"],
|
|
1387
1407
|
"ts/strict-boolean-expressions": ["error", {
|
|
1388
1408
|
allowNullableBoolean: true,
|
|
1389
|
-
|
|
1409
|
+
allowNullableString: true
|
|
1390
1410
|
}],
|
|
1391
|
-
"ts/switch-exhaustiveness-check": "error",
|
|
1411
|
+
"ts/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }],
|
|
1392
1412
|
"ts/unbound-method": "error"
|
|
1393
1413
|
};
|
|
1394
1414
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
@@ -1457,7 +1477,6 @@ async function typescript(options = {}) {
|
|
|
1457
1477
|
"ts/no-invalid-void-type": "off",
|
|
1458
1478
|
"ts/no-non-null-assertion": "off",
|
|
1459
1479
|
"ts/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1460
|
-
"ts/no-require-imports": "error",
|
|
1461
1480
|
"ts/no-unused-expressions": ["error", {
|
|
1462
1481
|
allowShortCircuit: true,
|
|
1463
1482
|
allowTaggedTemplates: false,
|
|
@@ -1466,7 +1485,6 @@ async function typescript(options = {}) {
|
|
|
1466
1485
|
}],
|
|
1467
1486
|
"ts/no-unused-vars": "off",
|
|
1468
1487
|
"ts/no-useless-constructor": "off",
|
|
1469
|
-
"ts/no-wrapper-object-types": "error",
|
|
1470
1488
|
"ts/prefer-as-const": "warn",
|
|
1471
1489
|
"ts/prefer-literal-enum-member": ["error", { allowBitwiseExpressions: true }],
|
|
1472
1490
|
"ts/triple-slash-reference": "off",
|
|
@@ -1707,7 +1725,7 @@ function getStyleOptions(options) {
|
|
|
1707
1725
|
* @returns Merged ESLint configurations based on provided options.
|
|
1708
1726
|
*/
|
|
1709
1727
|
function ncontiero(options = {}, ...userConfigs) {
|
|
1710
|
-
const { e18e: enableE18e = true, gitignore: enableGitignore = true, jsx: enableJsx = true, nextjs: enableNextJs = hasNextJs, react: enableReact = hasReact, regexp: enableRegexp = true, tailwindcss: enableTailwindCSS = hasTailwind, tanstackQuery: enableTanStackQuery = false, typescript: enableTypescript = hasTypeScript, unicorn: enableUnicorn = true } = options;
|
|
1728
|
+
const { deMorgan: enableDeMorgan = true, e18e: enableE18e = true, gitignore: enableGitignore = true, html: enableHtml = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsonc: enableJsonc = true, jsx: enableJsx = true, markdown: enableMarkdown = true, nextjs: enableNextJs = hasNextJs, node: enableNode = true, perfectionist: enablePerfectionist = true, prettier: enablePrettier = true, promise: enablePromise = true, react: enableReact = hasReact, regexp: enableRegexp = true, tailwindcss: enableTailwindCSS = hasTailwind, tanstackQuery: enableTanStackQuery = false, typescript: enableTypescript = hasTypeScript, unicorn: enableUnicorn = true } = options;
|
|
1711
1729
|
const prettierOptions = typeof options.prettier === "object" ? options.prettier : {};
|
|
1712
1730
|
const styleOptions = getStyleOptions(prettierOptions);
|
|
1713
1731
|
const configs = [];
|
|
@@ -1721,7 +1739,16 @@ function ncontiero(options = {}, ...userConfigs) {
|
|
|
1721
1739
|
})]));
|
|
1722
1740
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
1723
1741
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
1724
|
-
configs.push(ignores(
|
|
1742
|
+
configs.push(ignores(userIgnores, !enableTypescript), javascript({ overrides: getOverrides(options, "javascript") }), comments(), command());
|
|
1743
|
+
if (enablePerfectionist) configs.push(perfectionist({ overrides: getOverrides(options, "perfectionist") }));
|
|
1744
|
+
if (enableNode) configs.push(node());
|
|
1745
|
+
if (enablePromise) configs.push(promise({ overrides: getOverrides(options, "promise") }));
|
|
1746
|
+
if (enableJsdoc) configs.push(jsdoc());
|
|
1747
|
+
if (enableImports) configs.push(imports({
|
|
1748
|
+
nextJs: !!enableNextJs,
|
|
1749
|
+
overrides: getOverrides(options, "imports")
|
|
1750
|
+
}));
|
|
1751
|
+
if (enableDeMorgan) configs.push(deMorgan());
|
|
1725
1752
|
if (enableE18e) configs.push(e18e(enableE18e === true ? {} : enableE18e));
|
|
1726
1753
|
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? { regexp: !!enableRegexp } : enableUnicorn));
|
|
1727
1754
|
if (enableJsx) configs.push(jsx(enableJsx === true ? {} : enableJsx));
|
|
@@ -1731,7 +1758,7 @@ function ncontiero(options = {}, ...userConfigs) {
|
|
|
1731
1758
|
tsconfigPath
|
|
1732
1759
|
}));
|
|
1733
1760
|
if (enableTanStackQuery) configs.push(tanstackQuery({ overrides: getOverrides(options, "tanstackQuery") }));
|
|
1734
|
-
if (
|
|
1761
|
+
if (enableJsonc) configs.push(jsonc({
|
|
1735
1762
|
overrides: getOverrides(options, "jsonc"),
|
|
1736
1763
|
style: styleOptions
|
|
1737
1764
|
}), sortPackageJson(), sortTsconfig());
|
|
@@ -1743,7 +1770,7 @@ function ncontiero(options = {}, ...userConfigs) {
|
|
|
1743
1770
|
overrides: getOverrides(options, "toml"),
|
|
1744
1771
|
style: styleOptions
|
|
1745
1772
|
}));
|
|
1746
|
-
if (
|
|
1773
|
+
if (enableMarkdown) configs.push(markdown({ overrides: getOverrides(options, "markdown") }));
|
|
1747
1774
|
if (enableRegexp) configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
1748
1775
|
if (enableReact) configs.push(react({
|
|
1749
1776
|
...typescriptOptions,
|
|
@@ -1751,15 +1778,16 @@ function ncontiero(options = {}, ...userConfigs) {
|
|
|
1751
1778
|
tsconfigPath
|
|
1752
1779
|
}));
|
|
1753
1780
|
if (enableNextJs) configs.push(nextJs({ overrides: getOverrides(options, "nextjs") }));
|
|
1754
|
-
if (
|
|
1781
|
+
if (enableHtml) configs.push(html({
|
|
1755
1782
|
...resolveSubOptions(options, "html"),
|
|
1756
1783
|
overrides: getOverrides(options, "html")
|
|
1757
1784
|
}));
|
|
1758
1785
|
if (enableTailwindCSS) configs.push(tailwindcss({
|
|
1786
|
+
tsconfigPath,
|
|
1759
1787
|
...resolveSubOptions(options, "tailwindcss"),
|
|
1760
1788
|
overrides: getOverrides(options, "tailwindcss")
|
|
1761
1789
|
}));
|
|
1762
|
-
if (
|
|
1790
|
+
if (enablePrettier) configs.push(prettier(prettierOptions));
|
|
1763
1791
|
if ("files" in options) throw new Error("[@ncontiero/eslint-config] The first argument should not contain the \"files\" property as the options are supposed to be global. Place it in the second or later config instead.");
|
|
1764
1792
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1765
1793
|
if (key in options) acc[key] = options[key];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ncontiero/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.0
|
|
4
|
+
"version": "8.2.0",
|
|
5
5
|
"description": "Nicolas's ESLint config.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Nicolas Contiero",
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@e18e/eslint-plugin": "^0.4.1",
|
|
41
41
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
|
|
42
|
-
"@eslint-react/eslint-plugin": "^5.7.
|
|
42
|
+
"@eslint-react/eslint-plugin": "^5.7.6",
|
|
43
43
|
"@eslint/markdown": "^8.0.1",
|
|
44
44
|
"@html-eslint/eslint-plugin": "^0.60.0",
|
|
45
45
|
"@html-eslint/parser": "^0.60.0",
|
|
46
|
-
"@next/eslint-plugin-next": "^16.2.
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^8.59.
|
|
48
|
-
"@typescript-eslint/parser": "^8.59.
|
|
46
|
+
"@next/eslint-plugin-next": "^16.2.6",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
|
48
|
+
"@typescript-eslint/parser": "^8.59.3",
|
|
49
49
|
"eslint-config-flat-gitignore": "^2.3.0",
|
|
50
50
|
"eslint-merge-processors": "^2.0.0",
|
|
51
|
-
"eslint-plugin-antfu": "^3.2.
|
|
51
|
+
"eslint-plugin-antfu": "^3.2.3",
|
|
52
52
|
"eslint-plugin-better-tailwindcss": "4.5.0",
|
|
53
53
|
"eslint-plugin-command": "^3.5.2",
|
|
54
54
|
"eslint-plugin-de-morgan": "^2.1.2",
|
|
@@ -74,14 +74,14 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@changesets/cli": "^2.31.0",
|
|
77
|
-
"@commitlint/cli": "^
|
|
78
|
-
"@commitlint/config-conventional": "^
|
|
77
|
+
"@commitlint/cli": "^21.0.0",
|
|
78
|
+
"@commitlint/config-conventional": "^21.0.0",
|
|
79
79
|
"@eslint/config-inspector": "^2.0.1",
|
|
80
80
|
"@ncontiero/changelog-github": "^2.1.3",
|
|
81
81
|
"@ncontiero/prettier-config": "^1.0.0",
|
|
82
|
-
"@tanstack/eslint-plugin-query": "^5.100.
|
|
82
|
+
"@tanstack/eslint-plugin-query": "^5.100.10",
|
|
83
83
|
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
84
|
-
"@types/node": "^25.
|
|
84
|
+
"@types/node": "^25.7.0",
|
|
85
85
|
"eslint": "^10.3.0",
|
|
86
86
|
"eslint-typegen": "^2.3.1",
|
|
87
87
|
"husky": "^9.1.7",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"tsdown": "^0.22.0",
|
|
92
92
|
"tsx": "^4.21.0",
|
|
93
93
|
"typescript": "^6.0.3",
|
|
94
|
-
"vitest": "^4.1.
|
|
94
|
+
"vitest": "^4.1.6"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": ">=20.19.0"
|
|
@@ -102,9 +102,10 @@
|
|
|
102
102
|
"prettier": "@ncontiero/prettier-config",
|
|
103
103
|
"scripts": {
|
|
104
104
|
"build": "pnpm typegen && tsdown",
|
|
105
|
-
"dev": "
|
|
106
|
-
"build:inspector": "pnpm build &&
|
|
105
|
+
"dev": "pnpm inspector",
|
|
106
|
+
"build:inspector": "pnpm build && pnpm inspector build --outDir .eslint-config-inspector",
|
|
107
107
|
"typegen": "tsx scripts/typegen.ts",
|
|
108
|
+
"inspector": "eslint-config-inspector --config eslint-inspector.config.ts",
|
|
108
109
|
"test": "vitest",
|
|
109
110
|
"lint": "eslint .",
|
|
110
111
|
"lint:fix": "pnpm lint --fix",
|