@fullstacksjs/eslint-config 10.5.0 → 10.6.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/README.md CHANGED
@@ -70,6 +70,8 @@ interface Modules {
70
70
  storybook?: boolean; // controls storybook plugin
71
71
  tailwind?: boolean; // controls tailwindcss plugin
72
72
  next?: boolean; // controls next plugin
73
+ prettier?: boolean; // controls prettier plugin
74
+ disableExpensiveRules?: boolean; // controls expensive rules
73
75
  }
74
76
  ```
75
77
 
@@ -88,6 +90,32 @@ module.exports = init({
88
90
  });
89
91
  ```
90
92
 
93
+ ## Speed Optimization!
94
+
95
+ It's crucial to balance the benefits of linting rules against their performance impact. Below is a table highlighting the most resource-intensive linting rules encountered in a real-world React project:
96
+
97
+ | Rule | Time (ms) | Relative |
98
+ | --------------------------------------- | --------- | -------- |
99
+ | @cspell/spellchecker | 4298.302 | 25.0% |
100
+ | prettier/prettier | 3299.631 | 19.2% |
101
+ | @typescript-eslint/no-misused-promises | 2473.767 | 14.4% |
102
+ | import/no-cycle | 1177.111 | 6.8% |
103
+ | import/namespace | 1148.731 | 6.7% |
104
+
105
+ As illustrated, certain rules significantly increase linting time, potentially hindering the developer experience by slowing down the feedback loop. To mitigate this, you may consider disabling these resource-intensive rules in the development environment. However, they can remain active in environments where performance is less critical, such as Continuous Integration (CI) systems or during pre-commit checks (git hooks).
106
+
107
+ To conditionally disable expensive linting rules, you can modify your configuration as follows:
108
+
109
+ ```js
110
+ module.exports = init({
111
+ modules: {
112
+ disableExpensiveRules: !process.env.CI || !process.env.HUSKY // Or anywhere you want
113
+ },
114
+ });
115
+ ```
116
+
117
+ This approach ensures a smoother development experience while still enforcing rigorous code quality checks in environments where performance is less of a concern.
118
+
91
119
  ## React/NextJS configuration
92
120
 
93
121
  React/NextJS configuration should automatically work with Auto Module Detection, but if you need to have more control over the rules you can configure it through `modules.react`.
@@ -0,0 +1,13 @@
1
+ /** @type { import('eslint').Linter.Config } */
2
+ module.exports = {
3
+ rules: {
4
+ '@typescript-eslint/no-misused-promises': 'off',
5
+ 'prettier/prettier': 'off',
6
+ 'import/no-cycle': 'off',
7
+ 'import/namespace': 'off',
8
+ 'import/no-deprecated': 'off',
9
+ 'import/named': 'off',
10
+ 'import/export': 'off',
11
+ '@typescript-eslint/no-floating-promises': 'off',
12
+ },
13
+ };
package/init.d.ts CHANGED
@@ -15,6 +15,8 @@ export interface Options extends Config {
15
15
  test?: boolean;
16
16
  cypress?: boolean;
17
17
  storybook?: boolean;
18
+ prettier?: boolean;
19
+ disableExpensiveRules?: boolean;
18
20
  };
19
21
  }
20
22
 
package/init.js CHANGED
@@ -32,7 +32,8 @@ function init(opts = {}) {
32
32
  opts.test && require.resolve('./jest'),
33
33
  opts.esm && require.resolve('./esm'),
34
34
  opts.strict && require.resolve('./strict'),
35
- require.resolve('./prettier'),
35
+ opts.prettier && require.resolve('./prettier'),
36
+ opts.disableExpensiveRules && require.resolve('./expensive-rules'),
36
37
  ]
37
38
  .concat(extraExtends)
38
39
  .filter(Boolean),
@@ -2,11 +2,9 @@ module.exports = [
2
2
  {
3
3
  selector: 'default',
4
4
  format: ['camelCase'],
5
- filter: {
6
- regex: '^_+$',
7
- match: false,
8
- },
5
+ filter: { regex: '^_+$', match: false },
9
6
  },
7
+ { selector: 'import', format: null },
10
8
  {
11
9
  selector: 'function',
12
10
  format: ['camelCase', 'PascalCase'],
@@ -15,24 +13,15 @@ module.exports = [
15
13
  {
16
14
  selector: 'variable',
17
15
  format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
18
- filter: {
19
- regex: '^_+$',
20
- match: false,
21
- },
16
+ filter: { regex: '^_+$', match: false },
22
17
  },
23
18
  {
24
19
  selector: 'parameter',
25
20
  format: ['camelCase', 'PascalCase'],
26
21
  leadingUnderscore: 'allow',
27
- filter: {
28
- regex: '^_+$',
29
- match: false,
30
- },
31
- },
32
- {
33
- selector: 'memberLike',
34
- format: null,
22
+ filter: { regex: '^_+$', match: false },
35
23
  },
24
+ { selector: 'memberLike', format: null },
36
25
  {
37
26
  selector: 'memberLike',
38
27
  modifiers: ['static'],
@@ -53,7 +42,6 @@ module.exports = [
53
42
  selector: 'enumMember',
54
43
  format: ['PascalCase'],
55
44
  },
56
- // disallow I prefix for interfaces
57
45
  {
58
46
  selector: 'interface',
59
47
  format: ['PascalCase'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstacksjs/eslint-config",
3
- "version": "10.5.0",
3
+ "version": "10.6.0",
4
4
  "license": "MIT",
5
5
  "author": "fullstacks <fullstacksjs@gmail.com>",
6
6
  "description": "fullstacks eslint config",
@@ -28,6 +28,7 @@
28
28
  "node.js",
29
29
  "packages.js",
30
30
  "prettier.js",
31
+ "expensive-rules.js",
31
32
  "promise.js",
32
33
  "react.js",
33
34
  "registerOpts.js",
package/registerOpts.js CHANGED
@@ -12,6 +12,8 @@ const defaultOptions = {
12
12
  typescript: hasDep('typescript'),
13
13
  tailwind: hasDep('tailwindcss'),
14
14
  cspell: hasDep('cspell'),
15
+ prettier: hasDep('prettier'),
16
+ disableExpensiveRules: false,
15
17
  import: true,
16
18
  node: true,
17
19
  };
package/storybook.js CHANGED
@@ -18,8 +18,13 @@ module.exports = {
18
18
 
19
19
  'storybook/csf-component': 'warn',
20
20
  'storybook/no-stories-of': 'warn',
21
- 'storybook/no-title-property-in-meta': 'warn',
21
+ 'storybook/no-title-property-in-meta': 'off',
22
22
  'storybook/meta-inline-properties': 'off',
23
+
24
+ // Conflicts
25
+ '@typescript-eslint/no-confusing-void-expression': 'off',
26
+ 'react/jsx-no-useless-fragment': 'off',
27
+ 'react-hooks/rules-of-hooks': 'off',
23
28
  },
24
29
  },
25
30
  ],
package/typescript.js CHANGED
@@ -46,7 +46,7 @@ module.exports = {
46
46
  '@typescript-eslint/explicit-member-accessibility': 'off',
47
47
  '@typescript-eslint/explicit-module-boundary-types': 'off',
48
48
  '@typescript-eslint/generic-type-naming': 'off',
49
- '@typescript-eslint/init-declarations': ['off'],
49
+ '@typescript-eslint/init-declarations': 'off',
50
50
  '@typescript-eslint/lines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true }],
51
51
  '@typescript-eslint/member-naming': 'off',
52
52
  '@typescript-eslint/member-ordering': 'off',