katon-labs-eslint-config 0.0.5-alpha.2 → 0.0.5-alpha.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.cjs CHANGED
@@ -163,6 +163,13 @@ var GLOB_EXCLUDE = [
163
163
  ];
164
164
 
165
165
  // src/configs/typescript.ts
166
+ var getRulesFromConfigs = (config) => {
167
+ const array = Array.isArray(config) ? config : [config];
168
+ const object = array.reduce((acc, item) => {
169
+ return { ...acc, ...item.rules };
170
+ }, {});
171
+ return object;
172
+ };
166
173
  function typescript(options) {
167
174
  const files = [GLOB_TS, GLOB_TSX, GLOB_VUE];
168
175
  const fileTypeAware = options?.fileTypeAware ?? [GLOB_TS, GLOB_TSX, GLOB_VUE];
@@ -226,12 +233,67 @@ function typescript(options) {
226
233
  files,
227
234
  name: "katon-labs/typescript/rules",
228
235
  rules: {
236
+ ...getRulesFromConfigs(import_eslint_plugin.default.configs["flat/recommended"]),
237
+ // Type-aware rules
238
+ ...tsconfigPath ? getRulesFromConfigs(import_eslint_plugin.default.configs["flat/recommended-type-checked-only"]) : {},
239
+ ...getRulesFromConfigs(import_eslint_plugin.default.configs["flat/strict"]),
229
240
  ...import_eslint_plugin.default.configs["eslint-recommended"].overrides[0].rules,
230
241
  ...import_eslint_plugin.default.configs.strict.rules,
242
+ // Include typescript eslint rules in *.vue files
243
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
244
+ "constructor-super": "off",
245
+ // ts(2335) & ts(2377)
246
+ "getter-return": "off",
247
+ // ts(2378)
248
+ "no-const-assign": "off",
249
+ // ts(2588)
250
+ "no-dupe-args": "off",
251
+ // ts(2300)
231
252
  "no-dupe-class-members": "off",
253
+ // ts(2393) & ts(2300)
254
+ "no-dupe-keys": "off",
255
+ // ts(1117)
256
+ "no-func-assign": "off",
257
+ // ts(2539)
258
+ "no-import-assign": "off",
259
+ // ts(2539) & ts(2540)
260
+ "no-new-symbol": "off",
261
+ // ts(7009)
262
+ "no-obj-calls": "off",
263
+ // ts(2349)
232
264
  "no-redeclare": "off",
233
- "no-use-before-define": "off",
234
- "no-useless-constructor": "off",
265
+ // ts(2451)
266
+ "no-setter-return": "off",
267
+ // ts(2408)
268
+ "no-this-before-super": "off",
269
+ // ts(2376)
270
+ "no-undef": "off",
271
+ // ts(2304)
272
+ "no-unreachable": "off",
273
+ // ts(7027)
274
+ "no-unsafe-negation": "off",
275
+ // ts(2365) & ts(2360) & ts(2358)
276
+ "no-var": "error",
277
+ // ts transpiles let/const to var, so no need for vars any more
278
+ "prefer-const": "error",
279
+ // ts provides better types with const
280
+ "prefer-rest-params": "error",
281
+ // ts provides better types with rest args over arguments
282
+ "prefer-spread": "error",
283
+ // ts transpiles spread to apply, so no need for manual apply
284
+ "valid-typeof": "off",
285
+ // ts(2367)
286
+ "no-unused-vars": "off",
287
+ // ts takes care of this
288
+ "@typescript-eslint/no-non-null-assertion": "off",
289
+ "@typescript-eslint/no-unused-vars": ["error", {
290
+ args: "after-used",
291
+ argsIgnorePattern: "^_",
292
+ ignoreRestSiblings: true,
293
+ vars: "all",
294
+ varsIgnorePattern: "^_"
295
+ }],
296
+ "@typescript-eslint/no-import-type-side-effects": "error",
235
297
  "@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
236
298
  "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
237
299
  "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: true, prefer: "type-imports" }],
@@ -241,14 +303,7 @@ function typescript(options) {
241
303
  "@typescript-eslint/no-explicit-any": "off",
242
304
  "@typescript-eslint/no-duplicate-type-constituents": "error"
243
305
  }
244
- },
245
- ...isTypeAware ? [{
246
- files: fileTypeAware,
247
- name: "katon-labs/typescript/typeaware-rules",
248
- rules: {
249
- ...typeAwareRules
250
- }
251
- }] : []
306
+ }
252
307
  ];
253
308
  }
254
309
 
