@so1ve/eslint-config 1.0.0-alpha.8 → 1.0.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.cjs CHANGED
@@ -19,6 +19,7 @@ var pluginJsonSchemaValidator = require('eslint-plugin-json-schema-validator');
19
19
  var pluginJsonc = require('eslint-plugin-jsonc');
20
20
  var pluginMdx = require('eslint-plugin-mdx');
21
21
  var pluginNode = require('eslint-plugin-n');
22
+ var pluginNoAwaitInPromise = require('eslint-plugin-no-await-in-promise');
22
23
  var pluginNoOnlyTests = require('eslint-plugin-no-only-tests');
23
24
  var pluginOnlyError = require('eslint-plugin-only-error');
24
25
  var pluginPromise = require('eslint-plugin-promise');
@@ -41,6 +42,24 @@ var localPkg = require('local-pkg');
41
42
 
42
43
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
43
44
 
45
+ function _interopNamespace(e) {
46
+ if (e && e.__esModule) return e;
47
+ var n = Object.create(null);
48
+ if (e) {
49
+ Object.keys(e).forEach(function (k) {
50
+ if (k !== 'default') {
51
+ var d = Object.getOwnPropertyDescriptor(e, k);
52
+ Object.defineProperty(n, k, d.get ? d : {
53
+ enumerable: true,
54
+ get: function () { return e[k]; }
55
+ });
56
+ }
57
+ });
58
+ }
59
+ n["default"] = e;
60
+ return Object.freeze(n);
61
+ }
62
+
44
63
  var pluginComments__default = /*#__PURE__*/_interopDefaultLegacy(pluginComments);
45
64
  var pluginHtml__default = /*#__PURE__*/_interopDefaultLegacy(pluginHtml);
46
65
  var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
@@ -58,6 +77,7 @@ var pluginJsonSchemaValidator__default = /*#__PURE__*/_interopDefaultLegacy(plug
58
77
  var pluginJsonc__default = /*#__PURE__*/_interopDefaultLegacy(pluginJsonc);
59
78
  var pluginMdx__default = /*#__PURE__*/_interopDefaultLegacy(pluginMdx);
60
79
  var pluginNode__default = /*#__PURE__*/_interopDefaultLegacy(pluginNode);
80
+ var pluginNoAwaitInPromise__namespace = /*#__PURE__*/_interopNamespace(pluginNoAwaitInPromise);
61
81
  var pluginNoOnlyTests__default = /*#__PURE__*/_interopDefaultLegacy(pluginNoOnlyTests);
62
82
  var pluginOnlyError__default = /*#__PURE__*/_interopDefaultLegacy(pluginOnlyError);
63
83
  var pluginPromise__default = /*#__PURE__*/_interopDefaultLegacy(pluginPromise);
@@ -251,7 +271,6 @@ const formatting = (options) => {
251
271
  "moduleResolution",
252
272
  "moduleSuffixes",
253
273
  "noResolve",
254
- "paths",
255
274
  "resolveJsonModule",
256
275
  "resolvePackageJsonExports",
257
276
  "resolvePackageJsonImports",
@@ -317,7 +336,9 @@ const formatting = (options) => {
317
336
  "verbatimModuleSyntax",
318
337
  /* Completeness */
319
338
  "skipDefaultLibCheck",
320
- "skipLibCheck"
339
+ "skipLibCheck",
340
+ /* Alias */
341
+ "paths"
321
342
  ],
322
343
  pathPattern: "^compilerOptions$"
323
344
  }
@@ -334,6 +355,46 @@ const formatting = (options) => {
334
355
  ].flat().filter(Boolean);
335
356
  };
336
357
 
