@so1ve/eslint-config 1.0.0-alpha.9 → 1.0.1

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,
@@ -1038,7 +1066,9 @@ function typescript({
1038
1066
  parserOptions: {
1039
1067
  sourceType: "module",
1040
1068
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1041
- EXPERIMENTAL_useProjectService: true,
1069
+ // EXPERIMENTAL_useProjectService: true,
1070
+ project: true,
1071
+ tsconfigRootDir: process.cwd(),
1042
1072
  ...parserOptions
1043
1073
  }
1044
1074
  },
@@ -1131,6 +1161,15 @@ function typescript({
1131
1161
  "ts/prefer-ts-expect-error": "error",
1132
1162
  "ts/no-require-imports": "error",
1133
1163
  "ts/method-signature-style": ["error", "property"],
1164
+ "ts/explicit-member-accessibility": [
1165
+ "error",
1166
+ {
1167
+ accessibility: "explicit",
1168
+ overrides: {
1169
+ constructors: "no-public"
1170
+ }
1171
+ }
1172
+ ],
1134
1173
  // Override JS
1135
1174
  "no-useless-constructor": "off",
1136
1175
  "no-invalid-this": "off",
@@ -1161,7 +1200,6 @@ function typescript({
1161
1200
  // off
1162
1201
  "ts/camelcase": "off",
1163
1202
  "ts/explicit-function-return-type": "off",
1164
- "ts/explicit-member-accessibility": "off",
1165
1203
  "ts/no-explicit-any": "off",
1166
1204
  "ts/no-parameter-properties": "off",
1167
1205
  "ts/no-empty-interface": "off",
@@ -1457,9 +1495,7 @@ const vue = ({
1457
1495
  }
1458
1496
  ];
1459
1497
 
1460
- const yaml = ({
1461
- overrides
1462
- } = {}) => [
1498
+ const yaml = ({ overrides } = {}) => [
1463
1499
  {
1464
1500
  plugins: {
1465
1501
  yaml: pluginYaml__default["default"]
@@ -1520,7 +1556,8 @@ function so1ve(options = {}, ...userConfigs) {
1520
1556
  promise(),
1521
1557
  sortImports(),
1522
1558
  imports(),
1523
- unicorn()
1559
+ unicorn(),
1560
+ html()
1524
1561
  );
1525
1562
  if (enableVue) {
1526
1563
  componentExts.push("vue");
@@ -1593,7 +1630,7 @@ function so1ve(options = {}, ...userConfigs) {
1593
1630
  if (Object.keys(fusedConfig).length > 0) {
1594
1631
  configs.push([fusedConfig]);
1595
1632
  }
1596
- const merged = combine(...configs, ...userConfigs);
1633
+ const merged = [...configs, ...userConfigs].flat();
1597
1634
  return merged;
1598
1635
  }
1599
1636
 
@@ -1665,6 +1702,7 @@ Object.defineProperty(exports, 'pluginNode', {
1665
1702
  enumerable: true,
1666
1703
  get: function () { return pluginNode__default["default"]; }
1667
1704
  });
1705
+ exports.pluginNoAwaitInPromise = pluginNoAwaitInPromise__namespace;
1668
1706
  Object.defineProperty(exports, 'pluginNoOnlyTests', {
1669
1707
  enumerable: true,
1670
1708
  get: function () { return pluginNoOnlyTests__default["default"]; }
@@ -1751,7 +1789,6 @@ exports.GLOB_TSCONFIG = GLOB_TSCONFIG;
1751
1789
  exports.GLOB_TSX = GLOB_TSX;
1752
1790
  exports.GLOB_VUE = GLOB_VUE;
1753
1791
  exports.GLOB_YAML = GLOB_YAML;
1754
- exports.combine = combine;
1755
1792
  exports.comments = comments;
1756
1793
  exports.formatting = formatting;
1757
1794
  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,21 +37,23 @@ 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
- /** Additional extensions for components. */
41
+ /**
42
+ * Additional extensions for components.
43
+ */
41
44
  componentExts?: string[];
42
45
  }
43
46
  interface OptionsTypeScriptParserOptions {
44
- /** Additional parser options for TypeScript. */
47
+ /**
48
+ * Additional parser options for TypeScript.
49
+ */
45
50
  parserOptions?: Partial<ParserOptions>;
46
51
  }
47
52
  interface OptionsHasTypeScript {
48
53
  typescript?: boolean;
49
54
  }
50
55
  interface OptionsOverrides {
51
- overrides?: FlatESLintConfigItem["rules"];
56
+ overrides?: ConfigItem["rules"];
52
57
  }
53
58
  interface Options extends OptionsComponentExts {
54
59
  /**
@@ -116,58 +121,79 @@ interface Options extends OptionsComponentExts {
116
121
  * @default true
117
122
  */
118
123
  formatting?: boolean;
119
- /** Provide overrides for rules for each integration. */
124
+ /**
125
+ * Provide overrides for rules for each integration.
126
+ */
120
127
  overrides?: {
121
- javascript?: FlatESLintConfigItem["rules"];
122
- typescript?: FlatESLintConfigItem["rules"];
123
- test?: FlatESLintConfigItem["rules"];
124
- vue?: FlatESLintConfigItem["rules"];
125
- solid?: FlatESLintConfigItem["rules"];
126
- jsonc?: FlatESLintConfigItem["rules"];
127
- mdx?: FlatESLintConfigItem["rules"];
128
- yaml?: FlatESLintConfigItem["rules"];
129
- 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"];
130
137
  };
131
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[];
132
156
 
133
- declare const formatting: (options: Options) => FlatESLintConfigItem[];
157
+ declare const formatting: (options: Options) => ConfigItem[];
134
158
 
135
- declare const html: () => FlatESLintConfigItem[];
159
+ declare const html: () => ConfigItem[];
136
160
 
137
- declare const ignores: () => FlatESLintConfigItem[];
161
+ declare const ignores: () => ConfigItem[];
138
162
 
139
- declare const imports: (options?: Options) => FlatESLintConfigItem[];
163
+ declare const imports: (options?: Options) => ConfigItem[];
140
164
 
141
- declare const javascript: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
165
+ declare const javascript: ({ overrides, }?: OptionsOverrides) => ConfigItem[];
142
166
 
143
- declare const jsonc: () => FlatESLintConfigItem[];
167
+ declare const jsonc: () => ConfigItem[];
144
168
 
145
- declare const mdx: ({ componentExts, overrides, }?: OptionsComponentExts & OptionsOverrides) => FlatESLintConfigItem[];
169
+ declare const mdx: ({ componentExts, overrides, }?: OptionsComponentExts & OptionsOverrides) => ConfigItem[];
146
170
 
147
- declare const node: () => FlatESLintConfigItem[];
171
+ declare const node: () => ConfigItem[];
148
172
 
149
- declare const onlyError: () => FlatESLintConfigItem[];
173
+ declare const onlyError: () => ConfigItem[];
150
174
 
151
- declare const promise: () => FlatESLintConfigItem[];
175
+ declare const promise: () => ConfigItem[];
152
176
 
153
- declare const solid: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => FlatESLintConfigItem[];
177
+ declare const solid: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => ConfigItem[];
154
178
 
155
- declare const sortImports: () => FlatESLintConfigItem[];
179
+ declare const sortImports: () => ConfigItem[];
156
180
 
157
- declare const test: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
181
+ declare const test: ({ overrides }?: OptionsOverrides) => ConfigItem[];
158
182
 
159
- declare const toml: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
183
+ declare const toml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
160
184
 
161
- declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): FlatESLintConfigItem[];
185
+ declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): ConfigItem[];
162
186
 
163
- declare const unicorn: () => FlatESLintConfigItem[];
187
+ declare const unicorn: () => ConfigItem[];
164
188
 
165
- declare const vue: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => FlatESLintConfigItem[];
189
+ declare const vue: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsOverrides) => ConfigItem[];
166
190
 
167
- declare const yaml: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
191
+ declare const yaml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
168
192
 
169
- /** Construct an array of ESLint flat config items. */
170
- declare function so1ve(options?: Options, ...userConfigs: (FlatESLintConfigItem | FlatESLintConfigItem[])[]): FlatESLintConfigItem[];
193
+ /**
194
+ * Construct an array of ESLint flat config items.
195
+ */
196
+ declare function so1ve(options?: Options, ...userConfigs: (ConfigItem | ConfigItem[])[]): ConfigItem[];
171
197
 
172
198
  declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
173
199
  declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
@@ -196,13 +222,11 @@ declare const GLOB_TESTS: string[];
196
222
  declare const GLOB_ALL_SRC: string[];
197
223
  declare const GLOB_EXCLUDE: string[];
198
224
 
199
- /** Combine array and non-array configs into a single array. */
200
- declare const combine: (...configs: (FlatESLintConfigItem | FlatESLintConfigItem[])[]) => FlatESLintConfigItem[];
201
225
  declare const renameRules: (rules: Record<string, any>, from: string, to: string) => {
202
226
  [k: string]: any;
203
227
  };
204
- declare function recordRulesStateConfigs(configs: FlatESLintConfigItem[]): FlatESLintConfigItem[];
205
- declare function recordRulesState(rules: FlatESLintConfigItem["rules"]): FlatESLintConfigItem["rules"];
228
+ declare function recordRulesStateConfigs(configs: ConfigItem[]): ConfigItem[];
229
+ declare function recordRulesState(rules: ConfigItem["rules"]): ConfigItem["rules"];
206
230
  declare function warnUnnecessaryOffRules(): void;
207
231
 
208
- 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,
@@ -1027,7 +1037,9 @@ function typescript({
1027
1037
  parserOptions: {
1028
1038
  sourceType: "module",
1029
1039
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1030
- EXPERIMENTAL_useProjectService: true,
1040
+ // EXPERIMENTAL_useProjectService: true,
1041
+ project: true,
1042
+ tsconfigRootDir: process.cwd(),
1031
1043
  ...parserOptions
1032
1044
  }
1033
1045
  },
@@ -1120,6 +1132,15 @@ function typescript({
1120
1132
  "ts/prefer-ts-expect-error": "error",
1121
1133
  "ts/no-require-imports": "error",
1122
1134
  "ts/method-signature-style": ["error", "property"],
1135
+ "ts/explicit-member-accessibility": [
1136
+ "error",
1137
+ {
1138
+ accessibility: "explicit",
1139
+ overrides: {
1140
+ constructors: "no-public"
1141
+ }
1142
+ }
1143
+ ],
1123
1144
  // Override JS
1124
1145
  "no-useless-constructor": "off",
1125
1146
  "no-invalid-this": "off",
@@ -1150,7 +1171,6 @@ function typescript({
1150
1171
  // off
1151
1172
  "ts/camelcase": "off",
1152
1173
  "ts/explicit-function-return-type": "off",
1153
- "ts/explicit-member-accessibility": "off",
1154
1174
  "ts/no-explicit-any": "off",
1155
1175
  "ts/no-parameter-properties": "off",
1156
1176
  "ts/no-empty-interface": "off",
@@ -1446,9 +1466,7 @@ const vue = ({
1446
1466
  }
1447
1467
  ];
1448
1468
 
1449
- const yaml = ({
1450
- overrides
1451
- } = {}) => [
1469
+ const yaml = ({ overrides } = {}) => [
1452
1470
  {
1453
1471
  plugins: {
1454
1472
  yaml: pluginYaml
@@ -1509,7 +1527,8 @@ function so1ve(options = {}, ...userConfigs) {
1509
1527
  promise(),
1510
1528
  sortImports(),
1511
1529
  imports(),
1512
- unicorn()
1530
+ unicorn(),
1531
+ html()
1513
1532
  );
1514
1533
  if (enableVue) {
1515
1534
  componentExts.push("vue");
@@ -1582,8 +1601,8 @@ function so1ve(options = {}, ...userConfigs) {
1582
1601
  if (Object.keys(fusedConfig).length > 0) {
1583
1602
  configs.push([fusedConfig]);
1584
1603
  }
1585
- const merged = combine(...configs, ...userConfigs);
1604
+ const merged = [...configs, ...userConfigs].flat();
1586
1605
  return merged;
1587
1606
  }
1588
1607
 
1589
- 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 };
1608
+ 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.9",
3
+ "version": "1.0.1",
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": "1.0.0-alpha.9",
74
- "@so1ve/eslint-plugin-sort-imports": "1.0.0-alpha.9"
74
+ "@so1ve/eslint-plugin": "1.0.1",
75
+ "@so1ve/eslint-plugin-sort-imports": "1.0.1"
75
76
  },
76
77
  "devDependencies": {
77
78
  "eslint": "^8.46.0"