@@ -268,6 +323,15 @@ function vue() {
268
323
  // This allows Vue plugin to work with auto imports
269
324
  // https://github.com/vuejs/eslint-plugin-vue/pull/2422
270
325
  languageOptions: {
326
+ parserOptions: {
327
+ ecmaVersion: "latest",
328
+ extraFileExtensions: [".vue"],
329
+ parser: import_parser2.default,
330
+ sourceType: "module",
331
+ ecmaFeatures: {
332
+ jsx: true
333
+ }
334
+ },
271
335
  globals: {
272
336
  computed: "readonly",
273
337
  defineEmits: "readonly",
@@ -550,7 +614,7 @@ function ignores() {
550
614
  function katonlabs(options = {}, ...userConfigs) {
551
615
  const { ts } = options;
552
616
  const configs = [];
553
- configs.push(typescript(ts));
617
+ configs.push(typescript(ts ? ts : void 0));
554
618
  configs.push(vue());
555
619
  configs.push(imports());
556
620
  configs.push(unicorn());
package/dist/index.js CHANGED
@@ -87,6 +87,13 @@ var GLOB_EXCLUDE = [
87
87
  ];
88
88
 
89
89
  // src/configs/typescript.ts
90
+ var getRulesFromConfigs = (config) => {
91
+ const array = Array.isArray(config) ? config : [config];
92
+ const object = array.reduce((acc, item) => {
93
+ return { ...acc, ...item.rules };
94
+ }, {});
95
+ return object;
96
+ };
90
97
  function typescript(options) {
91
98
  const files = [GLOB_TS, GLOB_TSX, GLOB_VUE];
92
99
  const fileTypeAware = options?.fileTypeAware ?? [GLOB_TS, GLOB_TSX, GLOB_VUE];
@@ -150,12 +157,67 @@ function typescript(options) {
150
157
  files,
151
158
  name: "katon-labs/typescript/rules",
152
159
  rules: {
160
+ ...getRulesFromConfigs(pluginTS.configs["flat/recommended"]),
161
+ // Type-aware rules
162
+ ...tsconfigPath ? getRulesFromConfigs(pluginTS.configs["flat/recommended-type-checked-only"]) : {},
163
+ ...getRulesFromConfigs(pluginTS.configs["flat/strict"]),
153
164
  ...pluginTS.configs["eslint-recommended"].overrides[0].rules,
154
165
  ...pluginTS.configs.strict.rules,
166
+ // Include typescript eslint rules in *.vue files
167
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
168
+ "constructor-super": "off",
169
+ // ts(2335) & ts(2377)
170
+ "getter-return": "off",
171
+ // ts(2378)
172
+ "no-const-assign": "off",
173
+ // ts(2588)
174
+ "no-dupe-args": "off",
175
+ // ts(2300)
155
176
  "no-dupe-class-members": "off",
177
+ // ts(2393) & ts(2300)
178
+ "no-dupe-keys": "off",
179
+ // ts(1117)
180
+ "no-func-assign": "off",
181
+ // ts(2539)
182
+ "no-import-assign": "off",
183
+ // ts(2539) & ts(2540)
184
+ "no-new-symbol": "off",
185
+ // ts(7009)
186
+ "no-obj-calls": "off",
187
+ // ts(2349)
156
188
  "no-redeclare": "off",
157
- "no-use-before-define": "off",
158
- "no-useless-constructor": "off",
189
+ // ts(2451)
190
+ "no-setter-return": "off",
191
+ // ts(2408)
192
+ "no-this-before-super": "off",
193
+ // ts(2376)
194
+ "no-undef": "off",
195
+ // ts(2304)
196
+ "no-unreachable": "off",
197
+ // ts(7027)
198
+ "no-unsafe-negation": "off",
199
+ // ts(2365) & ts(2360) & ts(2358)
200
+ "no-var": "error",
201
+ // ts transpiles let/const to var, so no need for vars any more
202
+ "prefer-const": "error",
203
+ // ts provides better types with const
204
+ "prefer-rest-params": "error",
205
+ // ts provides better types with rest args over arguments
206
+ "prefer-spread": "error",
207
+ // ts transpiles spread to apply, so no need for manual apply
208
+ "valid-typeof": "off",
209
+ // ts(2367)
210
+ "no-unused-vars": "off",
211
+ // ts takes care of this
212
+ "@typescript-eslint/no-non-null-assertion": "off",
213
+ "@typescript-eslint/no-unused-vars": ["error", {
214
+ args: "after-used",
215
+ argsIgnorePattern: "^_",
216
+ ignoreRestSiblings: true,
217
+ vars: "all",
218
+ varsIgnorePattern: "^_"
219
+ }],
220
+ "@typescript-eslint/no-import-type-side-effects": "error",
159
221
  "@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
160
222
  "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
161
223
  "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: true, prefer: "type-imports" }],
@@ -165,14 +227,7 @@ function typescript(options) {
165
227
  "@typescript-eslint/no-explicit-any": "off",
166
228
  "@typescript-eslint/no-duplicate-type-constituents": "error"
167
229
  }
168
- },
169
- ...isTypeAware ? [{
170
- files: fileTypeAware,
171
- name: "katon-labs/typescript/typeaware-rules",
172
- rules: {
173
- ...typeAwareRules
174
- }
175
- }] : []
230
+ }
176
231
  ];
177
232
  }
178
233
 
@@ -192,6 +247,15 @@ function vue() {
192
247
  // This allows Vue plugin to work with auto imports
193
248
  // https://github.com/vuejs/eslint-plugin-vue/pull/2422
194
249
  languageOptions: {
250
+ parserOptions: {
251
+ ecmaVersion: "latest",
252
+ extraFileExtensions: [".vue"],
253
+ parser: parserTS2,
254
+ sourceType: "module",
255
+ ecmaFeatures: {
256
+ jsx: true
257
+ }
258
+ },
195
259
  globals: {
196
260
  computed: "readonly",
197
261
  defineEmits: "readonly",
@@ -474,7 +538,7 @@ function ignores() {
474
538
  function katonlabs(options = {}, ...userConfigs) {
475
539
  const { ts } = options;
476
540
  const configs = [];
477
- configs.push(typescript(ts));
541
+ configs.push(typescript(ts ? ts : void 0));
478
542
  configs.push(vue());
479
543
  configs.push(imports());
480
544
  configs.push(unicorn());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "katon-labs-eslint-config",
3
3
  "type": "module",
4
- "version": "0.0.5-alpha.2",
4
+ "version": "0.0.5-alpha.3",
5
5
  "packageManager": "bun@1.1.27",
6
6
  "description": "Katon Labs's ESLint config",
7
7
  "author": "Alam Esa Wikanning Katon <naturaatom@gmail.com> (https://github.com/wikanonymous-dev/)",