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

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
@@ -979,7 +979,8 @@ function warnUnnecessaryOffRules() {
979
979
  function typescript({
980
980
  componentExts = [],
981
981
  parserOptions,
982
- overrides
982
+ overrides,
983
+ tsconfigPath
983
984
  } = {}) {
984
985
  const typeAwareRules = {
985
986
  "etc/no-assign-mutated-array": "error",
@@ -1032,7 +1033,12 @@ function typescript({
1032
1033
  parserOptions: {
1033
1034
  sourceType: "module",
1034
1035
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1035
- EXPERIMENTAL_useProjectService: true,
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
+ } : {},
1036
1042
  // eslint-disable-next-line ts/no-unnecessary-type-assertion
1037
1043
  ...parserOptions
1038
1044
  }
@@ -1178,7 +1184,7 @@ function typescript({
1178
1184
  "ts/no-non-null-asserted-nullish-coalescing": "error",
1179
1185
  // handled by unused-imports/no-unused-imports
1180
1186
  "ts/no-unused-vars": "off",
1181
- ...typeAwareRules,
1187
+ ...tsconfigPath ? typeAwareRules : {},
1182
1188
  ...overrides
1183
1189
  }
1184
1190
  },
@@ -1495,11 +1501,11 @@ function so1ve(options = {}, ...userConfigs) {
1495
1501
  const {
1496
1502
  vue: enableVue = VuePackages.some((i) => localPkg.isPackageExists(i)),
1497
1503
  solid: enableSolid = localPkg.isPackageExists("solid-js"),
1498
- typescript: enableTypeScript = localPkg.isPackageExists("typescript"),
1499
1504
  gitignore: enableGitignore = true,
1500
1505
  overrides = {},
1501
1506
  componentExts = []
1502
1507
  } = options;
1508
+ let { typescript: enableTypeScript = localPkg.isPackageExists("typescript") } = options;
1503
1509
  const configs = [];
1504
1510
  if (enableGitignore) {
1505
1511
  if (typeof enableGitignore === "boolean") {
@@ -1527,10 +1533,16 @@ function so1ve(options = {}, ...userConfigs) {
1527
1533
  componentExts.push("vue");
1528
1534
  }
1529
1535
  if (enableTypeScript) {
1536
+ if (typeof enableTypeScript !== "object") {
1537
+ enableTypeScript = {
1538
+ tsconfigPath: "tsconfig.json"
1539
+ };
1540
+ }
1530
1541
  configs.push(
1531
1542
  typescript({
1532
1543
  componentExts,
1533
- overrides: overrides.typescript
1544
+ overrides: overrides.typescript,
1545
+ ...enableTypeScript
1534
1546
  })
1535
1547
  );
1536
1548
  }
package/dist/index.d.ts CHANGED
@@ -39,9 +39,15 @@ interface OptionsComponentExts {
39
39
  /** Additional extensions for components. */
40
40
  componentExts?: string[];
41
41
  }
42
- interface OptionsTypeScriptParserOptions {
42
+ interface OptionsTypeScript {
43
43
  /** Additional parser options for TypeScript. */
44
44
  parserOptions?: Partial<ParserOptions>;
45
+ /**
46
+ * Path to `tsconfig.json`.
47
+ *
48
+ * @default "tsconfig.json"
49
+ */
50
+ tsconfigPath?: string;
45
51
  }
46
52
  interface OptionsHasTypeScript {
47
53
  typescript?: boolean;
@@ -66,7 +72,7 @@ interface Options extends OptionsComponentExts {
66
72
  *
67
73
  * @default auto-detect based on the dependencies
68
74
  */
69
- typescript?: boolean;
75
+ typescript?: boolean | OptionsTypeScript;
70
76
  /**
71
77
  * Enable test support.
72
78
  *
@@ -174,7 +180,7 @@ declare const test: ({ overrides }?: OptionsOverrides) => ConfigItem[];
174
180
 
175
181
  declare const toml: ({ overrides }?: OptionsOverrides) => ConfigItem[];
176
182
 
177
- declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): ConfigItem[];
183
+ declare function typescript({ componentExts, parserOptions, overrides, tsconfigPath, }?: OptionsTypeScript & OptionsComponentExts & OptionsOverrides): ConfigItem[];
178
184
 
179
185
  declare const unicorn: () => ConfigItem[];
180
186
 
@@ -221,4 +227,4 @@ declare function recordRulesStateConfigs(configs: ConfigItem[]): ConfigItem[];
221
227
  declare function recordRulesState(rules: ConfigItem["rules"]): ConfigItem["rules"];
222
228
  declare function warnUnnecessaryOffRules(): void;
223
229
 
224
- 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, 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, 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 };
package/dist/index.mjs CHANGED
@@ -968,7 +968,8 @@ function warnUnnecessaryOffRules() {
968
968
  function typescript({
969
969
  componentExts = [],
970
970
  parserOptions,
971
- overrides
971
+ overrides,
972
+ tsconfigPath
972
973
  } = {}) {
973
974
  const typeAwareRules = {
974
975
  "etc/no-assign-mutated-array": "error",
@@ -1021,7 +1022,12 @@ function typescript({
1021
1022
  parserOptions: {
1022
1023
  sourceType: "module",
1023
1024
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
1024
- EXPERIMENTAL_useProjectService: true,
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
+ } : {},
1025
1031
  // eslint-disable-next-line ts/no-unnecessary-type-assertion
1026
1032
  ...parserOptions
1027
1033
  }
@@ -1167,7 +1173,7 @@ function typescript({
1167
1173
  "ts/no-non-null-asserted-nullish-coalescing": "error",
1168
1174
  // handled by unused-imports/no-unused-imports
1169
1175
  "ts/no-unused-vars": "off",
1170
- ...typeAwareRules,
1176
+ ...tsconfigPath ? typeAwareRules : {},
1171
1177
  ...overrides
1172
1178
  }
1173
1179
  },
@@ -1484,11 +1490,11 @@ function so1ve(options = {}, ...userConfigs) {
1484
1490
  const {
1485
1491
  vue: enableVue = VuePackages.some((i) => isPackageExists(i)),
1486
1492
  solid: enableSolid = isPackageExists("solid-js"),
1487
- typescript: enableTypeScript = isPackageExists("typescript"),
1488
1493
  gitignore: enableGitignore = true,
1489
1494
  overrides = {},
1490
1495
  componentExts = []
1491
1496
  } = options;
1497
+ let { typescript: enableTypeScript = isPackageExists("typescript") } = options;
1492
1498
  const configs = [];
1493
1499
  if (enableGitignore) {
1494
1500
  if (typeof enableGitignore === "boolean") {
@@ -1516,10 +1522,16 @@ function so1ve(options = {}, ...userConfigs) {
1516
1522
  componentExts.push("vue");
1517
1523
  }
1518
1524
  if (enableTypeScript) {
1525
+ if (typeof enableTypeScript !== "object") {
1526
+ enableTypeScript = {
1527
+ tsconfigPath: "tsconfig.json"
1528
+ };
1529
+ }
1519
1530
  configs.push(
1520
1531
  typescript({
1521
1532
  componentExts,
1522
- overrides: overrides.typescript
1533
+ overrides: overrides.typescript,
1534
+ ...enableTypeScript
1523
1535
  })
1524
1536
  );
1525
1537
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-config",
3
- "version": "1.0.0-alpha.14",
3
+ "version": "1.0.0-alpha.15",
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.14",
74
- "@so1ve/eslint-plugin-sort-imports": "1.0.0-alpha.14"
73
+ "@so1ve/eslint-plugin": "1.0.0-alpha.15",
74
+ "@so1ve/eslint-plugin-sort-imports": "1.0.0-alpha.15"
75
75
  },
76
76
  "devDependencies": {
77
77
  "eslint": "^8.46.0"