@so1ve/eslint-config 1.0.0-alpha.15 → 1.0.0-alpha.17

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
@@ -935,7 +935,6 @@ const toml = ({ overrides } = {}) => [
935
935
  }
936
936
  ];
937
937
 
938
- const combine = (...configs) => configs.flatMap((config) => Array.isArray(config) ? config : [config]);
939
938
  const renameRules = (rules, from, to) => Object.fromEntries(
940
939
  Object.entries(rules).map(([key, value]) => {
941
940
  if (key.startsWith(from)) {
@@ -979,8 +978,7 @@ function warnUnnecessaryOffRules() {
979
978
  function typescript({
980
979
  componentExts = [],
981
980
  parserOptions,
982
- overrides,
983
- tsconfigPath
981
+ overrides
984
982
  } = {}) {
985
983
  const typeAwareRules = {
986
984
  "etc/no-assign-mutated-array": "error",
@@ -1033,12 +1031,7 @@ function typescript({
1033
1031
  parserOptions: {
1034
1032
  sourceType: "module",
1035
1033
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1036
- // Disable this because it doesn't work well with vue
1037
- // EXPERIMENTAL_useProjectService: true,
1038
- ...tsconfigPath ? {
1039
- project: [tsconfigPath],
1040
- tsconfigRootDir: process.cwd()
1041
- } : {},
1034
+ EXPERIMENTAL_useProjectService: true,
1042
1035
  // eslint-disable-next-line ts/no-unnecessary-type-assertion
1043
1036
  ...parserOptions
1044
1037
  }
@@ -1184,7 +1177,7 @@ function typescript({
1184
1177
  "ts/no-non-null-asserted-nullish-coalescing": "error",
1185
1178
  // handled by unused-imports/no-unused-imports
1186
1179
  "ts/no-unused-vars": "off",
1187
- ...tsconfigPath ? typeAwareRules : {},
1180
+ ...typeAwareRules,
1188
1181
  ...overrides
1189
1182
  }
1190
1183
  },
@@ -1501,11 +1494,11 @@ function so1ve(options = {}, ...userConfigs) {
1501
1494
  const {
1502
1495
  vue: enableVue = VuePackages.some((i) => localPkg.isPackageExists(i)),
1503
1496
  solid: enableSolid = localPkg.isPackageExists("solid-js"),
1497
+ typescript: enableTypeScript = localPkg.isPackageExists("typescript"),
1504
1498
  gitignore: enableGitignore = true,
1505
1499
  overrides = {},
1506
1500
  componentExts = []
1507
1501
  } = options;
1508
- let { typescript: enableTypeScript = localPkg.isPackageExists("typescript") } = options;
1509
1502
  const configs = [];
1510
1503
  if (enableGitignore) {
1511
1504
  if (typeof enableGitignore === "boolean") {
@@ -1533,16 +1526,10 @@ function so1ve(options = {}, ...userConfigs) {
1533
1526
  componentExts.push("vue");
1534
1527
  }
1535
1528
  if (enableTypeScript) {
1536
- if (typeof enableTypeScript !== "object") {
1537
- enableTypeScript = {
1538
- tsconfigPath: "tsconfig.json"
1539
- };
1540
- }
1541
1529
  configs.push(
1542
1530
  typescript({
1543
1531
  componentExts,
1544
- overrides: overrides.typescript,
1545
- ...enableTypeScript
1532
+ overrides: overrides.typescript
1546
1533
  })
1547
1534
  );
1548
1535
  }
@@ -1606,7 +1593,7 @@ function so1ve(options = {}, ...userConfigs) {
1606
1593
  if (Object.keys(fusedConfig).length > 0) {
1607
1594
  configs.push([fusedConfig]);
1608
1595
  }
1609
- const merged = combine(...configs, ...userConfigs);
1596
+ const merged = [...configs, ...userConfigs].flat();
1610
1597
  return merged;
1611
1598
  }
1612
1599
 
@@ -1764,7 +1751,6 @@ exports.GLOB_TSCONFIG = GLOB_TSCONFIG;
1764
1751
  exports.GLOB_TSX = GLOB_TSX;
1765
1752
  exports.GLOB_VUE = GLOB_VUE;
1766
1753
  exports.GLOB_YAML = GLOB_YAML;
1767
- exports.combine = combine;
1768
1754
  exports.comments = comments;
1769
1755
  exports.formatting = formatting;
1770
1756
  exports.html = html;
package/dist/index.d.ts CHANGED
@@ -36,18 +36,16 @@ export { default as parserVue } from 'vue-eslint-parser';
36
36
  export { default as parserYaml } from 'yaml-eslint-parser';
37
37
 
38
38
  interface OptionsComponentExts {
39
- /** Additional extensions for components. */
39
+ /**
40
+ * Additional extensions for components.
41
+ */
40
42
  componentExts?: string[];
41
43
  }
42
- interface OptionsTypeScript {
43
- /** Additional parser options for TypeScript. */
44
- parserOptions?: Partial<ParserOptions>;
44
+ interface OptionsTypeScriptParserOptions {
45
45
  /**
46
- * Path to `tsconfig.json`.
47
- *
48
- * @default "tsconfig.json"
46
+ * Additional parser options for TypeScript.
49
47
  */
50
- tsconfigPath?: string;
48
+ parserOptions?: Partial<ParserOptions>;
51
49
  }
52
50
  interface OptionsHasTypeScript {
53
51
  typescript?: boolean;
@@ -72,7 +70,7 @@ interface Options extends OptionsComponentExts {
72
70
  *
73
71
  * @default auto-detect based on the dependencies
74
72
  */
75
- typescript?: boolean | OptionsTypeScript;
73
+ typescript?: boolean;
76
74
  /**
77
75
  * Enable test support.
78
76
  *
@@ -121,7 +119,9 @@ interface Options extends OptionsComponentExts {
121
119
  * @default true
122
120
  */
123
121
  formatting?: boolean;
124
- /** Provide overrides for rules for each integration. */
122
+ /**
123
+ * Provide overrides for rules for each integration.
124
+ */
125
125
  overrides?: {
126
126
  javascript?: ConfigItem["rules"];
127
127
  typescript?: ConfigItem["rules"];
@@ -180,7 +180,7 @@ declare const test: ({ overrides }?: OptionsOverrides) => ConfigItem[];
180
180
 
181
181
  declare const toml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
182
182
 
183
- declare function typescript({ componentExts, parserOptions, overrides, tsconfigPath, }?: OptionsTypeScript & OptionsComponentExts & OptionsOverrides): ConfigItem[];
183
+ declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): ConfigItem[];
184
184
 
185
185
  declare const unicorn: () => ConfigItem[];
186
186
 
@@ -188,7 +188,9 @@ declare const vue: ({ overrides, typescript, }?: OptionsHasTypeScript & OptionsO
188
188
 
189
189
  declare const yaml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
190
190
 
191
- /** Construct an array of ESLint flat config items. */
191
+ /**
192
+ * Construct an array of ESLint flat config items.
193
+ */
192
194
  declare function so1ve(options?: Options, ...userConfigs: (ConfigItem | ConfigItem[])[]): ConfigItem[];
193
195
 
194
196
  declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
@@ -218,8 +220,6 @@ declare const GLOB_TESTS: string[];
218
220
  declare const GLOB_ALL_SRC: string[];
219
221
  declare const GLOB_EXCLUDE: string[];
220
222
 
221
- /** Combine array and non-array configs into a single array. */
222
- declare const combine: (...configs: (ConfigItem | ConfigItem[])[]) => ConfigItem[];
223
223
  declare const renameRules: (rules: Record<string, any>, from: string, to: string) => {
224
224
  [k: string]: any;
225
225
  };
@@ -227,4 +227,4 @@ declare function recordRulesStateConfigs(configs: ConfigItem[]): ConfigItem[];
227
227
  declare function recordRulesState(rules: ConfigItem["rules"]): ConfigItem["rules"];
228
228
  declare function warnUnnecessaryOffRules(): void;
229
229
 
230
- 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, OptionsTypeScript, RenamedRules, 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 };
230
+ 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
@@ -924,7 +924,6 @@ const toml = ({ overrides } = {}) => [
924
924
  }
925
925
  ];
926
926
 
927
- const combine = (...configs) => configs.flatMap((config) => Array.isArray(config) ? config : [config]);
928
927
  const renameRules = (rules, from, to) => Object.fromEntries(
929
928
  Object.entries(rules).map(([key, value]) => {
930
929
  if (key.startsWith(from)) {
@@ -968,8 +967,7 @@ function warnUnnecessaryOffRules() {
968
967
  function typescript({
969
968
  componentExts = [],
970
969
  parserOptions,
971
- overrides,
972
- tsconfigPath
970
+ overrides
973
971
  } = {}) {
974
972
  const typeAwareRules = {
975
973
  "etc/no-assign-mutated-array": "error",
@@ -1022,12 +1020,7 @@ function typescript({
1022
1020
  parserOptions: {
1023
1021
  sourceType: "module",
1024
1022
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1025
- // Disable this because it doesn't work well with vue
1026
- // EXPERIMENTAL_useProjectService: true,
1027
- ...tsconfigPath ? {
1028
- project: [tsconfigPath],
1029
- tsconfigRootDir: process.cwd()
1030
- } : {},
1023
+ EXPERIMENTAL_useProjectService: true,
1031
1024
  // eslint-disable-next-line ts/no-unnecessary-type-assertion
1032
1025
  ...parserOptions
1033
1026
  }
@@ -1173,7 +1166,7 @@ function typescript({
1173
1166
  "ts/no-non-null-asserted-nullish-coalescing": "error",
1174
1167
  // handled by unused-imports/no-unused-imports
1175
1168
  "ts/no-unused-vars": "off",
1176
- ...tsconfigPath ? typeAwareRules : {},
1169
+ ...typeAwareRules,
1177
1170
  ...overrides
1178
1171
  }
1179
1172
  },
@@ -1490,11 +1483,11 @@ function so1ve(options = {}, ...userConfigs) {
1490
1483
  const {
1491
1484
  vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
1492
1485
  solid: enableSolid = isPackageExists("solid-js"),
1486
+ typescript: enableTypeScript = isPackageExists("typescript"),
1493
1487
  gitignore: enableGitignore = true,
1494
1488
  overrides = {},
1495
1489
  componentExts = []
1496
1490
  } = options;
1497
- let { typescript: enableTypeScript = isPackageExists("typescript") } = options;
1498
1491
  const configs = [];
1499
1492
  if (enableGitignore) {
1500
1493
  if (typeof enableGitignore === "boolean") {
@@ -1522,16 +1515,10 @@ function so1ve(options = {}, ...userConfigs) {
1522
1515
  componentExts.push("vue");
1523
1516
  }
1524
1517
  if (enableTypeScript) {
1525
- if (typeof enableTypeScript !== "object") {
1526
- enableTypeScript = {
1527
- tsconfigPath: "tsconfig.json"
1528
- };
1529
- }
1530
1518
  configs.push(
1531
1519
  typescript({
1532
1520
  componentExts,
1533
- overrides: overrides.typescript,
1534
- ...enableTypeScript
1521
+ overrides: overrides.typescript
1535
1522
  })
1536
1523
  );
1537
1524
  }
@@ -1595,8 +1582,8 @@ function so1ve(options = {}, ...userConfigs) {
1595
1582
  if (Object.keys(fusedConfig).length > 0) {
1596
1583
  configs.push([fusedConfig]);
1597
1584
  }
1598
- const merged = combine(...configs, ...userConfigs);
1585
+ const merged = [...configs, ...userConfigs].flat();
1599
1586
  return merged;
1600
1587
  }
1601
1588
 
1602
- 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 };
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, 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.15",
3
+ "version": "1.0.0-alpha.17",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "description": "Ray's eslint config.",
6
6
  "keywords": [
@@ -70,8 +70,8 @@
70
70
  "toml-eslint-parser": "^0.6.0",
71
71
  "vue-eslint-parser": "^9.3.1",
72
72
  "yaml-eslint-parser": "^1.2.2",
73
- "@so1ve/eslint-plugin": "1.0.0-alpha.15",
74
- "@so1ve/eslint-plugin-sort-imports": "1.0.0-alpha.15"
73
+ "@so1ve/eslint-plugin": "1.0.0-alpha.17",
74
+ "@so1ve/eslint-plugin-sort-imports": "1.0.0-alpha.17"
75
75
  },
76
76
  "devDependencies": {
77
77
  "eslint": "^8.46.0"