@fullstacksjs/eslint-config 9.0.2 → 9.0.4

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/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  require('./registerOpts');
2
2
  const { compact } = require('@fullstacksjs/toolbox');
3
- const { hasDep } = require('./utils');
4
3
 
5
4
  /** @type { import('eslint').Linter.Config } */
6
5
  module.exports = {
@@ -12,9 +11,9 @@ module.exports = {
12
11
  require.resolve('./promise'),
13
12
  require.resolve('./storybook'),
14
13
  require.resolve('./jest'),
15
- hasDep('react') && !hasDep('next') && require.resolve('./react'),
16
- hasDep('typescript') && require.resolve('./typescript'),
17
- hasDep('cypress') && require.resolve('./cypress'),
14
+ global.fullstacksjs?.react && require.resolve('./react'),
15
+ global.fullstacksjs?.typescript && require.resolve('./typescript'),
16
+ global.fullstacksjs?.cypress && require.resolve('./cypress'),
18
17
  require.resolve('./prettier'),
19
18
  ]),
20
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstacksjs/eslint-config",
3
- "version": "9.0.2",
3
+ "version": "9.0.4",
4
4
  "license": "MIT",
5
5
  "author": "fullstacks <fullstacksjs@gmail.com>",
6
6
  "description": "fullstacks eslint config",
package/registerOpts.js CHANGED
@@ -5,7 +5,7 @@ const defaultOptions = {
5
5
  esm: isEsm(),
6
6
  cypress: hasDep('cypress'),
7
7
  graphql: hasDep('graphql'),
8
- react: hasDep('react'),
8
+ react: hasDep('react') && !hasDep('next'),
9
9
  storybook: hasDep('storybook'),
10
10
  test: hasDep('jest') || hasDep('vitest'),
11
11
  typescript: hasDep('typescript'),
package/typescript.js CHANGED
@@ -17,69 +17,168 @@ module.exports = {
17
17
  },
18
18
  },