358
+ const renameRules = (rules, from, to) => Object.fromEntries(
359
+ Object.entries(rules).map(([key, value]) => {
360
+ if (key.startsWith(from)) {
361
+ return [to + key.slice(from.length), value];
362
+ }
363
+ return [key, value];
364
+ })
365
+ );
366
+ const rulesOn = /* @__PURE__ */ new Set();
367
+ const rulesOff = /* @__PURE__ */ new Set();
368
+ function recordRulesStateConfigs(configs) {
369
+ var _a;
370
+ for (const config of configs) {
371
+ recordRulesState((_a = config.rules) != null ? _a : {});
372
+ }
373
+ return configs;
374
+ }
375
+ function recordRulesState(rules) {
376
+ for (const [key, value] of Object.entries(rules != null ? rules : {})) {
377
+ const firstValue = Array.isArray(value) ? value[0] : value;
378
+ if (firstValue == null) {
379
+ continue;
380
+ }
381
+ if (firstValue === "off" || firstValue === 0) {
382
+ rulesOff.add(key);
383
+ } else {
384
+ rulesOn.add(key);
385
+ }
386
+ }
387
+ return rules;
388
+ }
389
+ function warnUnnecessaryOffRules() {
390
+ const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
391
+ for (const off of unnecessaryOffRules) {
392
+ console.warn(
393
+ `[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`
394
+ );
395
+ }
396
+ }
397
+
337
398
  const html = () => [
338
399
  {
339
400
  plugins: {
@@ -350,7 +411,11 @@ const html = () => [
350
411
  },
351
412
  files: [GLOB_HTML],
352
413
  rules: {
353
- ...pluginHtml__default["default"].configs.recommended.rules,
414
+ ...renameRules(
415
+ pluginHtml__default["default"].configs.recommended.rules,
416
+ "@html-eslint/",
417
+ "html/"
418
+ ),
354
419
  "html/indent": "off",
355
420
  "html/no-trailing-spaces": "off",
356
421
  "html/require-closing-tags": "off",
@@ -360,9 +425,7 @@ const html = () => [
360
425
  }
361
426
  ];
362
427
 
363
- const ignores = () => [
364
- { ignores: GLOB_EXCLUDE }
365
- ];
428
+ const ignores = () => [{ ignores: GLOB_EXCLUDE }];
366
429
 
367
430
  const imports = (options = {}) => [
368
431
  {
@@ -422,7 +485,8 @@ const javascript = ({
422
485
  "sort-imports": pluginSortImports__default["default"],
423
486
  "array-func": pluginArrayFunc__default["default"],
424
487
  "json-schema-validator": pluginJsonSchemaValidator__default["default"],
425
- "regexp": pluginRegexp__default["default"]
488
+ "regexp": pluginRegexp__default["default"],
489
+ "no-await-in-promise": pluginNoAwaitInPromise__namespace
426
490
  }
427
491
  },
428
492
  {
@@ -727,10 +791,19 @@ const javascript = ({
727
791
  "sort-imports/exports": "error",
728
792
  // array-func
729
793
  "array-func/prefer-array-from": "off",
794
+ "array-func/prefer-flat": "off",
795
+ // Handled by unicorn
796
+ "array-func/from-map": "off",
797
+ // Conflicts with unicorn/prefer-spread
798
+ "array-func/no-unnecessary-this-arg": "error",
799
+ "array-func/avoid-reverse": "error",
800
+ "array-func/prefer-flat-map": "error",
730
801
  // json-schema-validator
731
802
  "json-schema-validator/no-invalid": "warn",
732
803
  // regexp
733
804
  "regexp/no-unused-capturing-group": "warn",
805
+ // no-await-in-promise
806
+ "no-await-in-promise/no-await-in-promise": "error",
734
807
  ...overrides
735
808
  }
736
809
  },
@@ -883,9 +956,7 @@ const sortImports = () => [
883
956
  }
884
957
  ];
885
958
 
886
- const test = ({
887
- overrides
888
- } = {}) => [
959
+ const test = ({ overrides } = {}) => [
889
960
  {
890
961
  plugins: {
891
962
  "no-only-tests": pluginNoOnlyTests__default["default"],
@@ -919,9 +990,7 @@ const test = ({
919
990
  }
920
991
  ];
921
992
 
922
- const toml = ({
923
- overrides
924
- } = {}) => [
993
+ const toml = ({ overrides } = {}) => [
925
994
  {
926
995
  plugins: {
927
996
  toml: pluginToml__default["default"]
@@ -941,47 +1010,6 @@ const toml = ({
941
1010
  }
942
1011
  ];
943
1012
 
944
- const combine = (...configs) => configs.flatMap((config) => Array.isArray(config) ? config : [config]);
945
- const renameRules = (rules, from, to) => Object.fromEntries(
946
- Object.entries(rules).map(([key, value]) => {
947
- if (key.startsWith(from)) {
948
- return [to + key.slice(from.length), value];
949
- }
950
- return [key, value];
951
- })
952
- );
953
- const rulesOn = /* @__PURE__ */ new Set();
954
- const rulesOff = /* @__PURE__ */ new Set();
955
- function recordRulesStateConfigs(configs) {
956
- var _a;
957
- for (const config of configs) {
958
- recordRulesState((_a = config.rules) != null ? _a : {});
959
- }
960
- return configs;
961
- }
962
- function recordRulesState(rules) {
963
- for (const [key, value] of Object.entries(rules != null ? rules : {})) {
964
- const firstValue = Array.isArray(value) ? value[0] : value;
965
- if (firstValue == null) {
966
- continue;
967
- }
968
- if (firstValue === "off" || firstValue === 0) {
969
- rulesOff.add(key);
970
- } else {
971
- rulesOn.add(key);
972
- }
973
- }
974
- return rules;
975
- }
976
- function warnUnnecessaryOffRules() {
977
- const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
978
- for (const off of unnecessaryOffRules) {
979
- console.warn(
980
- `[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`
981
- );
982
- }
983
- }
984
-
985
1013
  function typescript({
986
1014
  componentExts = [],
987
1015
  parserOptions,
@@ -1037,7 +1065,9 @@ function typescript({
1037
1065
  parser: parserTs__default["default"],
1038
1066
  parserOptions: {
1039
1067
  sourceType: "module",
1068
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1040
1069
  EXPERIMENTAL_useProjectService: true,
1070
+ // eslint-disable-next-line ts/no-unnecessary-type-assertion
1041
1071
  ...parserOptions
1042
1072
  }
1043
1073
  },
@@ -1130,6 +1160,15 @@ function typescript({
1130
1160
  "ts/prefer-ts-expect-error": "error",
1131
1161
  "ts/no-require-imports": "error",
1132
1162
  "ts/method-signature-style": ["error", "property"],
1163
+ "ts/explicit-member-accessibility": [
1164
+ "error",
1165
+ {
1166
+ accessibility: "explicit",
1167
+ overrides: {
1168
+ constructors: "no-public"
1169
+ }
1170
+ }
1171
+ ],
1133
1172
  // Override JS
1134
1173
  "no-useless-constructor": "off",
1135
1174
  "no-invalid-this": "off",
@@ -1160,7 +1199,6 @@ function typescript({
1160
1199
  // off
1161
1200
  "ts/camelcase": "off",
1162
1201
  "ts/explicit-function-return-type": "off",
1163
- "ts/explicit-member-accessibility": "off",
1164
1202
  "ts/no-explicit-any": "off",
1165
1203
  "ts/no-parameter-properties": "off",
1166
1204
  "ts/no-empty-interface": "off",
@@ -1456,9 +1494,7 @@ const vue = ({
1456
1494
  }
1457
1495
  ];
1458
1496
 
1459
- const yaml = ({
1460
- overrides
1461
- } = {}) => [
1497
+ const yaml = ({ overrides } = {}) => [
1462
1498
  {
1463
1499
  plugins: {
1464
1500
  yaml: pluginYaml__default["default"]
@@ -1519,7 +1555,8 @@ function so1ve(options = {}, ...userConfigs) {
1519
1555
  promise(),
1520
1556
  sortImports(),
1521
1557
  imports(),
1522
- unicorn()
1558
+ unicorn(),
1559
+ html()
1523
1560
  );
1524
1561
  if (enableVue) {
1525
1562
  componentExts.push("vue");
@@ -1592,7 +1629,7 @@ function so1ve(options = {}, ...userConfigs) {
1592
1629
  if (Object.keys(fusedConfig).length > 0) {
1593
1630
  configs.push([fusedConfig]);
1594
1631
  }
1595
- const merged = combine(...configs, ...userConfigs);
1632
+ const merged = [...configs, ...userConfigs].flat();
1596
1633
  return merged;
1597
1634
  }
1598
1635
 
@@ -1664,6 +1701,7 @@ Object.defineProperty(exports, 'pluginNode', {
1664
1701
  enumerable: true,
1665
1702
  get: function () { return pluginNode__default["default"]; }
1666
1703
  });
1704
+ exports.pluginNoAwaitInPromise = pluginNoAwaitInPromise__namespace;
1667
1705
  Object.defineProperty(exports, 'pluginNoOnlyTests', {
1668
1706
  enumerable: true,
1669
1707
  get: function () { return pluginNoOnlyTests__default["default"]; }
@@ -1750,7 +1788,6 @@ exports.GLOB_TSCONFIG = GLOB_TSCONFIG;
1750
1788
  exports.GLOB_TSX = GLOB_TSX;
1751
1789
  exports.GLOB_VUE = GLOB_VUE;
1752
1790
  exports.GLOB_YAML = GLOB_YAML;
1753
- exports.combine = combine;
1754
1791
  exports.comments = comments;
1755
1792
  exports.formatting = formatting;
1756
1793
  exports.html = html;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { FlatESLintConfigItem } from 'eslint-define-config';
1
+ import so1vePlugin from '@so1ve/eslint-plugin';
2
+ export { default as pluginSo1ve } from '@so1ve/eslint-plugin';
2
3
  import { ParserOptions } from '@typescript-eslint/parser';
3
4
  export { default as parserTs } from '@typescript-eslint/parser';
4
5
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
6
+ import { Rules, FlatESLintConfigItem } from 'eslint-define-config';
5
7
  export { default as pluginComments } from '@eslint-community/eslint-plugin-eslint-comments';
6
8
  export { default as pluginHtml } from '@html-eslint/eslint-plugin';
7
9
  export { default as parserHtml } from '@html-eslint/parser';
8
- export { default as pluginSo1ve } from '@so1ve/eslint-plugin';
9
10
  export { default as pluginSortImports } from '@so1ve/eslint-plugin-sort-imports';
10
11
  export { default as pluginTs } from '@typescript-eslint/eslint-plugin';
11
12
  export { default as parserMdx } from 'eslint-mdx';
@@ -18,6 +19,8 @@ export { default as pluginJsonSchemaValidator } from 'eslint-plugin-json-schema-
18
19
  export { default as pluginJsonc } from 'eslint-plugin-jsonc';
19
20
  export { default as pluginMdx } from 'eslint-plugin-mdx';
20
21
  export { default as pluginNode } from 'eslint-plugin-n';
22
+ import * as eslintPluginNoAwaitInPromise from 'eslint-plugin-no-await-in-promise';
23
+ export { eslintPluginNoAwaitInPromise as pluginNoAwaitInPromise };
21
24
  export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
22
25
  export { default as pluginOnlyError } from 'eslint-plugin-only-error';
23
26
  export { default as pluginPromise } from 'eslint-plugin-promise';
@@ -34,8 +37,6 @@ export { default as parserToml } from 'toml-eslint-parser';
34
37
  export { default as parserVue } from 'vue-eslint-parser';
35
38
  export { default as parserYaml } from 'yaml-eslint-parser';
36
39
 
37
- declare const comments: () => FlatESLintConfigItem[];
38
-
39
40
  interface OptionsComponentExts {
40
41
  /**
41
42
  * Additional extensions for components.
@@ -52,7 +53,7 @@ interface OptionsHasTypeScript {
52
53
  typescript?: boolean;
53
54
  }
54
55
  interface OptionsOverrides {
55
- overrides?: FlatESLintConfigItem["rules"];
56
+ overrides?: ConfigItem["rules"];
56
57
  }
57
58
  interface Options extends OptionsComponentExts {
58
59
  /**
@@ -124,58 +125,75 @@ interface Options extends OptionsComponentExts {
124
125
  * Provide overrides for rules for each integration.
125
126
  */
126
127
  overrides?: {
127
- javascript?: FlatESLintConfigItem["rules"];
128
- typescript?: FlatESLintConfigItem["rules"];
129
- test?: FlatESLintConfigItem["rules"];
130
- vue?: FlatESLintConfigItem["rules"];
131
- solid?: FlatESLintConfigItem["rules"];
132
- jsonc?: FlatESLintConfigItem["rules"];
133
- mdx?: FlatESLintConfigItem["rules"];
134
- yaml?: FlatESLintConfigItem["rules"];
135
- toml?: FlatESLintConfigItem["rules"];
128
+ javascript?: ConfigItem["rules"];
129
+ typescript?: ConfigItem["rules"];
130
+ test?: ConfigItem["rules"];
131
+ vue?: ConfigItem["rules"];
132
+ solid?: ConfigItem["rules"];
133
+ jsonc?: ConfigItem["rules"];
134
+ mdx?: ConfigItem["rules"];
135
+ yaml?: ConfigItem["rules"];
136
+ toml?: ConfigItem["rules"];
136
137
  };
137
138
  }
139
+ type Unprefix<T extends Record<string, any>, Pre extends string> = {
140
+ [K in keyof T as K extends `${Pre}${infer U}` ? U : never]: T[K];
141
+ };
142
+ type Prefix<T extends Record<string, any>, Pre extends string> = {
143
+ [K in keyof T as `${Pre}${K & string}`]: T[K];
144
+ };
145
+ type RenamePrefix<T extends Record<string, any>, Old extends string, New extends string> = Prefix<Unprefix<T, Old>, New>;
146
+ type MergeIntersection<T extends Record<any, any>> = {
147
+ [K in keyof T]: T[K];
148
+ };
149
+ type RenamedRules = MergeIntersection<Rules & RenamePrefix<Rules, "@typescript-eslint/", "ts/"> & RenamePrefix<Rules, "yml/", "yaml/"> & RenamePrefix<Rules, "n/", "node/"> & Prefix<Partial<(typeof so1vePlugin)["rules"]>, "so1ve/">>;
150
+ type ConfigItem = Omit<FlatESLintConfigItem, "plugins" | "rules"> & {
151
+ plugins?: Record<string, any>;
152
+ rules?: RenamedRules | Record<string, any>;
153
+ };
154
+
155
+ declare const comments: () => ConfigItem[];
138
156
 
139
- declare const formatting: (options: Options) => FlatESLintConfigItem[];
157
+ declare const formatting: (options: Options) => ConfigItem[];
140
158
 
141
- declare const html: () => FlatESLintConfigItem[];
159
+ declare const html: () => ConfigItem[];
142
160
 
143
- declare const ignores: () => FlatESLintConfigItem[];
161
+ declare const ignores: () => ConfigItem[];
144
162
 
145
- declare const imports: (options?: Options) => FlatESLintConfigItem[];
163
+ declare const imports: (options?: Options) => ConfigItem[];
146
164
 
147
- declare const javascript: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
165
+ declare const javascript: ({ overrides, }?: OptionsOverrides) => ConfigItem[];
148
166
 
149
- declare const jsonc: () => FlatESLintConfigItem[];
167
+ declare const jsonc: () => ConfigItem[];
150
168
 
151
- declare const mdx: ({ componentExts, overrides, }?: OptionsComponentExts & OptionsOverrides) => FlatESLintConfigItem[];
169
+ declare const mdx: ({ componentExts, overrides, }?: OptionsComponentExts & OptionsOverrides) => ConfigItem[];
152
170
 
153
- declare const node: () => FlatESLintConfigItem[];
171
+ declare const node: () => ConfigItem[];
154
172
 
155
- declare const onlyError: () => FlatESLintConfigItem[];
173
+ declare const onlyError: () => ConfigItem[];
156
174
 
157
- declare const promise: () => FlatESLintConfigItem[];
175
+ declare const promise: () => ConfigItem[];
158
176
 
159
- declare const solid: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => FlatESLintConfigItem[];
177
+ declare const solid: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => ConfigItem[];
160
178
 
161
- declare const sortImports: () => FlatESLintConfigItem[];
179
+ declare const sortImports: () => ConfigItem[];
162
180
 
163
- declare const test: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
181
+ declare const test: ({ overrides }?: OptionsOverrides) => ConfigItem[];
164
182
 
165
- declare const toml: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
183
+ declare const toml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
166
184
 
167
- declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): FlatESLintConfigItem[];
185
+ declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): ConfigItem[];
168
186
 
169
- declare const unicorn: () => FlatESLintConfigItem[];
187
+ declare const unicorn: () => ConfigItem[];
170
188
 
171
- declare const vue: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => FlatESLintConfigItem[];
189
+ declare const vue: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => ConfigItem[];
172
190
 
173
- declare const yaml: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
191
+ declare const yaml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
174
192
 
175
193
  /**
176
194
  * Construct an array of ESLint flat config items.
177
195
  */
178
- declare function so1ve(options?: Options, ...userConfigs: (FlatESLintConfigItem | FlatESLintConfigItem[])[]): FlatESLintConfigItem[];
196
+ declare function so1ve(options?: Options, ...userConfigs: (ConfigItem | ConfigItem[])[]): ConfigItem[];
179
197
 
180
198
  declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
181
199
  declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
@@ -204,15 +222,11 @@ declare const GLOB_TESTS: string[];
204
222
  declare const GLOB_ALL_SRC: string[];
205
223
  declare const GLOB_EXCLUDE: string[];
206
224
 
207
- /**
208
- * Combine array and non-array configs into a single array.
209
- */
210
- declare const combine: (...configs: (FlatESLintConfigItem | FlatESLintConfigItem[])[]) => FlatESLintConfigItem[];
211
225
  declare const renameRules: (rules: Record<string, any>, from: string, to: string) => {
212
226
  [k: string]: any;
213
227
  };
214
- declare function recordRulesStateConfigs(configs: FlatESLintConfigItem[]): FlatESLintConfigItem[];
215
- declare function recordRulesState(rules: FlatESLintConfigItem["rules"]): FlatESLintConfigItem["rules"];
228
+ declare function recordRulesStateConfigs(configs: ConfigItem[]): ConfigItem[];
229
+ declare function recordRulesState(rules: ConfigItem["rules"]): ConfigItem["rules"];
216
230
  declare function warnUnnecessaryOffRules(): void;
217
231
 
218
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, Options, OptionsComponentExts, OptionsHasTypeScript, OptionsOverrides, OptionsTypeScriptParserOptions, combine, comments, formatting, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
232
+ export { ConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, Options, OptionsComponentExts, OptionsHasTypeScript, OptionsOverrides, OptionsTypeScriptParserOptions, RenamedRules, comments, formatting, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
package/dist/index.mjs CHANGED
@@ -31,6 +31,8 @@ import pluginMdx from 'eslint-plugin-mdx';
31
31
  export { default as pluginMdx } from 'eslint-plugin-mdx';
32
32
  import pluginNode from 'eslint-plugin-n';
33
33
  export { default as pluginNode } from 'eslint-plugin-n';
34
+ import * as pluginNoAwaitInPromise from 'eslint-plugin-no-await-in-promise';
35
+ export { pluginNoAwaitInPromise };
34
36
  import pluginNoOnlyTests from 'eslint-plugin-no-only-tests';
35
37
  export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests';
36
38
  import pluginOnlyError from 'eslint-plugin-only-error';
@@ -240,7 +242,6 @@ const formatting = (options) => {
240
242
  "moduleResolution",
241
243
  "moduleSuffixes",
242
244
  "noResolve",
243
- "paths",
244
245
  "resolveJsonModule",
245
246
  "resolvePackageJsonExports",
246
247
  "resolvePackageJsonImports",
@@ -306,7 +307,9 @@ const formatting = (options) => {
306
307
  "verbatimModuleSyntax",
307
308
  /* Completeness */
308
309
  "skipDefaultLibCheck",
309
- "skipLibCheck"
310
+ "skipLibCheck",
311
+ /* Alias */
312
+ "paths"
310
313
  ],
311
314
  pathPattern: "^compilerOptions$"
312
315
  }
@@ -323,6 +326,46 @@ const formatting = (options) => {
323
326
  ].flat().filter(Boolean);
324
327
  };
325
328
 
329
+ const renameRules = (rules, from, to) => Object.fromEntries(
330
+ Object.entries(rules).map(([key, value]) => {
331
+ if (key.startsWith(from)) {
332
+ return [to + key.slice(from.length), value];
333
+ }
334
+ return [key, value];
335
+ })
336
+ );
337
+ const rulesOn = /* @__PURE__ */ new Set();
338
+ const rulesOff = /* @__PURE__ */ new Set();
339
+ function recordRulesStateConfigs(configs) {
340
+ var _a;
341
+ for (const config of configs) {
342
+ recordRulesState((_a = config.rules) != null ? _a : {});
343
+ }
344
+ return configs;
345
+ }
346
+ function recordRulesState(rules) {
347
+ for (const [key, value] of Object.entries(rules != null ? rules : {})) {
348
+ const firstValue = Array.isArray(value) ? value[0] : value;
349
+ if (firstValue == null) {
350
+ continue;
351
+ }
352
+ if (firstValue === "off" || firstValue === 0) {
353
+ rulesOff.add(key);
354
+ } else {
355
+ rulesOn.add(key);
356
+ }
357
+ }
358
+ return rules;
359
+ }
360
+ function warnUnnecessaryOffRules() {
361
+ const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
362
+ for (const off of unnecessaryOffRules) {
363
+ console.warn(
364
+ `[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`
365
+ );
366
+ }
367
+ }
368
+
326
369
  const html = () => [
327
370
  {
328
371
  plugins: {
@@ -339,7 +382,11 @@ const html = () => [
339
382
  },
340
383
  files: [GLOB_HTML],
341
384
  rules: {
342
- ...pluginHtml.configs.recommended.rules,
385
+ ...renameRules(
386
+ pluginHtml.configs.recommended.rules,
387
+ "@html-eslint/",
388
+ "html/"
389
+ ),
343
390
  "html/indent": "off",
344
391
  "html/no-trailing-spaces": "off",
345
392
  "html/require-closing-tags": "off",
@@ -349,9 +396,7 @@ const html = () => [
349
396
  }
350
397
  ];
351
398
 
352
- const ignores = () => [
353
- { ignores: GLOB_EXCLUDE }
354
- ];
399
+ const ignores = () => [{ ignores: GLOB_EXCLUDE }];
355
400
 
356
401
  const imports = (options = {}) => [
357
402
  {
@@ -411,7 +456,8 @@ const javascript = ({
411
456
  "sort-imports": pluginSortImports,
412
457
  "array-func": pluginArrayFunc,
413
458
  "json-schema-validator": pluginJsonSchemaValidator,
414
- "regexp": pluginRegexp
459
+ "regexp": pluginRegexp,
460
+ "no-await-in-promise": pluginNoAwaitInPromise
415
461
  }
416
462
  },
417
463
  {
@@ -716,10 +762,19 @@ const javascript = ({
716
762
  "sort-imports/exports": "error",
717
763
  // array-func
718
764
  "array-func/prefer-array-from": "off",
765
+ "array-func/prefer-flat": "off",
766
+ // Handled by unicorn
767
+ "array-func/from-map": "off",
768
+ // Conflicts with unicorn/prefer-spread
769
+ "array-func/no-unnecessary-this-arg": "error",
770
+ "array-func/avoid-reverse": "error",
771
+ "array-func/prefer-flat-map": "error",
719
772
  // json-schema-validator
720
773
  "json-schema-validator/no-invalid": "warn",
721
774
  // regexp
722
775
  "regexp/no-unused-capturing-group": "warn",
776
+ // no-await-in-promise
777
+ "no-await-in-promise/no-await-in-promise": "error",
723
778
  ...overrides
724
779
  }
725
780
  },
@@ -872,9 +927,7 @@ const sortImports = () => [
872
927
  }
873
928
  ];
874
929
 
875
- const test = ({
876
- overrides
877
- } = {}) => [
930
+ const test = ({ overrides } = {}) => [
878
931
  {
879
932
  plugins: {
880
933
  "no-only-tests": pluginNoOnlyTests,
@@ -908,9 +961,7 @@ const test = ({
908
961
  }
909
962
  ];
910
963
 
911
- const toml = ({
912
- overrides
913
- } = {}) => [
964
+ const toml = ({ overrides } = {}) => [
914
965
  {
915
966
  plugins: {
916
967
  toml: pluginToml
@@ -930,47 +981,6 @@ const toml = ({
930
981
  }
931
982
  ];
932
983
 
933
- const combine = (...configs) => configs.flatMap((config) => Array.isArray(config) ? config : [config]);
934
- const renameRules = (rules, from, to) => Object.fromEntries(
935
- Object.entries(rules).map(([key, value]) => {
936
- if (key.startsWith(from)) {
937
- return [to + key.slice(from.length), value];
938
- }
939
- return [key, value];
940
- })
941
- );
942
- const rulesOn = /* @__PURE__ */ new Set();
943
- const rulesOff = /* @__PURE__ */ new Set();
944
- function recordRulesStateConfigs(configs) {
945
- var _a;
946
- for (const config of configs) {
947
- recordRulesState((_a = config.rules) != null ? _a : {});
948
- }
949
- return configs;
950
- }
951
- function recordRulesState(rules) {
952
- for (const [key, value] of Object.entries(rules != null ? rules : {})) {
953
- const firstValue = Array.isArray(value) ? value[0] : value;
954
- if (firstValue == null) {
955
- continue;
956
- }
957
- if (firstValue === "off" || firstValue === 0) {
958
- rulesOff.add(key);
959
- } else {
960
- rulesOn.add(key);
961
- }
962
- }
963
- return rules;
964
- }
965
- function warnUnnecessaryOffRules() {
966
- const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
967
- for (const off of unnecessaryOffRules) {
968
- console.warn(
969
- `[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`
970
- );
971
- }
972
- }
973
-
974
984
  function typescript({
975
985
  componentExts = [],
976
986
  parserOptions,
@@ -1026,7 +1036,9 @@ function typescript({
1026
1036
  parser: parserTs,
1027
1037
  parserOptions: {
1028
1038
  sourceType: "module",
1039
+ extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1029
1040
  EXPERIMENTAL_useProjectService: true,
1041
+ // eslint-disable-next-line ts/no-unnecessary-type-assertion
1030
1042
  ...parserOptions
1031
1043
  }
1032
1044
  },
@@ -1119,6 +1131,15 @@ function typescript({
1119
1131
  "ts/prefer-ts-expect-error": "error",
1120
1132
  "ts/no-require-imports": "error",
1121
1133
  "ts/method-signature-style": ["error", "property"],
1134
+ "ts/explicit-member-accessibility": [
1135
+ "error",
1136
+ {
1137
+ accessibility: "explicit",
1138
+ overrides: {
1139
+ constructors: "no-public"
1140
+ }
1141
+ }
1142
+ ],
1122
1143
  // Override JS
1123
1144
  "no-useless-constructor": "off",
1124
1145
  "no-invalid-this": "off",
@@ -1149,7 +1170,6 @@ function typescript({
1149
1170
  // off
1150
1171
  "ts/camelcase": "off",
1151
1172
  "ts/explicit-function-return-type": "off",
1152
- "ts/explicit-member-accessibility": "off",
1153
1173
  "ts/no-explicit-any": "off",
1154
1174
  "ts/no-parameter-properties": "off",
1155
1175
  "ts/no-empty-interface": "off",
@@ -1445,9 +1465,7 @@ const vue = ({
1445
1465
  }
1446
1466
  ];
1447
1467
 
1448
- const yaml = ({
1449
- overrides
1450
- } = {}) => [
1468
+ const yaml = ({ overrides } = {}) => [
1451
1469
  {
1452
1470
  plugins: {
1453
1471
  yaml: pluginYaml
@@ -1508,7 +1526,8 @@ function so1ve(options = {}, ...userConfigs) {
1508
1526
  promise(),
1509
1527
  sortImports(),
1510
1528
  imports(),
1511
- unicorn()
1529
+ unicorn(),
1530
+ html()
1512
1531
  );
1513
1532
  if (enableVue) {
1514
1533
  componentExts.push("vue");
@@ -1581,8 +1600,8 @@ function so1ve(options = {}, ...userConfigs) {
1581
1600
  if (Object.keys(fusedConfig).length > 0) {
1582
1601
  configs.push([fusedConfig]);
1583
1602
  }
1584
- const merged = combine(...configs, ...userConfigs);
1603
+ const merged = [...configs, ...userConfigs].flat();
1585
1604
  return merged;
1586
1605
  }
1587
1606
 
1588
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, combine, comments, formatting, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
1607
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSCONFIG, GLOB_TSX, GLOB_VUE, GLOB_YAML, comments, formatting, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-config",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "description": "Ray's eslint config.",
6
6
  "keywords": [
@@ -46,12 +46,13 @@
46
46
  "eslint-plugin-case-police": "^0.6.1",
47
47
  "eslint-plugin-etc": "^2.0.3",
48
48
  "eslint-plugin-html": "^7.1.0",
49
- "eslint-plugin-i": "2.28.1",
49
+ "eslint-plugin-i": "2.29.0",
50
50
  "eslint-plugin-jest-formatting": "^3.1.0",
51
51
  "eslint-plugin-json-schema-validator": "^4.6.0",
52
52
  "eslint-plugin-jsonc": "^2.9.0",
53
53
  "eslint-plugin-mdx": "^2.2.0",
54
54
  "eslint-plugin-n": "^16.0.1",
55
+ "eslint-plugin-no-await-in-promise": "^1.1.5",
55
56
  "eslint-plugin-no-explicit-type-exports": "^0.12.1",
56
57
  "eslint-plugin-no-only-tests": "^3.1.0",
57
58
  "eslint-plugin-only-error": "^1.0.2",
@@ -70,8 +71,8 @@
70
71
  "toml-eslint-parser": "^0.6.0",
71
72
  "vue-eslint-parser": "^9.3.1",
72
73
  "yaml-eslint-parser": "^1.2.2",
73
- "@so1ve/eslint-plugin-sort-imports": "1.0.0-alpha.8",
74
- "@so1ve/eslint-plugin": "1.0.0-alpha.8"
74
+ "@so1ve/eslint-plugin": "1.0.0",
75
+ "@so1ve/eslint-plugin-sort-imports": "1.0.0"
75
76
  },
76
77
  "devDependencies": {
77
78
  "eslint": "^8.46.0"