@so1ve/eslint-config 1.0.1 → 1.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/dist/index.cjs CHANGED
@@ -1066,9 +1066,6 @@ function typescript({
1066
1066
  parserOptions: {
1067
1067
  sourceType: "module",
1068
1068
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1069
- // EXPERIMENTAL_useProjectService: true,
1070
- project: true,
1071
- tsconfigRootDir: process.cwd(),
1072
1069
  ...parserOptions
1073
1070
  }
1074
1071
  },
@@ -1213,22 +1210,33 @@ function typescript({
1213
1210
  "ts/no-non-null-asserted-nullish-coalescing": "error",
1214
1211
  // handled by unused-imports/no-unused-imports
1215
1212
  "ts/no-unused-vars": "off",
1216
- ...typeAwareRules,
1217
1213
  ...overrides
1218
1214
  }
1219
1215
  },
1220
1216
  {
1221
- files: [GLOB_MARKDOWN_CODE],
1217
+ files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
1218
+ ignores: [GLOB_MARKDOWN_CODE],
1222
1219
  languageOptions: {
1223
1220
  parser: parserTs__default["default"],
1224
1221
  parserOptions: {
1225
- sourceType: "module"
1222
+ sourceType: "module",
1223
+ // EXPERIMENTAL_useProjectService: true,
1224
+ project: true,
1225
+ tsconfigRootDir: process.cwd()
1226
+ }
1227
+ },
1228
+ settings: {
1229
+ "import/resolver": {
1230
+ node: {
1231
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
1232
+ },
1233
+ typescript: {
1234
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
1235
+ }
1226
1236
  }
1227
1237
  },
1228
1238
  rules: {
1229
- ...Object.fromEntries(
1230
- Object.keys(typeAwareRules).map((k) => [k, "off"])
1231
- )
1239
+ ...typeAwareRules
1232
1240
  }
1233
1241
  },
1234
1242
  {
@@ -1532,7 +1540,6 @@ function so1ve(options = {}, ...userConfigs) {
1532
1540
  solid: enableSolid = localPkg.isPackageExists("solid-js"),
1533
1541
  typescript: enableTypeScript = localPkg.isPackageExists("typescript"),
1534
1542
  gitignore: enableGitignore = true,
1535
- overrides = {},
1536
1543
  componentExts = []
1537
1544
  } = options;
1538
1545
  const configs = [];
@@ -1548,7 +1555,7 @@ function so1ve(options = {}, ...userConfigs) {
1548
1555
  configs.push(
1549
1556
  ignores(),
1550
1557
  javascript({
1551
- overrides: overrides.javascript
1558
+ overrides: getOverrides(options, "javascript")
1552
1559
  }),
1553
1560
  comments(),
1554
1561
  node(),
@@ -1566,21 +1573,21 @@ function so1ve(options = {}, ...userConfigs) {
1566
1573
  configs.push(
1567
1574
  typescript({
1568
1575
  componentExts,
1569
- overrides: overrides.typescript
1576
+ overrides: getOverrides(options, "typescript")
1570
1577
  })
1571
1578
  );
1572
1579
  }
1573
1580
  if ((_a = options.test) != null ? _a : true) {
1574
1581
  configs.push(
1575
1582
  test({
1576
- overrides: overrides.test
1583
+ overrides: getOverrides(options, "test")
1577
1584
  })
1578
1585
  );
1579
1586
  }
1580
1587
  if (enableVue) {
1581
1588
  configs.push(
1582
1589
  vue({
1583
- overrides: overrides.vue,
1590
+ overrides: getOverrides(options, "vue"),
1584
1591
  typescript: !!enableTypeScript
1585
1592
  })
1586
1593
  );
@@ -1588,7 +1595,7 @@ function so1ve(options = {}, ...userConfigs) {
1588
1595
  if (enableSolid) {
1589
1596
  configs.push(
1590
1597
  solid({
1591
- overrides: overrides.solid,
1598
+ overrides: getOverrides(options, "solid"),
1592
1599
  typescript: !!enableTypeScript
1593
1600
  })
1594
1601
  );
@@ -1599,14 +1606,14 @@ function so1ve(options = {}, ...userConfigs) {
1599
1606
  if ((_c = options.toml) != null ? _c : true) {
1600
1607
  configs.push(
1601
1608
  toml({
1602
- overrides: overrides.toml
1609
+ overrides: getOverrides(options, "toml")
1603
1610
  })
1604
1611
  );
1605
1612
  }
1606
1613
  if ((_d = options.yaml) != null ? _d : true) {
1607
1614
  configs.push(
1608
1615
  yaml({
1609
- overrides: overrides.yaml
1616
+ overrides: getOverrides(options, "yaml")
1610
1617
  })
1611
1618
  );
1612
1619
  }
@@ -1614,7 +1621,7 @@ function so1ve(options = {}, ...userConfigs) {
1614
1621
  configs.push(
1615
1622
  mdx({
1616
1623
  componentExts,
1617
- overrides: overrides.mdx
1624
+ overrides: getOverrides(options, "mdx")
1618
1625
  })
1619
1626
  );
1620
1627
  }
@@ -1633,6 +1640,16 @@ function so1ve(options = {}, ...userConfigs) {
1633
1640
  const merged = [...configs, ...userConfigs].flat();
1634
1641
  return merged;
1635
1642
  }
1643
+ const resolveSubOptions = (options, key) => typeof options[key] === "boolean" ? {} : options[key] || {};
1644
+ function getOverrides(options, key) {
1645
+ var _a;
1646
+ const sub = resolveSubOptions(options, key);
1647
+ return {
1648
+ // eslint-disable-next-line etc/no-deprecated
1649
+ ...(_a = options.overrides) == null ? void 0 : _a[key],
1650
+ ..."overrides" in sub ? sub.overrides : {}
1651
+ };
1652
+ }
1636
1653
 
1637
1654
  Object.defineProperty(exports, 'pluginComments', {
1638
1655
  enumerable: true,
@@ -1791,6 +1808,7 @@ exports.GLOB_VUE = GLOB_VUE;
1791
1808
  exports.GLOB_YAML = GLOB_YAML;
1792
1809
  exports.comments = comments;
1793
1810
  exports.formatting = formatting;
1811
+ exports.getOverrides = getOverrides;
1794
1812
  exports.html = html;
1795
1813
  exports.ignores = ignores;
1796
1814
  exports.imports = imports;
@@ -1803,6 +1821,7 @@ exports.promise = promise;
1803
1821
  exports.recordRulesState = recordRulesState;
1804
1822
  exports.recordRulesStateConfigs = recordRulesStateConfigs;
1805
1823
  exports.renameRules = renameRules;
1824
+ exports.resolveSubOptions = resolveSubOptions;
1806
1825
  exports.so1ve = so1ve;
1807
1826
  exports.solid = solid;
1808
1827
  exports.sortImports = sortImports;
package/dist/index.d.ts CHANGED
@@ -65,6 +65,10 @@ interface Options extends OptionsComponentExts {
65
65
  * @see https://github.com/antfu/eslint-config-flat-gitignore
66
66
  */
67
67
  gitignore?: boolean | FlatGitignoreOptions;
68
+ /**
69
+ * Core rules. Can't be disabled.
70
+ */
71
+ javascript?: OptionsOverrides;
68
72
  /**
69
73
  * Enable TypeScript support.
70
74
  *
@@ -72,57 +76,59 @@ interface Options extends OptionsComponentExts {
72
76
  *
73
77
  * @default auto-detect based on the dependencies
74
78
  */
75
- typescript?: boolean;
79
+ typescript?: boolean | OptionsOverrides;
76
80
  /**
77
81
  * Enable test support.
78
82
  *
79
83
  * @default true
80
84
  */
81
- test?: boolean;
85
+ test?: boolean | OptionsOverrides;
82
86
  /**
83
87
  * Enable Vue support.
84
88
  *
85
89
  * @default auto-detect based on the dependencies
86
90
  */
87
- vue?: boolean;
91
+ vue?: boolean | OptionsOverrides;
88
92
  /**
89
93
  * Enable Solid.js support.
90
94
  *
91
95
  * @default auto-detect based on the dependencies
92
96
  */
93
- solid?: boolean;
97
+ solid?: boolean | OptionsOverrides;
94
98
  /**
95
99
  * Enable JSONC support.
96
100
  *
97
101
  * @default true
98
102
  */
99
- jsonc?: boolean;
103
+ jsonc?: boolean | OptionsOverrides;
100
104
  /**
101
105
  * Enable YAML support.
102
106
  *
103
107
  * @default true
104
108
  */
105
- yaml?: boolean;
109
+ yaml?: boolean | OptionsOverrides;
106
110
  /**
107
111
  * Enable TOML support.
108
112
  *
109
113
  * @default true
110
114
  */
111
- toml?: boolean;
115
+ toml?: boolean | OptionsOverrides;
112
116
  /**
113
117
  * Enable markdown and mdx support.
114
118
  *
115
119
  * @default true
116
120
  */
117
- mdx?: boolean;
121
+ mdx?: boolean | OptionsOverrides;
118
122
  /**
119
123
  * Enable formatting rules.
120
124
  *
121
125
  * @default true
122
126
  */
123
- formatting?: boolean;
127
+ formatting?: boolean | OptionsOverrides;
124
128
  /**
125
129
  * Provide overrides for rules for each integration.
130
+ *
131
+ * @deprecated Use `overrides` option in each integration key instead
126
132
  */
127
133
  overrides?: {
128
134
  javascript?: ConfigItem["rules"];
@@ -194,6 +200,9 @@ declare const yaml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
194
200
  * Construct an array of ESLint flat config items.
195
201
  */
196
202
  declare function so1ve(options?: Options, ...userConfigs: (ConfigItem | ConfigItem[])[]): ConfigItem[];
203
+ type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
204
+ declare const resolveSubOptions: <K extends keyof Options>(options: Options & ConfigItem, key: K) => ResolvedOptions<Options[K]>;
205
+ declare function getOverrides<K extends keyof Options>(options: Options, key: K): any;
197
206
 
198
207
  declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
199
208
  declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
@@ -229,4 +238,4 @@ declare function recordRulesStateConfigs(configs: ConfigItem[]): ConfigItem[];
229
238
  declare function recordRulesState(rules: ConfigItem["rules"]): ConfigItem["rules"];
230
239
  declare function warnUnnecessaryOffRules(): void;
231
240
 
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 };
241
+ 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, ResolvedOptions, comments, formatting, getOverrides, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, resolveSubOptions, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
package/dist/index.mjs CHANGED
@@ -1037,9 +1037,6 @@ function typescript({
1037
1037
  parserOptions: {
1038
1038
  sourceType: "module",
1039
1039
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1040
- // EXPERIMENTAL_useProjectService: true,
1041
- project: true,
1042
- tsconfigRootDir: process.cwd(),
1043
1040
  ...parserOptions
1044
1041
  }
1045
1042
  },
@@ -1184,22 +1181,33 @@ function typescript({
1184
1181
  "ts/no-non-null-asserted-nullish-coalescing": "error",
1185
1182
  // handled by unused-imports/no-unused-imports
1186
1183
  "ts/no-unused-vars": "off",
1187
- ...typeAwareRules,
1188
1184
  ...overrides
1189
1185
  }
1190
1186
  },
1191
1187
  {
1192
- files: [GLOB_MARKDOWN_CODE],
1188
+ files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
1189
+ ignores: [GLOB_MARKDOWN_CODE],
1193
1190
  languageOptions: {
1194
1191
  parser: parserTs,
1195
1192
  parserOptions: {
1196
- sourceType: "module"
1193
+ sourceType: "module",
1194
+ // EXPERIMENTAL_useProjectService: true,
1195
+ project: true,
1196
+ tsconfigRootDir: process.cwd()
1197
+ }
1198
+ },
1199
+ settings: {
1200
+ "import/resolver": {
1201
+ node: {
1202
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
1203
+ },
1204
+ typescript: {
1205
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
1206
+ }
1197
1207
  }
1198
1208
  },
1199
1209
  rules: {
1200
- ...Object.fromEntries(
1201
- Object.keys(typeAwareRules).map((k) => [k, "off"])
1202
- )
1210
+ ...typeAwareRules
1203
1211
  }
1204
1212
  },
1205
1213
  {
@@ -1503,7 +1511,6 @@ function so1ve(options = {}, ...userConfigs) {
1503
1511
  solid: enableSolid = isPackageExists("solid-js"),
1504
1512
  typescript: enableTypeScript = isPackageExists("typescript"),
1505
1513
  gitignore: enableGitignore = true,
1506
- overrides = {},
1507
1514
  componentExts = []
1508
1515
  } = options;
1509
1516
  const configs = [];
@@ -1519,7 +1526,7 @@ function so1ve(options = {}, ...userConfigs) {
1519
1526
  configs.push(
1520
1527
  ignores(),
1521
1528
  javascript({
1522
- overrides: overrides.javascript
1529
+ overrides: getOverrides(options, "javascript")
1523
1530
  }),
1524
1531
  comments(),
1525
1532
  node(),
@@ -1537,21 +1544,21 @@ function so1ve(options = {}, ...userConfigs) {
1537
1544
  configs.push(
1538
1545
  typescript({
1539
1546
  componentExts,
1540
- overrides: overrides.typescript
1547
+ overrides: getOverrides(options, "typescript")
1541
1548
  })
1542
1549
  );
1543
1550
  }
1544
1551
  if ((_a = options.test) != null ? _a : true) {
1545
1552
  configs.push(
1546
1553
  test({
1547
- overrides: overrides.test
1554
+ overrides: getOverrides(options, "test")
1548
1555
  })
1549
1556
  );
1550
1557
  }
1551
1558
  if (enableVue) {
1552
1559
  configs.push(
1553
1560
  vue({
1554
- overrides: overrides.vue,
1561
+ overrides: getOverrides(options, "vue"),
1555
1562
  typescript: !!enableTypeScript
1556
1563
  })
1557
1564
  );
@@ -1559,7 +1566,7 @@ function so1ve(options = {}, ...userConfigs) {
1559
1566
  if (enableSolid) {
1560
1567
  configs.push(
1561
1568
  solid({
1562
- overrides: overrides.solid,
1569
+ overrides: getOverrides(options, "solid"),
1563
1570
  typescript: !!enableTypeScript
1564
1571
  })
1565
1572
  );
@@ -1570,14 +1577,14 @@ function so1ve(options = {}, ...userConfigs) {
1570
1577
  if ((_c = options.toml) != null ? _c : true) {
1571
1578
  configs.push(
1572
1579
  toml({
1573
- overrides: overrides.toml
1580
+ overrides: getOverrides(options, "toml")
1574
1581
  })
1575
1582
  );
1576
1583
  }
1577
1584
  if ((_d = options.yaml) != null ? _d : true) {
1578
1585
  configs.push(
1579
1586
  yaml({
1580
- overrides: overrides.yaml
1587
+ overrides: getOverrides(options, "yaml")
1581
1588
  })
1582
1589
  );
1583
1590
  }
@@ -1585,7 +1592,7 @@ function so1ve(options = {}, ...userConfigs) {
1585
1592
  configs.push(
1586
1593
  mdx({
1587
1594
  componentExts,
1588
- overrides: overrides.mdx
1595
+ overrides: getOverrides(options, "mdx")
1589
1596
  })
1590
1597
  );
1591
1598
  }
@@ -1604,5 +1611,15 @@ function so1ve(options = {}, ...userConfigs) {
1604
1611
  const merged = [...configs, ...userConfigs].flat();
1605
1612
  return merged;
1606
1613
  }
1614
+ const resolveSubOptions = (options, key) => typeof options[key] === "boolean" ? {} : options[key] || {};
1615
+ function getOverrides(options, key) {
1616
+ var _a;
1617
+ const sub = resolveSubOptions(options, key);
1618
+ return {
1619
+ // eslint-disable-next-line etc/no-deprecated
1620
+ ...(_a = options.overrides) == null ? void 0 : _a[key],
1621
+ ..."overrides" in sub ? sub.overrides : {}
1622
+ };
1623
+ }
1607
1624
 
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 };
1625
+ 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, getOverrides, html, ignores, imports, javascript, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, resolveSubOptions, 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.1",
3
+ "version": "1.1.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "description": "Ray's eslint config.",
6
6
  "keywords": [
@@ -71,8 +71,8 @@
71
71
  "toml-eslint-parser": "^0.6.0",
72
72
  "vue-eslint-parser": "^9.3.1",
73
73
  "yaml-eslint-parser": "^1.2.2",
74
- "@so1ve/eslint-plugin": "1.0.1",
75
- "@so1ve/eslint-plugin-sort-imports": "1.0.1"
74
+ "@so1ve/eslint-plugin": "1.1.0",
75
+ "@so1ve/eslint-plugin-sort-imports": "1.1.0"
76
76
  },
77
77
  "devDependencies": {
78
78
  "eslint": "^8.46.0"