19
19
  rules: {
20
- '@typescript-eslint/await-thenable': 'error',
21
- '@typescript-eslint/consistent-type-exports': 'warn',
22
- '@typescript-eslint/dot-notation': [
23
- 'warn',
20
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
21
+ '@typescript-eslint/array-type': 'error',
22
+ '@typescript-eslint/ban-ts-comment': [
23
+ 'error',
24
24
  {
25
- allowPrivateClassPropertyAccess: false,
26
- allowProtectedClassPropertyAccess: false,
27
- allowIndexSignaturePropertyAccess: true,
25
+ 'ts-expect-error': 'allow-with-description',
26
+ 'ts-ignore': 'allow-with-description',
27
+ 'ts-nocheck': 'allow-with-description',
28
+ 'ts-check': 'allow-with-description',
29
+ 'minimumDescriptionLength': 3,
28
30
  },
29
31
  ],
30
- '@typescript-eslint/no-confusing-void-expression': ['warn', { ignoreArrowShorthand: true, ignoreVoidOperator: true }],
31
- '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
32
- '@typescript-eslint/no-for-in-array': 'error',
33
- '@typescript-eslint/no-implied-eval': 'error',
34
- '@typescript-eslint/no-meaningless-void-operator': ['warn', { checkNever: false }],
35
- '@typescript-eslint/no-misused-promises': ['warn', { checksVoidReturn: { attributes: false } }],
36
- '@typescript-eslint/no-redundant-type-constituents': 'warn',
37
- '@typescript-eslint/no-throw-literal': 'error',
38
- '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
39
- '@typescript-eslint/no-unnecessary-condition': [
32
+ '@typescript-eslint/ban-tslint-comment': 'off',
33
+ '@typescript-eslint/ban-types': 'error',
34
+ '@typescript-eslint/camelcase': 'off',
35
+ '@typescript-eslint/class-literal-property-style': ['error', 'getters'],
36
+ '@typescript-eslint/consistent-generic-constructors': ['warn', 'constructor'],
37
+ '@typescript-eslint/consistent-indexed-object-style': 'off',
38
+ '@typescript-eslint/consistent-type-assertions': 'error',
39
+ '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
40
+ '@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports', disallowTypeAnnotations: false }],
41
+ '@typescript-eslint/default-param-last': 'warn',
42
+ '@typescript-eslint/explicit-function-return-type': 'off',
43
+ '@typescript-eslint/explicit-member-accessibility': 'off',
44
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
45
+ '@typescript-eslint/generic-type-naming': 'off',
46
+ '@typescript-eslint/init-declarations': ['off'],
47
+ '@typescript-eslint/lines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true }],
48
+ '@typescript-eslint/member-naming': 'off',
49
+ '@typescript-eslint/member-ordering': 'off',
50
+ '@typescript-eslint/method-signature-style': ['warn', 'property'],
51
+ '@typescript-eslint/naming-convention': ['warn', ...require('./naming-convention')],
52
+ '@typescript-eslint/no-array-constructor': 'error',
53
+ '@typescript-eslint/no-base-to-string': 'off', // false negative
54
+ '@typescript-eslint/no-confusing-non-null-assertion': 'error',
55
+ '@typescript-eslint/no-dupe-class-members': 'error',
56
+ '@typescript-eslint/no-duplicate-enum-values': 'error',
57
+ '@typescript-eslint/no-dynamic-delete': 'error',
58
+ '@typescript-eslint/no-empty-function': 'error',
59
+ '@typescript-eslint/no-empty-interface': 'off', // Annoying with auto-fix on save.
60
+ '@typescript-eslint/no-explicit-any': 'off',
61
+ '@typescript-eslint/no-extra-non-null-assertion': 'error',
62
+ '@typescript-eslint/no-extraneous-class': ['warn', { allowWithDecorator: true }],
63
+ '@typescript-eslint/no-inferrable-types': 'off',
64
+ '@typescript-eslint/no-invalid-this': ['error', { capIsConstructor: false }],
65
+ '@typescript-eslint/no-invalid-void-type': 'error',
66
+ '@typescript-eslint/no-loop-func': 'error',
67
+ '@typescript-eslint/no-loss-of-precision': 'error',
68
+ '@typescript-eslint/no-magic-numbers': ['off', { ignoreEnums: true }], // Not good enough yet
69
+ '@typescript-eslint/no-misused-new': 'error',
70
+ '@typescript-eslint/no-namespace': 'error',
71
+ '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
72
+ '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
73
+ '@typescript-eslint/no-non-null-assertion': 'off',
74
+ '@typescript-eslint/no-redeclare': ['off', { ignoreDeclarationMerge: true }], // useful in FP.
75
+ '@typescript-eslint/no-require-imports': 'error',
76
+ '@typescript-eslint/no-restricted-imports': 'off',
77
+ '@typescript-eslint/no-shadow': 'error',
78
+ '@typescript-eslint/no-this-alias': 'error',
79
+ '@typescript-eslint/no-type-alias': 'off',
80
+ '@typescript-eslint/no-unnecessary-type-constraint': 'warn',
81
+ '@typescript-eslint/no-unsafe-argument': 'off',
82
+ '@typescript-eslint/no-unsafe-assignment': 'off',
83
+ '@typescript-eslint/no-unsafe-call': 'off',
84
+ '@typescript-eslint/no-unsafe-declaration-merging': 'warn',
85
+ '@typescript-eslint/no-unsafe-member-access': 'off',
86
+ '@typescript-eslint/no-unsafe-return': 'off',
87
+ '@typescript-eslint/no-untyped-public-signature': 'off',
88
+ '@typescript-eslint/no-unused-expressions': 'error',
89
+ '@typescript-eslint/no-unused-vars-experimental': 'off', // Why two rules?
90
+ '@typescript-eslint/no-unused-vars': [
40
91
  'warn',
41
- {
42
- allowConstantLoopConditions: false,
43
- allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
44
- },
92
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^[iI]gnore(d)?', args: 'after-used', ignoreRestSiblings: true },
45
93
  ],
46
- '@typescript-eslint/no-unnecessary-qualifier': 'error',
47
- '@typescript-eslint/no-unnecessary-type-arguments': 'error',
48
- '@typescript-eslint/no-unnecessary-type-assertion': 'error',
49
- '@typescript-eslint/non-nullable-type-assertion-style': 'warn',
50
- '@typescript-eslint/prefer-includes': 'warn',
51
- '@typescript-eslint/prefer-reduce-type-parameter': 'warn',
52
- '@typescript-eslint/prefer-nullish-coalescing': [
94
+ '@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: true }],
95
+ '@typescript-eslint/no-useless-constructor': 'error',
96
+ '@typescript-eslint/no-useless-empty-export': 'warn',
97
+ '@typescript-eslint/no-var-requires': 'error',
98
+ '@typescript-eslint/object-curly-spacing': 'warn',
99
+ '@typescript-eslint/parameter-properties': 'off',
100
+ '@typescript-eslint/padding-line-between-statements': [
53
101
  'warn',
54
102
  {
55
- ignoreConditionalTests: false,
56
- ignoreTernaryTests: false,
57
- ignoreMixedLogicalExpressions: false,
58
- allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
103
+ blankLine: 'always',
104
+ prev: '*',
105
+ next: ['class', 'for', 'while', 'switch', 'do', 'directive', 'function', 'iife', 'block-like'],
59
106
  },
107
+ { blankLine: 'always', prev: ['block-like', 'block'], next: ['return'] },
108
+ { blankLine: 'always', prev: ['block-like'], next: ['const', 'let', 'var'] },
109
+ { blankLine: 'always', prev: ['const', 'let', 'var'], next: ['type', 'interface'] },
110
+ { blankLine: 'always', prev: ['multiline-const', 'multiline-let', 'multiline-var'], next: ['if'] },
60
111
  ],
61
- '@typescript-eslint/prefer-regexp-exec': 'warn',
62
- '@typescript-eslint/prefer-return-this-type': 'warn',
63
- '@typescript-eslint/prefer-string-starts-ends-with': 'warn',
64
- '@typescript-eslint/require-array-sort-compare': 'error',
65
- '@typescript-eslint/require-await': 'error',
66
- '@typescript-eslint/return-await': 'error',
67
- '@typescript-eslint/switch-exhaustiveness-check': 'error',
68
- '@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
69
- '@typescript-eslint/naming-convention': [
112
+ '@typescript-eslint/prefer-as-const': 'warn',
113
+ '@typescript-eslint/prefer-enum-initializers': 'off',
114
+ '@typescript-eslint/prefer-for-of': 'warn',
115
+ '@typescript-eslint/prefer-function-type': 'warn',
116
+ '@typescript-eslint/prefer-literal-enum-member': ['error', { allowBitwiseExpressions: true }],
117
+ '@typescript-eslint/prefer-namespace-keyword': 'error',
118
+ '@typescript-eslint/prefer-optional-chain': 'warn',
119
+ '@typescript-eslint/prefer-readonly-parameter-types': [
120
+ 'off',
121
+ { checkParameterProperties: true, ignoreInferredTypes: false, treatMethodsAsReadonly: true },
122
+ ], // I'm not sure...
123
+ '@typescript-eslint/prefer-readonly': 'off',
124
+ '@typescript-eslint/prefer-readonlysemi': 'off', // Annoying with auto-fix on save.
125
+ '@typescript-eslint/prefer-ts-expect-error': 'off',
126
+ '@typescript-eslint/promise-function-async': 'off',
127
+ '@typescript-eslint/restrict-plus-operands': 'off',
128
+ '@typescript-eslint/restrict-template-expressions': [
129
+ 'off',
130
+ { allowNumber: true, allowBoolean: false, allowAny: false, allowNullish: false, allowRegExp: false },
131
+ ],
132
+ '@typescript-eslint/sort-type-constituents': [
70
133
  'warn',
71
- ...require('./naming-convention'),
72
- // force use is/should/has for boolean variables
73
134
  {
74
- selector: 'variable',
75
- types: ['boolean'],
76
- format: ['PascalCase'],
77
- prefix: ['is', 'should', 'has', 'can', 'did', 'will', 'enable', 'loading'],
135
+ checkIntersections: true,
136
+ checkUnions: true,
137
+ groupOrder: [
138
+ 'named',
139
+ 'keyword',
140
+ 'operator',
141
+ 'literal',
142
+ 'function',
143
+ 'import',
144
+ 'conditional',
145
+ 'object',
146
+ 'tuple',
147
+ 'intersection',
148
+ 'union',
149
+ 'nullish',
150
+ ],
78
151
  },
79
152
  ],
153
+ '@typescript-eslint/strict-boolean-expressions': 'off', // Annoying
154
+ '@typescript-eslint/space-before-blocks': 'off',
155
+
156
+ '@typescript-eslint/triple-slash-reference': 'error',
157
+ '@typescript-eslint/typedef': ['error', { parameter: false, arrowParameter: false, variableDeclaration: false }],
158
+ '@typescript-eslint/unified-signatures': 'error',
159
+ '@typescript-eslint/key-spacing': 'off',
80
160
 
81
161
  // collisions
82
- 'dot-notation': 'off',
162
+ 'key-spacing': 'off',
163
+ 'camelcase': 'off',
164
+ 'default-param-last': 'off',
165
+ 'init-declarations': 'off',
166
+ 'lines-between-class-members': 'off',
167
+ 'no-invalid-this': 'off',
168
+ 'no-loop-func': 'off',
169
+ 'no-redeclare': 'off',
170
+ 'no-restricted-imports': 'off',
171
+ 'no-shadow': 'off',
172
+ 'no-unused-vars': 'off',
173
+ 'no-use-before-define': 'off',
174
+ 'no-useless-constructor': 'off',
175
+ 'object-curly-spacing': 'off',
176
+ 'padding-line-between-statements': 'off',
177
+ 'space-before-blocks': 'off',
178
+
179
+ // open issues
180
+ 'react/jsx-no-useless-fragment': 'off', // Need useless-fragment for JSX return type
181
+ 'dot-notation': 'off', // Need to have IndexSignaturePropertyAccess Typescript compiler option
83
182
  },
84
183
  },
85
184
  ],