@zjutjh/eslint-config 0.3.2 → 0.3.3

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.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Linter } from 'eslint';
2
+ import { ParserOptions } from '@typescript-eslint/parser';
2
3
 
3
4
  type OverridesConfigs = {
4
5
  vue?: Linter.RulesRecord;
@@ -7,10 +8,16 @@ type OverridesConfigs = {
7
8
  };
8
9
  type OptionsConfig = {
9
10
  vue?: boolean;
10
- ts?: boolean;
11
+ ts?: boolean | (OptionsOverrides & OptionsTypeScriptParserOptions);
11
12
  taro?: boolean;
12
13
  overrides?: OverridesConfigs;
13
14
  };
15
+ type OptionsOverrides = {
16
+ overrides: Linter.RulesRecord;
17
+ };
18
+ interface OptionsTypeScriptParserOptions {
19
+ parserOptions?: Partial<ParserOptions>;
20
+ }
14
21
 
15
22
  declare function zjutjh(options?: OptionsConfig): Promise<Linter.Config<Linter.RulesRecord>[]>;
16
23
 
package/dist/index.js CHANGED
@@ -122,6 +122,9 @@ async function ensurePackages(packages) {
122
122
  throw new Error(message);
123
123
  }
124
124
  }
125
+ function resolveSubOptions(options, key) {
126
+ return typeof options[key] === "boolean" ? {} : options[key] || {};
127
+ }
125
128
  function getOverrides(options, key) {
126
129
  return {
127
130
  ...options.overrides?.[key]
@@ -130,6 +133,10 @@ function getOverrides(options, key) {
130
133
 
131
134
  // src/configs/typescript.ts
132
135
  async function typescript(options) {
136
+ const {
137
+ overrides,
138
+ parserOptions
139
+ } = options;
133
140
  await ensurePackages([
134
141
  "@typescript-eslint/eslint-plugin",
135
142
  "@typescript-eslint/parser"
@@ -160,7 +167,8 @@ async function typescript(options) {
160
167
  allowDefaultProject: ["./*.js"],
161
168
  defaultProject: "./tsconfig.json"
162
169
  },
163
- tsconfigRootDir: process.cwd()
170
+ tsconfigRootDir: process.cwd(),
171
+ ...parserOptions
164
172
  }
165
173
  }
166
174
  },
@@ -176,7 +184,7 @@ async function typescript(options) {
176
184
  allowTaggedTemplates: true,
177
185
  allowTernary: true
178
186
  }],
179
- ...options.overrides
187
+ ...overrides
180
188
  }
181
189
  }
182
190
  ];
@@ -244,13 +252,17 @@ async function zjutjh(options = {}) {
244
252
  stylistic({ overrides: getOverrides(options, "stylistic") })
245
253
  );
246
254
  configs.push(imports());
255
+ const typescriptOptions = resolveSubOptions(options, "ts");
247
256
  if (enableTs) configs.push(
248
- await typescript({ overrides: getOverrides(options, "ts") })
257
+ await typescript({
258
+ ...typescriptOptions,
259
+ overrides: getOverrides(options, "ts")
260
+ })
249
261
  );
250
262
  if (enableVue) {
251
263
  configs.push(
252
264
  await vue({
253
- ts: enableTs,
265
+ ts: !!enableTs,
254
266
  taro: enableTaro,
255
267
  overrides: getOverrides(options, "vue")
256
268
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zjutjh/eslint-config",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.3.3",
5
5
  "license": "ISC",
6
6
  "author": "zjutjh",
7
7
  "description": "Eslint config used by zjutjh",