@lincy/eslint-config 3.0.11 → 3.1.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/README.md CHANGED
@@ -24,9 +24,9 @@ pnpm add -D eslint @lincy/eslint-config
24
24
 
25
25
  ```js
26
26
  // eslint.config.js
27
- import eslintConfig from '@lincy/eslint-config'
27
+ import lincy from '@lincy/eslint-config'
28
28
 
29
- export default eslintConfig()
29
+ export default lincy()
30
30
  ```
31
31
 
32
32
  > 通常您不需要`.eslintignore`,因为它已由预设提供。
@@ -99,46 +99,96 @@ For example:
99
99
 
100
100
  ## 定制化
101
101
 
102
- 通常你只需要导入 `eslintConfig` 预设:
102
+ 通常你只需要导入 `lincy` 预设:
103
103
 
104
+ #### esm
104
105
  ```js
105
106
  // eslint.config.js
106
- import eslintConfig from '@lincy/eslint-config'
107
+ import lincy from '@lincy/eslint-config'
107
108
 
108
- export default eslintConfig()
109
+ // or
110
+ // import { lincy } from '@lincy/eslint-config'
111
+
112
+ export default lincy()
113
+ ```
114
+
115
+ #### cjs
116
+ ```js
117
+ // eslint.config.js
118
+ const lincy = require('@lincy/eslint-config').lincy
119
+
120
+ module.exports = lincy()
109
121
  ```
110
122
 
111
123
  您可以单独配置每个功能,例如:
112
124
 
113
125
  ```js
114
126
  // eslint.config.js
115
- import eslintConfig from '@lincy/eslint-config'
116
-
117
- export default eslintConfig({
118
- stylistic: true, // enable stylistic formatting rules
119
- typescript: true,
120
- vue: true,
121
- jsonc: false,
122
- yml: false,
127
+ import lincy from '@lincy/eslint-config'
128
+
129
+ export default lincy({
130
+ // 是否启用 stylistic 格式化规则
131
+ stylistic: true, // 默认值: true
132
+ // 是否启用 typescript 规则
133
+ typescript: true, // 默认值: 检测是否安装typescript依赖
134
+ // 是否启用 vue 规则
135
+ vue: true, // 默认值: 检测是否安装vue依赖
136
+ // 是否启用 jsonc 规则
137
+ jsonc: false, // 默认值: 检测是否安装typescript依赖
138
+ // 是否启用 yml 规则
139
+ yml: false, // 默认值: true
140
+ // 是否启用 .gitignore 文件
141
+ gitignore: false, // 默认值: true
142
+ // 是否启用 test 规则
143
+ test: false, // 默认值: true
144
+ // 是否启用 markdown 规则
145
+ markdown: false, // 默认值: true
123
146
  })
124
147
  ```
125
148
 
126
- `eslintConfig` 工厂函数还接受任意数量的自定义配置覆盖:
149
+ `lincy` 工厂函数还接受任意数量的自定义配置覆盖:
127
150
 
