@dr.pogodin/eslint-configs 0.2.5 → 0.2.6

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.
@@ -11,7 +11,10 @@ import babelPlugin from '@babel/eslint-plugin';
11
11
  import js from '@eslint/js';
12
12
  import stylisticPlugin from '@stylistic/eslint-plugin';
13
13
 
14
- export function newJsConfig({ noPerf } = {}) {
14
+ export function newJsConfig({
15
+ noPerf,
16
+ perfectionistTsConfig,
17
+ } = {}) {
15
18
  const extentions = [
16
19
  'js/recommended',
17
20
  '@stylistic/recommended',
@@ -296,7 +299,7 @@ export function newJsConfig({ noPerf } = {}) {
296
299
  partitionByNewLine: true,
297
300
  };
298
301
 
299
- rules['perfectionist/sort-imports'] = ['error', {
302
+ const sortImporsOptions = {
300
303
  alphabet,
301
304
  groups: [
302
305
  'builtin',
@@ -312,7 +315,13 @@ export function newJsConfig({ noPerf } = {}) {
312
315
  newlinesInside: 'ignore',
313
316
  partitionByNewLine: false,
314
317
  type: 'custom',
315
- }];
318
+ };
319
+
320
+ if (perfectionistTsConfig) {
321
+ sortImporsOptions.tsconfig = perfectionistTsConfig;
322
+ }
323
+
324
+ rules['perfectionist/sort-imports'] = ['error', sortImporsOptions];
316
325
  }
317
326
 
318
327
  return defineConfig([{
@@ -1,19 +1,17 @@
1
1
  import { defineConfig } from 'eslint/config';
2
2
  import tsEsLint from 'typescript-eslint';
3
3
 
4
- import { javascriptNoPerf, newJsConfig } from './javascript.js';
4
+ import { newJsConfig } from './javascript.js';
5
5
 
6
6
  function newConfig({ noPerf } = {}) {
7
- const jsConfig = newJsConfig();
8
-
9
- // TODO: It is not the best way to modify this rule's settings,
10
- // it will be better to expose this as an option of newJsConfig()
11
- // function.
12
- jsConfig[0].rules['perfectionist/sort-imports'][1].tsconfig = {
13
- rootDir: '.',
14
- };
7
+ const jsConfig = newJsConfig({
8
+ noPerf,
9
+ perfectionistTsConfig: {
10
+ rootDir: '.',
11
+ },
12
+ });
15
13
 
16
- let extentions = [
14
+ const extentions = [
17
15
  jsConfig,
18
16
  tsEsLint.configs.recommendedTypeChecked,
19
17
  tsEsLint.configs.stylisticTypeChecked,
@@ -100,11 +98,7 @@ function newConfig({ noPerf } = {}) {
100
98
  '@typescript-eslint/use-unknown-in-catch-callback-variable': 'error',
101
99
  };
102
100
 
103
- if (noPerf) {
104
- extentions = [javascriptNoPerf, ...extentions];
105
- } else {
106
- extentions = [jsConfig, ...extentions];
107
-
101
+ if (!noPerf) {
108
102
  rules['adjacent-overload-signatures'] = 'off';
109
103
  }
110
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dr.pogodin/eslint-configs",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "ESLint configurations for TypeScript and/or React projects",
5
5
  "type": "module",
6
6
  "main": "./config/index.js",