128
151
  ```js
129
152
  // eslint.config.js
130
- import eslintConfig from '@lincy/eslint-config'
153
+ import { readFile } from 'node:fs/promises'
154
+ import lincy from '@lincy/eslint-config'
155
+ import plugin from '@unocss/eslint-plugin'
156
+
157
+ const autoImport = JSON.parse(
158
+ await readFile(new URL('./.eslintrc-auto-import.json', import.meta.url)),
159
+ )
131
160
 
132
- export default eslintConfig(
161
+ export default lincy(
133
162
  {
134
163
  // Configures for config
135
164
  },
136
-
137
- // From the second arguments they are ESLint Flat Configs
138
- // you can have multiple configs
165
+ // 启用 unocss
139
166
  {
140
- rules: {},
167
+ plugins: {
168
+ '@unocss': plugin,
169
+ },
170
+ rules: {
171
+ ...plugin.configs.recommended.rules,
172
+ '@unocss/order': 'off',
173
+ },
174
+ },
175
+ // 启用 auto-import 生成的 .eslintrc-auto-import.json
176
+ {
177
+ languageOptions: {
178
+ globals: {
179
+ ...autoImport.globals,
180
+ // 其他 globals
181
+ },
182
+ },
183
+ },
184
+ // 自定义排除文件(夹)
185
+ {
186
+ ignores: [
187
+ '**/assets',
188
+ '**/static',
189
+ ],
141
190
  },
191
+ // 你还可以继续配置多个 ESLint Flat Configs
142
192
  {
143
193
  rules: {},
144
194
  },
@@ -202,7 +252,6 @@ export default [
202
252
  | `n/*` | `node` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n)
203
253
  | `@typescript-eslint/*` | `ts/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
204
254
  | `@stylistic/js` | `style/*` | [@stylistic/eslint-plugin-js](https://github.com/eslint-stylistic/eslint-stylistic) |
205
- | `@stylistic/ts` | `style-ts/` | [@stylistic/eslint-plugin-ts](https://github.com/eslint-stylistic/eslint-stylistic) |
206
255
 
207
256
  当您想要覆盖规则或内联禁用它们时,您需要更新到新的前缀:
208
257
 
@@ -218,9 +267,9 @@ type foo = { bar: 2 }
218
267
 
219
268
  ```js
220
269
  // eslint.config.js
221
- import eslintConfig from '@lincy/eslint-config'
270
+ import lincy from '@lincy/eslint-config'
222
271
 
223
- export default eslintConfig({
272
+ export default lincy({
224
273
  typescript: {
225
274
  tsconfigPath: 'tsconfig.json',
226
275
  },
package/dist/index.cjs CHANGED
@@ -36,7 +36,6 @@ __export(src_exports, {
36
36
  ignores: () => ignores,
37
37
  imports: () => imports,
38
38
  javascript: () => javascript,
39
- javascriptStylistic: () => javascriptStylistic,
40
39
  jsdoc: () => jsdoc,
41
40
  jsonc: () => jsonc,
42
41
  lincy: () => lincy,
@@ -54,22 +53,24 @@ __export(src_exports, {
54
53
  pluginMarkdown: () => import_eslint_plugin_markdown.default,
55
54
  pluginNoOnlyTests: () => import_eslint_plugin_no_only_tests.default,
56
55
  pluginNode: () => import_eslint_plugin_n.default,
57
- pluginStylisticJs: () => import_eslint_plugin_js.default,
58
- pluginStylisticTs: () => import_eslint_plugin_ts.default,
59
- pluginTs: () => import_eslint_plugin.default,
56
+ pluginStylistic: () => import_eslint_plugin.default,
57
+ pluginTs: () => import_eslint_plugin2.default,
60
58
  pluginUnicorn: () => import_eslint_plugin_unicorn.default,
61
59
  pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
62
60
  pluginVue: () => import_eslint_plugin_vue.default,
63
61
  pluginYml: () => import_eslint_plugin_yml.default,
62
+ recordRulesState: () => recordRulesState,
63
+ recordRulesStateConfigs: () => recordRulesStateConfigs,
64
64
  renameRules: () => renameRules,
65
65
  sortPackageJson: () => sortPackageJson,
66
66
  sortTsconfig: () => sortTsconfig,
67
+ stylistic: () => stylistic,
67
68
  test: () => test,
68
69
  typescript: () => typescript,
69
- typescriptStylistic: () => typescriptStylistic,
70
70
  typescriptWithLanguageServer: () => typescriptWithLanguageServer,
71
71
  unicorn: () => unicorn,
72
72
  vue: () => vue,
73
+ warnUnnecessaryOffRules: () => warnUnnecessaryOffRules,
73
74
  yml: () => yml
74
75
  });
75
76
  module.exports = __toCommonJS(src_exports);
@@ -141,9 +142,6 @@ function searchPackageJSON(dir) {
141
142
  // src/factory.ts
142
143
  var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
143
144
 
144
- // src/flags.ts
145
- var OFF = 0;
146
-
147
145
  // src/plugins.ts
148
146
  var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
149
147
  var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
@@ -152,9 +150,8 @@ var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
152
150
  var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
153
151
  var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
154
152
  var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
155
- var import_eslint_plugin_js = __toESM(require("@stylistic/eslint-plugin-js"), 1);
156
- var import_eslint_plugin_ts = __toESM(require("@stylistic/eslint-plugin-ts"), 1);
157
- var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
153
+ var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
154
+ var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
158
155
  var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
159
156
  var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
160
157
  var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
@@ -172,8 +169,10 @@ var comments = [
172
169
  "eslint-comments": import_eslint_plugin_eslint_comments.default
173
170
  },
174
171
  rules: {
175
- ...import_eslint_plugin_eslint_comments.default.configs.recommended.rules,
176
- "eslint-comments/disable-enable-pair": OFF
172
+ "eslint-comments/no-aggregating-enable": "error",
173
+ "eslint-comments/no-duplicate-disable": "error",
174
+ "eslint-comments/no-unlimited-disable": "error",
175
+ "eslint-comments/no-unused-enable": "error"
177
176
  }
178
177
  }
179
178
  ];
@@ -246,6 +245,11 @@ var imports = [
246
245
 
247
246
  // src/configs/javascript.ts
248
247
  var import_globals = __toESM(require("globals"), 1);
248
+
249
+ // src/flags.ts
250
+ var OFF = 0;
251
+
252
+ // src/configs/javascript.ts
249
253
  function javascript(options = {}) {
250
254
  return [
251
255
  {
@@ -479,19 +483,25 @@ var jsdoc = [
479
483
  jsdoc: import_eslint_plugin_jsdoc.default
480
484
  },
481
485
  rules: {
482
- ...import_eslint_plugin_jsdoc.default.configs["flat/recommended-typescript"].rules,
483
- "jsdoc/check-tag-names": OFF,
484
- "jsdoc/check-values": OFF,
485
- "jsdoc/no-undefined-types": OFF,
486
- "jsdoc/require-jsdoc": OFF,
487
- "jsdoc/require-param": OFF,
488
- "jsdoc/require-param-description": OFF,
489
- "jsdoc/require-param-type": OFF,
490
- "jsdoc/require-returns": OFF,
491
- "jsdoc/require-returns-type": OFF,
492
- "jsdoc/require-throws": OFF,
493
- "jsdoc/require-yields": OFF,
494
- "jsdoc/tag-lines": OFF
486
+ "jsdoc/check-access": "warn",
487
+ "jsdoc/check-alignment": "warn",
488
+ "jsdoc/check-param-names": "warn",
489
+ "jsdoc/check-property-names": "warn",
490
+ "jsdoc/check-types": "warn",
491
+ "jsdoc/empty-tags": "warn",
492
+ "jsdoc/implements-on-classes": "warn",
493
+ "jsdoc/multiline-blocks": "warn",
494
+ "jsdoc/no-defaults": "warn",
495
+ "jsdoc/no-multi-asterisks": "warn",
496
+ "jsdoc/no-types": "warn",
497
+ "jsdoc/require-param-name": "warn",
498
+ "jsdoc/require-property": "warn",
499
+ "jsdoc/require-property-description": "warn",
500
+ "jsdoc/require-property-name": "warn",
501
+ "jsdoc/require-returns-check": "warn",
502
+ "jsdoc/require-returns-description": "warn",
503
+ "jsdoc/require-yields-check": "warn",
504
+ "jsdoc/valid-types": "warn"
495
505
  }
496
506
  }
497
507
  ];
@@ -507,16 +517,42 @@ var jsonc = [
507
517
  jsonc: import_eslint_plugin_jsonc.default
508
518
  },
509
519
  rules: {
510
- ...import_eslint_plugin_jsonc.default.configs["recommended-with-jsonc"].rules,
511
520
  "jsonc/array-bracket-spacing": ["error", "never"],
512
521
  "jsonc/comma-dangle": ["error", "never"],
513
522
  "jsonc/comma-style": ["error", "last"],
514
523
  "jsonc/indent": ["error", 2],
515
524
  "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
525
+ "jsonc/no-bigint-literals": "error",
526
+ "jsonc/no-binary-expression": "error",
527
+ "jsonc/no-binary-numeric-literals": "error",
528
+ "jsonc/no-dupe-keys": "error",
529
+ "jsonc/no-escape-sequence-in-identifier": "error",
530
+ "jsonc/no-floating-decimal": "error",
531
+ "jsonc/no-hexadecimal-numeric-literals": "error",
532
+ "jsonc/no-infinity": "error",
533
+ "jsonc/no-multi-str": "error",
534
+ "jsonc/no-nan": "error",
535
+ "jsonc/no-number-props": "error",
536
+ "jsonc/no-numeric-separators": "error",
537
+ "jsonc/no-octal": "error",
516
538
  "jsonc/no-octal-escape": "error",
539
+ "jsonc/no-octal-numeric-literals": "error",
540
+ "jsonc/no-parenthesized": "error",
541
+ "jsonc/no-plus-sign": "error",
542
+ "jsonc/no-regexp-literals": "error",
543
+ "jsonc/no-sparse-arrays": "error",
544
+ "jsonc/no-template-literals": "error",
545
+ "jsonc/no-undefined-value": "error",
546
+ "jsonc/no-unicode-codepoint-escapes": "error",
547
+ "jsonc/no-useless-escape": "error",
517
548
  "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
518
549
  "jsonc/object-curly-spacing": ["error", "always"],
519
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }]
550
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
551
+ "jsonc/quote-props": "error",
552
+ "jsonc/quotes": "error",
553
+ "jsonc/space-unary-ops": "error",
554
+ "jsonc/valid-json-number": "error",
555
+ "jsonc/vue-custom-block/no-parsing-error": "error"
520
556
  }
521
557
  }
522
558
  ];
@@ -547,21 +583,19 @@ function markdown(options = {}) {
547
583
  }
548
584
  },
549
585
  plugins: {
550
- ts: import_eslint_plugin.default
586
+ ts: import_eslint_plugin2.default
551
587
  },
552
588
  rules: {
553
- ...import_eslint_plugin_markdown.default.configs.recommended.overrides[1].rules,
554
589
  "antfu/no-cjs-exports": OFF,
555
590
  "antfu/no-ts-export-equal": OFF,
556
- "import/no-unresolved": OFF,
591
+ "eol-last": OFF,
557
592
  "no-alert": OFF,
558
593
  "no-console": OFF,
559
- "no-restricted-imports": OFF,
560
594
  "no-undef": OFF,
561
595
  "no-unused-expressions": OFF,
562
596
  "no-unused-vars": OFF,
563
597
  "node/prefer-global/process": OFF,
564
- "ts/comma-dangle": OFF,
598
+ "style/comma-dangle": OFF,
565
599
  "ts/consistent-type-imports": OFF,
566
600
  "ts/no-namespace": OFF,
567
601
  "ts/no-redeclare": OFF,
@@ -569,6 +603,7 @@ function markdown(options = {}) {
569
603
  "ts/no-unused-vars": OFF,
570
604
  "ts/no-use-before-define": OFF,
571
605
  "ts/no-var-requires": OFF,
606
+ "unicode-bom": "off",
572
607
  "unused-imports/no-unused-imports": OFF,
573
608
  "unused-imports/no-unused-vars": OFF
574
609
  }
@@ -806,30 +841,24 @@ var sortTsconfig = [
806
841
  ];
807
842
 
808
843
  // src/configs/stylistic.ts
809
- var import_metadata = require("@eslint-stylistic/metadata");
810
- var tsPackage = import_metadata.packages.find((i) => i.shortId === "ts");
811
- var javascriptStylistic = [
844
+ var stylistic = [
812
845
  {
813
846
  plugins: {
814
- style: import_eslint_plugin_js.default
847
+ style: import_eslint_plugin.default
815
848
  },
816
849
  rules: {
817
850
  "antfu/consistent-list-newline": "error",
818
851
  "antfu/if-newline": "error",
819
- "comma-dangle": ["error", "always-multiline"],
820
852
  "curly": ["error", "multi-or-nest", "consistent"],
821
- "quotes": ["error", "single"],
822
- "semi": ["error", "never"],
823
853
  "style/array-bracket-spacing": ["error", "never"],
824
854
  "style/arrow-spacing": ["error", { after: true, before: true }],
825
855
  "style/block-spacing": ["error", "always"],
826
856
  "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
857
+ "style/comma-dangle": ["error", "always-multiline"],
827
858
  "style/comma-spacing": ["error", { after: true, before: false }],
828
859
  "style/comma-style": ["error", "last"],
829
860
  "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
830
861
  "style/dot-location": ["error", "property"],
831
- "style/func-call-spacing": OFF,
832
- "style/generator-star-spacing": OFF,
833
862
  "style/indent": ["error", 4, {
834
863
  ArrayExpression: 1,
835
864
  CallExpression: { arguments: 1 },
@@ -871,6 +900,7 @@ var javascriptStylistic = [
871
900
  "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
872
901
  "style/keyword-spacing": ["error", { after: true, before: true }],
873
902
  "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
903
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
874
904
  "style/multiline-ternary": ["error", "always-multiline"],
875
905
  "style/no-mixed-spaces-and-tabs": "error",
876
906
  "style/no-multi-spaces": "error",
@@ -883,7 +913,9 @@ var javascriptStylistic = [
883
913
  "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
884
914
  "style/operator-linebreak": ["error", "before"],
885
915
  "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
916
+ "style/quotes": ["error", "single"],
886
917
  "style/rest-spread-spacing": ["error", "never"],
918
+ "style/semi": ["error", "never"],
887
919
  "style/semi-spacing": ["error", { after: true, before: false }],
888
920
  "style/space-before-blocks": ["error", "always"],
889
921
  "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
@@ -903,53 +935,11 @@ var javascriptStylistic = [
903
935
  }],
904
936
  "style/template-curly-spacing": "error",
905
937
  "style/template-tag-spacing": ["error", "never"],
938
+ "style/type-annotation-spacing": ["error", {}],
906
939
  "style/yield-star-spacing": ["error", "both"]
907
940
  }
908
941
  }
909
942
  ];
910
- var typescriptStylistic = [
911
- {
912
- plugins: {
913
- "style-ts": import_eslint_plugin_ts.default,
914
- "ts": import_eslint_plugin.default
915
- },
916
- rules: {
917
- ...stylisticJsToTS(javascriptStylistic[0].rules),
918
- "comma-dangle": OFF,
919
- "quotes": OFF,
920
- "semi": OFF,
921
- "style-ts/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
922
- "style-ts/type-annotation-spacing": ["error", {}],
923
- "ts/comma-dangle": ["error", "always-multiline"],
924
- "ts/quotes": ["error", "single"],
925
- "ts/semi": ["error", "never"]
926
- }
927
- }
928
- ];
929
- function stylisticJsToTS(input) {
930
- return {
931
- // turn off all stylistic rules from style
932
- ...Object.fromEntries(
933
- Object.entries(input).map(([key]) => {
934
- if (!key.startsWith("style/"))
935
- return null;
936
- const basename = key.replace("style/", "");
937
- if (tsPackage.rules.find((i) => i.name === basename))
938
- return [key, OFF];
939
- return null;
940
- }).filter(Boolean)
941
- ),
942
- // rename all stylistic rules from style to style/ts
943
- ...Object.fromEntries(
944
- Object.entries(input).map(([key, value]) => {
945
- if (!key.startsWith("style/"))
946
- return null;
947
- const basename = key.replace("style/", "");
948
- return tsPackage.rules.find((i) => i.name === basename) ? [`style-ts/${basename}`, value] : null;
949
- }).filter(Boolean)
950
- )
951
- };
952
- }
953
943
 
954
944
  // src/configs/typescript.ts
955
945
  var import_node_process = __toESM(require("process"), 1);
@@ -967,6 +957,30 @@ function renameRules(rules, from, to) {
967
957
  })
968
958
  );
969
959
  }
960
+ var rulesOn = /* @__PURE__ */ new Set();
961
+ var rulesOff = /* @__PURE__ */ new Set();
962
+ function recordRulesStateConfigs(configs) {
963
+ for (const config of configs)
964
+ recordRulesState(config.rules ?? {});
965
+ return configs;
966
+ }
967
+ function recordRulesState(rules) {
968
+ for (const [key, value] of Object.entries(rules ?? {})) {
969
+ const firstValue = Array.isArray(value) ? value[0] : value;
970
+ if (firstValue == null)
971
+ continue;
972
+ if (firstValue === "off" || firstValue === 0)
973
+ rulesOff.add(key);
974
+ else
975
+ rulesOn.add(key);
976
+ }
977
+ return rules;
978
+ }
979
+ function warnUnnecessaryOffRules() {
980
+ const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
981
+ for (const off of unnecessaryOffRules)
982
+ console.warn(`[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`);
983
+ }
970
984
 
971
985
  // src/configs/typescript.ts
972
986
  function typescript(options) {
@@ -989,16 +1003,16 @@ function typescript(options) {
989
1003
  plugins: {
990
1004
  antfu: import_eslint_plugin_antfu.default,
991
1005
  import: import_eslint_plugin_i.default,
992
- ts: import_eslint_plugin.default
1006
+ ts: import_eslint_plugin2.default
993
1007
  },
994
1008
  rules: {
995
1009
  ...renameRules(
996
- import_eslint_plugin.default.configs["eslint-recommended"].overrides[0].rules,
1010
+ import_eslint_plugin2.default.configs["eslint-recommended"].overrides[0].rules,
997
1011
  "@typescript-eslint/",
998
1012
  "ts/"
999
1013
  ),
1000
1014
  ...renameRules(
1001
- import_eslint_plugin.default.configs.strict.rules,
1015
+ import_eslint_plugin2.default.configs.strict.rules,
1002
1016
  "@typescript-eslint/",
1003
1017
  "ts/"
1004
1018
  ),
@@ -1015,18 +1029,10 @@ function typescript(options) {
1015
1029
  "no-use-before-define": OFF,
1016
1030
  "no-useless-constructor": OFF,
1017
1031
  "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1018
- "ts/ban-ts-ignore": OFF,
1019
- "ts/consistent-indexed-object-style": OFF,
1020
1032
  "ts/consistent-type-definitions": ["error", "interface"],
1021
1033
  "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1022
- "ts/explicit-function-return-type": OFF,
1023
- "ts/explicit-member-accessibility": OFF,
1024
- "ts/explicit-module-boundary-types": OFF,
1025
- "ts/naming-convention": OFF,
1026
1034
  "ts/no-dupe-class-members": "error",
1027
1035
  "ts/no-dynamic-delete": OFF,
1028
- "ts/no-empty-function": OFF,
1029
- "ts/no-empty-interface": OFF,
1030
1036
  "ts/no-explicit-any": OFF,
1031
1037
  "ts/no-extra-parens": ["error", "functions"],
1032
1038
  "ts/no-invalid-this": "error",
@@ -1037,7 +1043,6 @@ function typescript(options) {
1037
1043
  "ts/no-require-imports": "error",
1038
1044
  "ts/no-unused-vars": OFF,
1039
1045
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1040
- "ts/parameter-properties": OFF,
1041
1046
  "ts/prefer-ts-expect-error": "error",
1042
1047
  "ts/triple-slash-reference": OFF,
1043
1048
  "ts/unified-signatures": OFF
@@ -1088,7 +1093,7 @@ function typescriptWithLanguageServer(options) {
1088
1093
  }
1089
1094
  },
1090
1095
  plugins: {
1091
- ts: import_eslint_plugin.default
1096
+ ts: import_eslint_plugin2.default
1092
1097
  },
1093
1098
  rules: {
1094
1099
  "dot-notation": OFF,
@@ -1295,11 +1300,25 @@ var yml = [
1295
1300
  yml: import_eslint_plugin_yml.default
1296
1301
  },
1297
1302
  rules: {
1298
- ...import_eslint_plugin_yml.default.configs.standard.rules,
1299
1303
  "style/spaced-comment": OFF,
1300
- "yml/no-empty-document": OFF,
1301
- "yml/no-empty-mapping-value": OFF,
1302
- "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }]
1304
+ "yml/block-mapping": "error",
1305
+ "yml/block-mapping-question-indicator-newline": "error",
1306
+ "yml/block-sequence": "error",
1307
+ "yml/block-sequence-hyphen-indicator-newline": "error",
1308
+ "yml/flow-mapping-curly-newline": "error",
1309
+ "yml/flow-mapping-curly-spacing": "error",
1310
+ "yml/flow-sequence-bracket-newline": "error",
1311
+ "yml/flow-sequence-bracket-spacing": "error",
1312
+ "yml/indent": ["error", 2],
1313
+ "yml/key-spacing": "error",
1314
+ "yml/no-empty-key": "error",
1315
+ "yml/no-empty-sequence-entry": "error",
1316
+ "yml/no-irregular-whitespace": "error",
1317
+ "yml/no-tab-indent": "error",
1318
+ "yml/plain-scalar": "error",
1319
+ "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }],
1320
+ "yml/spaced-comment": "error",
1321
+ "yml/vue-custom-block/no-parsing-error": "error"
1303
1322
  }
1304
1323
  }
1305
1324
  ];
@@ -1357,8 +1376,6 @@ function lincy(options = {}, ...userConfigs) {
1357
1376
  const componentExts = [];
1358
1377
  if (enableVue)
1359
1378
  componentExts.push("vue");
1360
- if (enableStylistic)
1361
- configs.push(javascriptStylistic);
1362
1379
  if (enableTypeScript) {
1363
1380
  configs.push(typescript({ componentExts }));
1364
1381
  if (typeof enableTypeScript !== "boolean") {
@@ -1367,9 +1384,9 @@ function lincy(options = {}, ...userConfigs) {
1367
1384
  componentExts
1368
1385
  }));
1369
1386
  }
1370
- if (enableStylistic)
1371
- configs.push(typescriptStylistic);
1372
1387
  }
1388
+ if (enableStylistic)
1389
+ configs.push(stylistic);
1373
1390
  if (options.test ?? true)
1374
1391
  configs.push(test({ isInEditor }));
1375
1392
  if (enableVue)
@@ -1392,10 +1409,11 @@ function lincy(options = {}, ...userConfigs) {
1392
1409
  }, {});
1393
1410
  if (Object.keys(fusedConfig).length)
1394
1411
  configs.push([fusedConfig]);
1395
- return combine(
1412
+ const merged = combine(
1396
1413
  ...configs,
1397
1414
  ...userConfigs
1398
1415
  );
1416
+ return merged;
1399
1417
  }
1400
1418
 
1401
1419
  // src/index.ts
@@ -1407,7 +1425,6 @@ var src_default = lincy;
1407
1425
  ignores,
1408
1426
  imports,
1409
1427
  javascript,
1410
- javascriptStylistic,
1411
1428
  jsdoc,
1412
1429
  jsonc,
1413
1430
  lincy,
@@ -1425,21 +1442,23 @@ var src_default = lincy;
1425
1442
  pluginMarkdown,
1426
1443
  pluginNoOnlyTests,
1427
1444
  pluginNode,
1428
- pluginStylisticJs,
1429
- pluginStylisticTs,
1445
+ pluginStylistic,
1430
1446
  pluginTs,
1431
1447
  pluginUnicorn,
1432
1448
  pluginUnusedImports,
1433
1449
  pluginVue,
1434
1450
  pluginYml,
1451
+ recordRulesState,
1452
+ recordRulesStateConfigs,
1435
1453
  renameRules,
1436
1454
  sortPackageJson,
1437
1455
  sortTsconfig,
1456
+ stylistic,
1438
1457
  test,
1439
1458
  typescript,
1440
- typescriptStylistic,
1441
1459
  typescriptWithLanguageServer,
1442
1460
  unicorn,
1443
1461
  vue,
1462
+ warnUnnecessaryOffRules,
1444
1463
  yml
1445
1464
  });
package/dist/index.d.cts CHANGED
@@ -7,8 +7,7 @@ export { default as pluginJsdoc } from 'eslint-plugin-jsdoc';
7
7
  export { default as pluginJsonc } from 'eslint-plugin-jsonc';
8
8
  export { default as pluginMarkdown } from 'eslint-plugin-markdown';
9
9
  export { default as pluginNode } from 'eslint-plugin-n';
10
- export { default as pluginStylisticJs } from '@stylistic/eslint-plugin-js';
11
- export { default as pluginStylisticTs } from '@stylistic/eslint-plugin-ts';
10
+ export { default as pluginStylistic } from '@stylistic/eslint-plugin';
12
11
  export { default as pluginTs } from '@typescript-eslint/eslint-plugin';
13
12
  export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
14
13
  export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
@@ -134,8 +133,7 @@ declare const sortPackageJson: FlatESLintConfigItem[];
134
133
  */
135
134
  declare const sortTsconfig: FlatESLintConfigItem[];
136
135
 
137
- declare const javascriptStylistic: FlatESLintConfigItem[];
138
- declare const typescriptStylistic: FlatESLintConfigItem[];
136
+ declare const stylistic: FlatESLintConfigItem[];
139
137
 
140
138
  declare function typescript(options?: OptionsComponentExts): FlatESLintConfigItem[];
141
139
  declare function typescriptWithLanguageServer(options: OptionsTypeScriptWithLanguageServer & OptionsComponentExts): FlatESLintConfigItem[];
@@ -155,5 +153,8 @@ declare function combine(...configs: (FlatESLintConfigItem | FlatESLintConfigIte
155
153
  declare function renameRules(rules: Record<string, any>, from: string, to: string): {
156
154
  [k: string]: any;
157
155
  };
156
+ declare function recordRulesStateConfigs(configs: FlatESLintConfigItem[]): FlatESLintConfigItem[];
157
+ declare function recordRulesState(rules: FlatESLintConfigItem['rules']): FlatESLintConfigItem['rules'];
158
+ declare function warnUnnecessaryOffRules(): void;
158
159
 
159
- export { OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIsInEditor, OptionsTypeScriptWithLanguageServer, combine, comments, lincy as default, ignores, imports, javascript, javascriptStylistic, jsdoc, jsonc, lincy, markdown, node, renameRules, sortPackageJson, sortTsconfig, test, typescript, typescriptStylistic, typescriptWithLanguageServer, unicorn, vue, yml };
160
+ export { OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIsInEditor, OptionsTypeScriptWithLanguageServer, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, recordRulesState, recordRulesStateConfigs, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, typescriptWithLanguageServer, unicorn, vue, warnUnnecessaryOffRules, yml };
package/dist/index.d.ts CHANGED
@@ -7,8 +7,7 @@ export { default as pluginJsdoc } from 'eslint-plugin-jsdoc';
7
7
  export { default as pluginJsonc } from 'eslint-plugin-jsonc';
8
8
  export { default as pluginMarkdown } from 'eslint-plugin-markdown';
9
9
  export { default as pluginNode } from 'eslint-plugin-n';
10
- export { default as pluginStylisticJs } from '@stylistic/eslint-plugin-js';
11
- export { default as pluginStylisticTs } from '@stylistic/eslint-plugin-ts';
10
+ export { default as pluginStylistic } from '@stylistic/eslint-plugin';
12
11
  export { default as pluginTs } from '@typescript-eslint/eslint-plugin';
13
12
  export { default as pluginUnicorn } from 'eslint-plugin-unicorn';
14
13
  export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports';
@@ -134,8 +133,7 @@ declare const sortPackageJson: FlatESLintConfigItem[];
134
133
  */
135
134
  declare const sortTsconfig: FlatESLintConfigItem[];
136
135
 
137
- declare const javascriptStylistic: FlatESLintConfigItem[];
138
- declare const typescriptStylistic: FlatESLintConfigItem[];
136
+ declare const stylistic: FlatESLintConfigItem[];
139
137
 
140
138
  declare function typescript(options?: OptionsComponentExts): FlatESLintConfigItem[];
141
139
  declare function typescriptWithLanguageServer(options: OptionsTypeScriptWithLanguageServer & OptionsComponentExts): FlatESLintConfigItem[];
@@ -155,5 +153,8 @@ declare function combine(...configs: (FlatESLintConfigItem | FlatESLintConfigIte
155
153
  declare function renameRules(rules: Record<string, any>, from: string, to: string): {
156
154
  [k: string]: any;
157
155
  };
156
+ declare function recordRulesStateConfigs(configs: FlatESLintConfigItem[]): FlatESLintConfigItem[];
157
+ declare function recordRulesState(rules: FlatESLintConfigItem['rules']): FlatESLintConfigItem['rules'];
158
+ declare function warnUnnecessaryOffRules(): void;
158
159
 
159
- export { OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIsInEditor, OptionsTypeScriptWithLanguageServer, combine, comments, lincy as default, ignores, imports, javascript, javascriptStylistic, jsdoc, jsonc, lincy, markdown, node, renameRules, sortPackageJson, sortTsconfig, test, typescript, typescriptStylistic, typescriptWithLanguageServer, unicorn, vue, yml };
160
+ export { OptionsComponentExts, OptionsConfig, OptionsHasTypeScript, OptionsIsInEditor, OptionsTypeScriptWithLanguageServer, combine, comments, lincy as default, ignores, imports, javascript, jsdoc, jsonc, lincy, markdown, node, recordRulesState, recordRulesStateConfigs, renameRules, sortPackageJson, sortTsconfig, stylistic, test, typescript, typescriptWithLanguageServer, unicorn, vue, warnUnnecessaryOffRules, yml };
package/dist/index.js CHANGED
@@ -61,9 +61,6 @@ function searchPackageJSON(dir) {
61
61
  // src/factory.ts
62
62
  import gitignore from "eslint-config-flat-gitignore";
63
63
 
64
- // src/flags.ts
65
- var OFF = 0;
66
-
67
64
  // src/plugins.ts
68
65
  import { default as default2 } from "eslint-plugin-antfu";
69
66
  import { default as default3 } from "eslint-plugin-eslint-comments";
@@ -72,18 +69,17 @@ import { default as default5 } from "eslint-plugin-jsdoc";
72
69
  import { default as default6 } from "eslint-plugin-jsonc";
73
70
  import { default as default7 } from "eslint-plugin-markdown";
74
71
  import { default as default8 } from "eslint-plugin-n";
75
- import { default as default9 } from "@stylistic/eslint-plugin-js";
76
- import { default as default10 } from "@stylistic/eslint-plugin-ts";
77
- import { default as default11 } from "@typescript-eslint/eslint-plugin";
78
- import { default as default12 } from "eslint-plugin-unicorn";
79
- import { default as default13 } from "eslint-plugin-unused-imports";
80
- import { default as default14 } from "eslint-plugin-vue";
81
- import { default as default15 } from "eslint-plugin-yml";
82
- import { default as default16 } from "eslint-plugin-no-only-tests";
83
- import { default as default17 } from "@typescript-eslint/parser";
84
- import { default as default18 } from "vue-eslint-parser";
85
- import { default as default19 } from "yaml-eslint-parser";
86
- import { default as default20 } from "jsonc-eslint-parser";
72
+ import { default as default9 } from "@stylistic/eslint-plugin";
73
+ import { default as default10 } from "@typescript-eslint/eslint-plugin";
74
+ import { default as default11 } from "eslint-plugin-unicorn";
75
+ import { default as default12 } from "eslint-plugin-unused-imports";
76
+ import { default as default13 } from "eslint-plugin-vue";
77
+ import { default as default14 } from "eslint-plugin-yml";
78
+ import { default as default15 } from "eslint-plugin-no-only-tests";
79
+ import { default as default16 } from "@typescript-eslint/parser";
80
+ import { default as default17 } from "vue-eslint-parser";
81
+ import { default as default18 } from "yaml-eslint-parser";
82
+ import { default as default19 } from "jsonc-eslint-parser";
87
83
 
88
84
  // src/configs/comments.ts
89
85
  var comments = [
@@ -92,8 +88,10 @@ var comments = [
92
88
  "eslint-comments": default3
93
89
  },
94
90
  rules: {
95
- ...default3.configs.recommended.rules,
96
- "eslint-comments/disable-enable-pair": OFF
91
+ "eslint-comments/no-aggregating-enable": "error",
92
+ "eslint-comments/no-duplicate-disable": "error",
93
+ "eslint-comments/no-unlimited-disable": "error",
94
+ "eslint-comments/no-unused-enable": "error"
97
95
  }
98
96
  }
99
97
  ];
@@ -166,6 +164,11 @@ var imports = [
166
164
 
167
165
  // src/configs/javascript.ts
168
166
  import globals from "globals";
167
+
168
+ // src/flags.ts
169
+ var OFF = 0;
170
+
171
+ // src/configs/javascript.ts
169
172
  function javascript(options = {}) {
170
173
  return [
171
174
  {
@@ -190,7 +193,7 @@ function javascript(options = {}) {
190
193
  },
191
194
  plugins: {
192
195
  "antfu": default2,
193
- "unused-imports": default13
196
+ "unused-imports": default12
194
197
  },
195
198
  rules: {
196
199
  "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
@@ -399,19 +402,25 @@ var jsdoc = [
399
402
  jsdoc: default5
400
403
  },
401
404
  rules: {
402
- ...default5.configs["flat/recommended-typescript"].rules,
403
- "jsdoc/check-tag-names": OFF,
404
- "jsdoc/check-values": OFF,
405
- "jsdoc/no-undefined-types": OFF,
406
- "jsdoc/require-jsdoc": OFF,
407
- "jsdoc/require-param": OFF,
408
- "jsdoc/require-param-description": OFF,
409
- "jsdoc/require-param-type": OFF,
410
- "jsdoc/require-returns": OFF,
411
- "jsdoc/require-returns-type": OFF,
412
- "jsdoc/require-throws": OFF,
413
- "jsdoc/require-yields": OFF,
414
- "jsdoc/tag-lines": OFF
405
+ "jsdoc/check-access": "warn",
406
+ "jsdoc/check-alignment": "warn",
407
+ "jsdoc/check-param-names": "warn",
408
+ "jsdoc/check-property-names": "warn",
409
+ "jsdoc/check-types": "warn",
410
+ "jsdoc/empty-tags": "warn",
411
+ "jsdoc/implements-on-classes": "warn",
412
+ "jsdoc/multiline-blocks": "warn",
413
+ "jsdoc/no-defaults": "warn",
414
+ "jsdoc/no-multi-asterisks": "warn",
415
+ "jsdoc/no-types": "warn",
416
+ "jsdoc/require-param-name": "warn",
417
+ "jsdoc/require-property": "warn",
418
+ "jsdoc/require-property-description": "warn",
419
+ "jsdoc/require-property-name": "warn",
420
+ "jsdoc/require-returns-check": "warn",
421
+ "jsdoc/require-returns-description": "warn",
422
+ "jsdoc/require-yields-check": "warn",
423
+ "jsdoc/valid-types": "warn"
415
424
  }
416
425
  }
417
426
  ];
@@ -421,22 +430,48 @@ var jsonc = [
421
430
  {
422
431
  files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
423
432
  languageOptions: {
424
- parser: default20
433
+ parser: default19
425
434
  },
426
435
  plugins: {
427
436
  jsonc: default6
428
437
  },
429
438
  rules: {
430
- ...default6.configs["recommended-with-jsonc"].rules,
431
439
  "jsonc/array-bracket-spacing": ["error", "never"],
432
440
  "jsonc/comma-dangle": ["error", "never"],
433
441
  "jsonc/comma-style": ["error", "last"],
434
442
  "jsonc/indent": ["error", 2],
435
443
  "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
444
+ "jsonc/no-bigint-literals": "error",
445
+ "jsonc/no-binary-expression": "error",
446
+ "jsonc/no-binary-numeric-literals": "error",
447
+ "jsonc/no-dupe-keys": "error",
448
+ "jsonc/no-escape-sequence-in-identifier": "error",
449
+ "jsonc/no-floating-decimal": "error",
450
+ "jsonc/no-hexadecimal-numeric-literals": "error",
451
+ "jsonc/no-infinity": "error",
452
+ "jsonc/no-multi-str": "error",
453
+ "jsonc/no-nan": "error",
454
+ "jsonc/no-number-props": "error",
455
+ "jsonc/no-numeric-separators": "error",
456
+ "jsonc/no-octal": "error",
436
457
  "jsonc/no-octal-escape": "error",
458
+ "jsonc/no-octal-numeric-literals": "error",
459
+ "jsonc/no-parenthesized": "error",
460
+ "jsonc/no-plus-sign": "error",
461
+ "jsonc/no-regexp-literals": "error",
462
+ "jsonc/no-sparse-arrays": "error",
463
+ "jsonc/no-template-literals": "error",
464
+ "jsonc/no-undefined-value": "error",
465
+ "jsonc/no-unicode-codepoint-escapes": "error",
466
+ "jsonc/no-useless-escape": "error",
437
467
  "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
438
468
  "jsonc/object-curly-spacing": ["error", "always"],
439
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }]
469
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
470
+ "jsonc/quote-props": "error",
471
+ "jsonc/quotes": "error",
472
+ "jsonc/space-unary-ops": "error",
473
+ "jsonc/valid-json-number": "error",
474
+ "jsonc/vue-custom-block/no-parsing-error": "error"
440
475
  }
441
476
  }
442
477
  ];
@@ -467,21 +502,19 @@ function markdown(options = {}) {
467
502
  }
468
503
  },
469
504
  plugins: {
470
- ts: default11
505
+ ts: default10
471
506
  },
472
507
  rules: {
473
- ...default7.configs.recommended.overrides[1].rules,
474
508
  "antfu/no-cjs-exports": OFF,
475
509
  "antfu/no-ts-export-equal": OFF,
476
- "import/no-unresolved": OFF,
510
+ "eol-last": OFF,
477
511
  "no-alert": OFF,
478
512
  "no-console": OFF,
479
- "no-restricted-imports": OFF,
480
513
  "no-undef": OFF,
481
514
  "no-unused-expressions": OFF,
482
515
  "no-unused-vars": OFF,
483
516
  "node/prefer-global/process": OFF,
484
- "ts/comma-dangle": OFF,
517
+ "style/comma-dangle": OFF,
485
518
  "ts/consistent-type-imports": OFF,
486
519
  "ts/no-namespace": OFF,
487
520
  "ts/no-redeclare": OFF,
@@ -489,6 +522,7 @@ function markdown(options = {}) {
489
522
  "ts/no-unused-vars": OFF,
490
523
  "ts/no-use-before-define": OFF,
491
524
  "ts/no-var-requires": OFF,
525
+ "unicode-bom": "off",
492
526
  "unused-imports/no-unused-imports": OFF,
493
527
  "unused-imports/no-unused-vars": OFF
494
528
  }
@@ -726,9 +760,7 @@ var sortTsconfig = [
726
760
  ];
727
761
 
728
762
  // src/configs/stylistic.ts
729
- import { packages } from "@eslint-stylistic/metadata";
730
- var tsPackage = packages.find((i) => i.shortId === "ts");
731
- var javascriptStylistic = [
763
+ var stylistic = [
732
764
  {
733
765
  plugins: {
734
766
  style: default9
@@ -736,20 +768,16 @@ var javascriptStylistic = [
736
768
  rules: {
737
769
  "antfu/consistent-list-newline": "error",
738
770
  "antfu/if-newline": "error",
739
- "comma-dangle": ["error", "always-multiline"],
740
771
  "curly": ["error", "multi-or-nest", "consistent"],
741
- "quotes": ["error", "single"],
742
- "semi": ["error", "never"],
743
772
  "style/array-bracket-spacing": ["error", "never"],
744
773
  "style/arrow-spacing": ["error", { after: true, before: true }],
745
774
  "style/block-spacing": ["error", "always"],
746
775
  "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
776
+ "style/comma-dangle": ["error", "always-multiline"],
747
777
  "style/comma-spacing": ["error", { after: true, before: false }],
748
778
  "style/comma-style": ["error", "last"],
749
779
  "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
750
780
  "style/dot-location": ["error", "property"],
751
- "style/func-call-spacing": OFF,
752
- "style/generator-star-spacing": OFF,
753
781
  "style/indent": ["error", 4, {
754
782
  ArrayExpression: 1,
755
783
  CallExpression: { arguments: 1 },
@@ -791,6 +819,7 @@ var javascriptStylistic = [
791
819
  "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
792
820
  "style/keyword-spacing": ["error", { after: true, before: true }],
793
821
  "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
822
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
794
823
  "style/multiline-ternary": ["error", "always-multiline"],
795
824
  "style/no-mixed-spaces-and-tabs": "error",
796
825
  "style/no-multi-spaces": "error",
@@ -803,7 +832,9 @@ var javascriptStylistic = [
803
832
  "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
804
833
  "style/operator-linebreak": ["error", "before"],
805
834
  "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
835
+ "style/quotes": ["error", "single"],
806
836
  "style/rest-spread-spacing": ["error", "never"],
837
+ "style/semi": ["error", "never"],
807
838
  "style/semi-spacing": ["error", { after: true, before: false }],
808
839
  "style/space-before-blocks": ["error", "always"],
809
840
  "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
@@ -823,53 +854,11 @@ var javascriptStylistic = [
823
854
  }],
824
855
  "style/template-curly-spacing": "error",
825
856
  "style/template-tag-spacing": ["error", "never"],
857
+ "style/type-annotation-spacing": ["error", {}],
826
858
  "style/yield-star-spacing": ["error", "both"]
827
859
  }
828
860
  }
829
861
  ];
830
- var typescriptStylistic = [
831
- {
832
- plugins: {
833
- "style-ts": default10,
834
- "ts": default11
835
- },
836
- rules: {
837
- ...stylisticJsToTS(javascriptStylistic[0].rules),
838
- "comma-dangle": OFF,
839
- "quotes": OFF,
840
- "semi": OFF,
841
- "style-ts/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
842
- "style-ts/type-annotation-spacing": ["error", {}],
843
- "ts/comma-dangle": ["error", "always-multiline"],
844
- "ts/quotes": ["error", "single"],
845
- "ts/semi": ["error", "never"]
846
- }
847
- }
848
- ];
849
- function stylisticJsToTS(input) {
850
- return {
851
- // turn off all stylistic rules from style
852
- ...Object.fromEntries(
853
- Object.entries(input).map(([key]) => {
854
- if (!key.startsWith("style/"))
855
- return null;
856
- const basename = key.replace("style/", "");
857
- if (tsPackage.rules.find((i) => i.name === basename))
858
- return [key, OFF];
859
- return null;
860
- }).filter(Boolean)
861
- ),
862
- // rename all stylistic rules from style to style/ts
863
- ...Object.fromEntries(
864
- Object.entries(input).map(([key, value]) => {
865
- if (!key.startsWith("style/"))
866
- return null;
867
- const basename = key.replace("style/", "");
868
- return tsPackage.rules.find((i) => i.name === basename) ? [`style-ts/${basename}`, value] : null;
869
- }).filter(Boolean)
870
- )
871
- };
872
- }
873
862
 
874
863
  // src/configs/typescript.ts
875
864
  import process from "process";
@@ -887,6 +876,30 @@ function renameRules(rules, from, to) {
887
876
  })
888
877
  );
889
878
  }
879
+ var rulesOn = /* @__PURE__ */ new Set();
880
+ var rulesOff = /* @__PURE__ */ new Set();
881
+ function recordRulesStateConfigs(configs) {
882
+ for (const config of configs)
883
+ recordRulesState(config.rules ?? {});
884
+ return configs;
885
+ }
886
+ function recordRulesState(rules) {
887
+ for (const [key, value] of Object.entries(rules ?? {})) {
888
+ const firstValue = Array.isArray(value) ? value[0] : value;
889
+ if (firstValue == null)
890
+ continue;
891
+ if (firstValue === "off" || firstValue === 0)
892
+ rulesOff.add(key);
893
+ else
894
+ rulesOn.add(key);
895
+ }
896
+ return rules;
897
+ }
898
+ function warnUnnecessaryOffRules() {
899
+ const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
900
+ for (const off of unnecessaryOffRules)
901
+ console.warn(`[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`);
902
+ }
890
903
 
891
904
  // src/configs/typescript.ts
892
905
  function typescript(options) {
@@ -901,7 +914,7 @@ function typescript(options) {
901
914
  ...componentExts.map((ext) => `**/*.${ext}`)
902
915
  ],
903
916
  languageOptions: {
904
- parser: default17,
917
+ parser: default16,
905
918
  parserOptions: {
906
919
  sourceType: "module"
907
920
  }
@@ -909,16 +922,16 @@ function typescript(options) {
909
922
  plugins: {
910
923
  antfu: default2,
911
924
  import: default4,
912
- ts: default11
925
+ ts: default10
913
926
  },
914
927
  rules: {
915
928
  ...renameRules(
916
- default11.configs["eslint-recommended"].overrides[0].rules,
929
+ default10.configs["eslint-recommended"].overrides[0].rules,
917
930
  "@typescript-eslint/",
918
931
  "ts/"
919
932
  ),
920
933
  ...renameRules(
921
- default11.configs.strict.rules,
934
+ default10.configs.strict.rules,
922
935
  "@typescript-eslint/",
923
936
  "ts/"
924
937
  ),
@@ -935,18 +948,10 @@ function typescript(options) {
935
948
  "no-use-before-define": OFF,
936
949
  "no-useless-constructor": OFF,
937
950
  "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
938
- "ts/ban-ts-ignore": OFF,
939
- "ts/consistent-indexed-object-style": OFF,
940
951
  "ts/consistent-type-definitions": ["error", "interface"],
941
952
  "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
942
- "ts/explicit-function-return-type": OFF,
943
- "ts/explicit-member-accessibility": OFF,
944
- "ts/explicit-module-boundary-types": OFF,
945
- "ts/naming-convention": OFF,
946
953
  "ts/no-dupe-class-members": "error",
947
954
  "ts/no-dynamic-delete": OFF,
948
- "ts/no-empty-function": OFF,
949
- "ts/no-empty-interface": OFF,
950
955
  "ts/no-explicit-any": OFF,
951
956
  "ts/no-extra-parens": ["error", "functions"],
952
957
  "ts/no-invalid-this": "error",
@@ -957,7 +962,6 @@ function typescript(options) {
957
962
  "ts/no-require-imports": "error",
958
963
  "ts/no-unused-vars": OFF,
959
964
  "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
960
- "ts/parameter-properties": OFF,
961
965
  "ts/prefer-ts-expect-error": "error",
962
966
  "ts/triple-slash-reference": OFF,
963
967
  "ts/unified-signatures": OFF
@@ -1001,14 +1005,14 @@ function typescriptWithLanguageServer(options) {
1001
1005
  ],
1002
1006
  ignores: ["**/*.md/*.*"],
1003
1007
  languageOptions: {
1004
- parser: default17,
1008
+ parser: default16,
1005
1009
  parserOptions: {
1006
1010
  project: [tsconfigPath],
1007
1011
  tsconfigRootDir
1008
1012
  }
1009
1013
  },
1010
1014
  plugins: {
1011
- ts: default11
1015
+ ts: default10
1012
1016
  },
1013
1017
  rules: {
1014
1018
  "dot-notation": OFF,
@@ -1039,7 +1043,7 @@ function typescriptWithLanguageServer(options) {
1039
1043
  var unicorn = [
1040
1044
  {
1041
1045
  plugins: {
1042
- unicorn: default12
1046
+ unicorn: default11
1043
1047
  },
1044
1048
  rules: {
1045
1049
  // Pass error message when throwing errors
@@ -1084,30 +1088,30 @@ function vue(options = {}) {
1084
1088
  {
1085
1089
  files: [GLOB_VUE],
1086
1090
  languageOptions: {
1087
- parser: default18,
1091
+ parser: default17,
1088
1092
  parserOptions: {
1089
1093
  ecmaFeatures: {
1090
1094
  jsx: true
1091
1095
  },
1092
1096
  extraFileExtensions: [".vue"],
1093
- parser: options.typescript ? default17 : null,
1097
+ parser: options.typescript ? default16 : null,
1094
1098
  sourceType: "module"
1095
1099
  }
1096
1100
  },
1097
1101
  plugins: {
1098
- vue: default14
1102
+ vue: default13
1099
1103
  },
1100
- processor: default14.processors[".vue"],
1104
+ processor: default13.processors[".vue"],
1101
1105
  rules: {
1102
- ...default14.configs.base.rules,
1106
+ ...default13.configs.base.rules,
1103
1107
  ...vueVersion === "3" ? {
1104
- ...default14.configs["vue3-essential"].rules,
1105
- ...default14.configs["vue3-strongly-recommended"].rules,
1106
- ...default14.configs["vue3-recommended"].rules
1108
+ ...default13.configs["vue3-essential"].rules,
1109
+ ...default13.configs["vue3-strongly-recommended"].rules,
1110
+ ...default13.configs["vue3-recommended"].rules
1107
1111
  } : {
1108
- ...default14.configs.essential.rules,
1109
- ...default14.configs["strongly-recommended"].rules,
1110
- ...default14.configs.recommended.rules
1112
+ ...default13.configs.essential.rules,
1113
+ ...default13.configs["strongly-recommended"].rules,
1114
+ ...default13.configs.recommended.rules
1111
1115
  },
1112
1116
  "node/prefer-global/process": OFF,
1113
1117
  "vue/array-bracket-spacing": ["error", "never"],
@@ -1209,17 +1213,31 @@ var yml = [
1209
1213
  {
1210
1214
  files: [GLOB_YAML],
1211
1215
  languageOptions: {
1212
- parser: default19
1216
+ parser: default18
1213
1217
  },
1214
1218
  plugins: {
1215
- yml: default15
1219
+ yml: default14
1216
1220
  },
1217
1221
  rules: {
1218
- ...default15.configs.standard.rules,
1219
1222
  "style/spaced-comment": OFF,
1220
- "yml/no-empty-document": OFF,
1221
- "yml/no-empty-mapping-value": OFF,
1222
- "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }]
1223
+ "yml/block-mapping": "error",
1224
+ "yml/block-mapping-question-indicator-newline": "error",
1225
+ "yml/block-sequence": "error",
1226
+ "yml/block-sequence-hyphen-indicator-newline": "error",
1227
+ "yml/flow-mapping-curly-newline": "error",
1228
+ "yml/flow-mapping-curly-spacing": "error",
1229
+ "yml/flow-sequence-bracket-newline": "error",
1230
+ "yml/flow-sequence-bracket-spacing": "error",
1231
+ "yml/indent": ["error", 2],
1232
+ "yml/key-spacing": "error",
1233
+ "yml/no-empty-key": "error",
1234
+ "yml/no-empty-sequence-entry": "error",
1235
+ "yml/no-irregular-whitespace": "error",
1236
+ "yml/no-tab-indent": "error",
1237
+ "yml/plain-scalar": "error",
1238
+ "yml/quotes": ["error", { avoidEscape: false, prefer: "single" }],
1239
+ "yml/spaced-comment": "error",
1240
+ "yml/vue-custom-block/no-parsing-error": "error"
1223
1241
  }
1224
1242
  }
1225
1243
  ];
@@ -1230,7 +1248,7 @@ function test(options = {}) {
1230
1248
  {
1231
1249
  files: GLOB_TESTS,
1232
1250
  plugins: {
1233
- "no-only-tests": default16
1251
+ "no-only-tests": default15
1234
1252
  },
1235
1253
  rules: {
1236
1254
  "no-only-tests/no-only-tests": options.isInEditor ? OFF : "error"
@@ -1277,8 +1295,6 @@ function lincy(options = {}, ...userConfigs) {
1277
1295
  const componentExts = [];
1278
1296
  if (enableVue)
1279
1297
  componentExts.push("vue");
1280
- if (enableStylistic)
1281
- configs.push(javascriptStylistic);
1282
1298
  if (enableTypeScript) {
1283
1299
  configs.push(typescript({ componentExts }));
1284
1300
  if (typeof enableTypeScript !== "boolean") {
@@ -1287,9 +1303,9 @@ function lincy(options = {}, ...userConfigs) {
1287
1303
  componentExts
1288
1304
  }));
1289
1305
  }
1290
- if (enableStylistic)
1291
- configs.push(typescriptStylistic);
1292
1306
  }
1307
+ if (enableStylistic)
1308
+ configs.push(stylistic);
1293
1309
  if (options.test ?? true)
1294
1310
  configs.push(test({ isInEditor }));
1295
1311
  if (enableVue)
@@ -1312,10 +1328,11 @@ function lincy(options = {}, ...userConfigs) {
1312
1328
  }, {});
1313
1329
  if (Object.keys(fusedConfig).length)
1314
1330
  configs.push([fusedConfig]);
1315
- return combine(
1331
+ const merged = combine(
1316
1332
  ...configs,
1317
1333
  ...userConfigs
1318
1334
  );
1335
+ return merged;
1319
1336
  }
1320
1337
 
1321
1338
  // src/index.ts
@@ -1327,39 +1344,40 @@ export {
1327
1344
  ignores,
1328
1345
  imports,
1329
1346
  javascript,
1330
- javascriptStylistic,
1331
1347
  jsdoc,
1332
1348
  jsonc,
1333
1349
  lincy,
1334
1350
  markdown,
1335
1351
  node,
1336
- default20 as parserJsonc,
1337
- default17 as parserTs,
1338
- default18 as parserVue,
1339
- default19 as parserYml,
1352
+ default19 as parserJsonc,
1353
+ default16 as parserTs,
1354
+ default17 as parserVue,
1355
+ default18 as parserYml,
1340
1356
  default2 as pluginAntfu,
1341
1357
  default3 as pluginComments,
1342
1358
  default4 as pluginImport,
1343
1359
  default5 as pluginJsdoc,
1344
1360
  default6 as pluginJsonc,
1345
1361
  default7 as pluginMarkdown,
1346
- default16 as pluginNoOnlyTests,
1362
+ default15 as pluginNoOnlyTests,
1347
1363
  default8 as pluginNode,
1348
- default9 as pluginStylisticJs,
1349
- default10 as pluginStylisticTs,
1350
- default11 as pluginTs,
1351
- default12 as pluginUnicorn,
1352
- default13 as pluginUnusedImports,
1353
- default14 as pluginVue,
1354
- default15 as pluginYml,
1364
+ default9 as pluginStylistic,
1365
+ default10 as pluginTs,
1366
+ default11 as pluginUnicorn,
1367
+ default12 as pluginUnusedImports,
1368
+ default13 as pluginVue,
1369
+ default14 as pluginYml,
1370
+ recordRulesState,
1371
+ recordRulesStateConfigs,
1355
1372
  renameRules,
1356
1373
  sortPackageJson,
1357
1374
  sortTsconfig,
1375
+ stylistic,
1358
1376
  test,
1359
1377
  typescript,
1360
- typescriptStylistic,
1361
1378
  typescriptWithLanguageServer,
1362
1379
  unicorn,
1363
1380
  vue,
1381
+ warnUnnecessaryOffRules,
1364
1382
  yml
1365
1383
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lincy/eslint-config",
3
3
  "type": "module",
4
- "version": "3.0.11",
4
+ "version": "3.1.0",
5
5
  "packageManager": "pnpm@8.7.6",
6
6
  "description": "LinCenYing's ESLint config",
7
7
  "author": "LinCenYing <lincenying@gmail.com> (https://github.com/lincenying/)",
@@ -39,12 +39,10 @@
39
39
  "eslint": ">=8.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@eslint-stylistic/metadata": "0.0.4",
43
42
  "@eslint/js": "^8.50.0",
44
- "@stylistic/eslint-plugin-js": "0.0.4",
45
- "@stylistic/eslint-plugin-ts": "0.0.4",
46
- "@typescript-eslint/eslint-plugin": "^6.7.2",
47
- "@typescript-eslint/parser": "^6.7.2",
43
+ "@stylistic/eslint-plugin": "^0.0.5",
44
+ "@typescript-eslint/eslint-plugin": "^6.7.3",
45
+ "@typescript-eslint/parser": "^6.7.3",
48
46
  "eslint-config-flat-gitignore": "^0.1.0",
49
47
  "eslint-define-config": "^1.23.0",
50
48
  "eslint-plugin-antfu": "1.0.0-beta.6",
@@ -67,15 +65,14 @@
67
65
  "devDependencies": {
68
66
  "@antfu/ni": "^0.21.8",
69
67
  "@lincy/eslint-config": "workspace:*",
70
- "@stylistic/eslint-plugin-migrate": "0.0.4",
71
- "@types/node": "^20.6.5",
68
+ "@types/node": "^20.7.0",
72
69
  "bumpp": "^9.2.0",
73
70
  "eslint": "^8.50.0",
74
71
  "eslint-plugin-sort-keys": "^2.3.5",
75
72
  "esno": "^0.17.0",
76
73
  "lint-staged": "^14.0.1",
77
74
  "local-pkg": "^0.4.3",
78
- "rimraf": "^5.0.1",
75
+ "rimraf": "^5.0.4",
79
76
  "simple-git-hooks": "^2.9.0",
80
77
  "simple-open-url": "^3.0.1",
81
78
  "sucrase": "^3.34.0",