@fullstacksjs/eslint-config 10.11.1 → 11.0.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.
Files changed (50) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -4
  3. package/package.json +27 -50
  4. package/src/index.js +86 -0
  5. package/src/init.d.ts +21 -0
  6. package/src/modules/base.js +187 -0
  7. package/src/modules/cypress.js +23 -0
  8. package/{esm.js → src/modules/esm.js} +1 -1
  9. package/src/modules/fp.js +16 -0
  10. package/src/modules/graphql.js +84 -0
  11. package/src/modules/ignores.js +39 -0
  12. package/src/modules/imports.js +100 -0
  13. package/src/modules/jest.js +74 -0
  14. package/src/modules/next.js +32 -0
  15. package/src/modules/node.js +33 -0
  16. package/src/modules/prettier.js +93 -0
  17. package/src/modules/promise.js +27 -0
  18. package/src/modules/react.js +151 -0
  19. package/src/modules/storybook.js +34 -0
  20. package/src/modules/strict.js +16 -0
  21. package/src/modules/tailwind.js +19 -0
  22. package/src/modules/tests.js +43 -0
  23. package/src/modules/typescript.js +255 -0
  24. package/src/modules/vitest.js +84 -0
  25. package/src/utils/conditions.js +20 -0
  26. package/src/utils/globs.js +40 -0
  27. package/base.js +0 -246
  28. package/cypress.js +0 -31
  29. package/expensive-rules.js +0 -4
  30. package/fp.js +0 -23
  31. package/graphql.js +0 -79
  32. package/import.js +0 -64
  33. package/index.js +0 -20
  34. package/init.d.ts +0 -22
  35. package/init.js +0 -64
  36. package/jest.js +0 -80
  37. package/next.js +0 -27
  38. package/node.js +0 -43
  39. package/prettier.js +0 -8
  40. package/promise.js +0 -21
  41. package/react.js +0 -147
  42. package/registerOpts.js +0 -20
  43. package/storybook.js +0 -31
  44. package/strict.js +0 -15
  45. package/tailwind.js +0 -15
  46. package/test.js +0 -40
  47. package/typecheck.js +0 -89
  48. package/typescript.js +0 -169
  49. package/utils.js +0 -21
  50. /package/{naming-convention.js → src/utils/naming-convention.js} +0 -0
package/registerOpts.js DELETED
@@ -1,20 +0,0 @@
1
- const { hasDep, isEsm } = require('./utils');
2
-
3
- /** @param { import('./init').Options } opts */
4
- const defaultOptions = {
5
- esm: isEsm(),
6
- cypress: hasDep('cypress'),
7
- graphql: hasDep('graphql'),
8
- react: hasDep('react'),
9
- next: hasDep('next'),
10
- storybook: hasDep('@storybook/react'),
11
- test: hasDep('jest') || hasDep('vitest'),
12
- typescript: hasDep('typescript'),
13
- tailwind: hasDep('tailwindcss'),
14
- prettier: hasDep('prettier'),
15
- disableExpensiveRules: false,
16
- import: true,
17
- node: true,
18
- };
19
-
20
- global.fullstacksjs = defaultOptions;
package/storybook.js DELETED
@@ -1,31 +0,0 @@
1
- /** @type { import('eslint').Linter.Config } */
2
- module.exports = {
3
- overrides: [
4
- {
5
- files: ['**/*.stories.+(ts|tsx|js|jsx|mjs|cjs|mdx)', '**/*.story.+(ts|tsx|js|jsx|mjs|cjs|mdx)'],
6
- plugins: ['storybook'],
7
- rules: {
8
- 'storybook/await-interactions': 'error',
9
- 'storybook/context-in-play-function': 'error',
10
- 'storybook/default-exports': 'error',
11
- 'storybook/hierarchy-separator': 'warn',
12
- 'storybook/no-redundant-story-name': 'warn',
13
- 'storybook/no-uninstalled-addons': 'error',
14
- 'storybook/prefer-pascal-case': 'warn',
15
- 'storybook/story-exports': 'error',
16
- 'storybook/use-storybook-expect': 'error',
17
- 'storybook/use-storybook-testing-library': 'error',
18
-
19
- 'storybook/csf-component': 'warn',
20
- 'storybook/no-stories-of': 'warn',
21
- 'storybook/no-title-property-in-meta': 'off',
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',
28
- },
29
- },
30
- ],
31
- };
package/strict.js DELETED
@@ -1,15 +0,0 @@
1
- /** @type { import('eslint').Linter.Config } */
2
- module.exports = {
3
- rules: {
4
- 'no-console': 'warn',
5
- 'fp/no-delete': 'error',
6
- 'fp/no-get-set': 'error',
7
- 'fp/no-mutating-methods': 'error',
8
- 'fp/no-mutation': ['error', { commonjs: true, allowThis: true, exceptions: [{ property: 'propTypes' }, { property: 'defaultProps' }] }],
9
- 'fp/no-nil': 'error',
10
- 'fp/no-this': 'error',
11
- 'fp/no-throw': 'error',
12
- 'fp/no-unused-expression': ['error', { allowUseStrict: true }],
13
- '@typescript-eslint/no-non-null-assertion': 'warn',
14
- },
15
- };
package/tailwind.js DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * @type { import('eslint').Linter.Config }
3
- */
4
- module.exports = {
5
- plugins: ['tailwindcss'],
6
- rules: {
7
- 'tailwindcss/classnames-order': 'warn',
8
- 'tailwindcss/enforces-negative-arbitrary-values': 'warn',
9
- 'tailwindcss/enforces-shorthand': 'warn',
10
- 'tailwindcss/migration-from-tailwind-2': 'warn',
11
- 'tailwindcss/no-arbitrary-value': 'off',
12
- 'tailwindcss/no-custom-classname': 'warn',
13
- 'tailwindcss/no-contradicting-classname': 'error',
14
- },
15
- };
package/test.js DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * @type { import('eslint').Linter.Config }
3
- */
4
- module.exports = {
5
- rules: {
6
- 'jest/prefer-hooks-in-order': 'warn',
7
- 'jest/no-disabled-tests': 'error',
8
- 'jest/no-duplicate-hooks': 'error',
9
- 'jest/no-focused-tests': 'error',
10
- 'jest/no-identical-title': 'error',
11
- 'jest/prefer-comparison-matcher': 'error',
12
- 'jest/prefer-equality-matcher': 'error',
13
- 'jest/max-expects': ['off', { max: 5 }],
14
-
15
- // formatting
16
- 'jest-formatting/padding-around-after-all-blocks': 'warn',
17
- 'jest-formatting/padding-around-after-each-blocks': 'warn',
18
- 'jest-formatting/padding-around-all': 'warn',
19
- 'jest-formatting/padding-around-before-all-blocks': 'warn',
20
- 'jest-formatting/padding-around-before-each-blocks': 'warn',
21
- 'jest-formatting/padding-around-describe-blocks': 'warn',
22
- 'jest-formatting/padding-around-expect-groups': 'warn',
23
- 'jest-formatting/padding-around-test-blocks': 'warn',
24
-
25
- 'max-lines-per-function': 'off',
26
- 'fp/no-let': 'off',
27
- 'fp/no-loops': 'off',
28
- 'no-sparse-arrays': 'off',
29
-
30
- ...(global.fullstacksjs?.react && {
31
- 'react/jsx-no-constructed-context-values': 'off',
32
- }),
33
- ...(global.fullstacksjs?.typescript && {
34
- '@typescript-eslint/method-signature-style': 'off',
35
- '@typescript-eslint/no-namespace ': 'off',
36
- '@typescript-eslint/unbound-method': 'off',
37
- '@typescript-eslint/no-empty-function': 'off',
38
- }),
39
- },
40
- };
package/typecheck.js DELETED
@@ -1,89 +0,0 @@
1
- const expensiveRules = require('./expensive-rules');
2
-
3
- /** @type { import('eslint').Linter.Config } */
4
- module.exports = {
5
- overrides: [
6
- {
7
- files: ['*.ts', '*.tsx'],
8
- rules: {
9
- '@typescript-eslint/await-thenable': 'error',
10
- '@typescript-eslint/consistent-return': 'off',
11
- '@typescript-eslint/consistent-type-exports': 'warn',
12
- '@typescript-eslint/dot-notation': [
13
- 'warn',
14
- {
15
- allowPrivateClassPropertyAccess: false,
16
- allowProtectedClassPropertyAccess: false,
17
- allowIndexSignaturePropertyAccess: true,
18
- },
19
- ],
20
- '@typescript-eslint/no-confusing-void-expression': ['off', { ignoreArrowShorthand: true, ignoreVoidOperator: true }], // Annoying and conflict with @typescript-eslint/no-meaningless-void-operator
21
- '@typescript-eslint/no-duplicate-type-constituents': 'warn',
22
- '@typescript-eslint/no-floating-promises': expensiveRules(['error', { ignoreVoid: true }]),
23
- '@typescript-eslint/no-for-in-array': 'error',
24
- '@typescript-eslint/no-implied-eval': 'error',
25
- '@typescript-eslint/no-meaningless-void-operator': ['warn', { checkNever: false }],
26
- '@typescript-eslint/no-misused-promises': expensiveRules(['warn', { checksVoidReturn: { attributes: false } }]),
27
- '@typescript-eslint/no-mixed-enums': 'error',
28
- '@typescript-eslint/no-redundant-type-constituents': 'warn',
29
- '@typescript-eslint/no-throw-literal': ['warn', { allowThrowingUnknown: false }],
30
- '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
31
- '@typescript-eslint/no-unsafe-enum-comparison': 'warn',
32
- '@typescript-eslint/no-unnecessary-condition': [
33
- 'warn',
34
- {
35
- allowConstantLoopConditions: false,
36
- allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
37
- },
38
- ],
39
- '@typescript-eslint/no-unnecessary-qualifier': 'error',
40
- '@typescript-eslint/no-unnecessary-type-arguments': 'error',
41
- '@typescript-eslint/no-unnecessary-type-assertion': 'error',
42
- '@typescript-eslint/no-unsafe-unary-minus': 'error',
43
- '@typescript-eslint/no-useless-template-literals': 'warn',
44
- '@typescript-eslint/non-nullable-type-assertion-style': 'warn',
45
- '@typescript-eslint/prefer-includes': 'warn',
46
- '@typescript-eslint/prefer-optional-chain': 'warn',
47
- '@typescript-eslint/prefer-reduce-type-parameter': 'warn',
48
- '@typescript-eslint/prefer-nullish-coalescing': [
49
- 'warn',
50
- {
51
- ignoreConditionalTests: false,
52
- ignoreTernaryTests: false,
53
- ignoreMixedLogicalExpressions: false,
54
- allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
55
- },
56
- ],
57
- '@typescript-eslint/prefer-regexp-exec': 'warn',
58
- '@typescript-eslint/prefer-promise-reject-errors': 'warn',
59
- '@typescript-eslint/prefer-return-this-type': 'warn',
60
- '@typescript-eslint/prefer-string-starts-ends-with': 'warn',
61
- '@typescript-eslint/restrict-template-expressions': [
62
- 'warn',
63
- { allowNumber: true, allowBoolean: false, allowAny: false, allowNullish: false, allowRegExp: false, allowNever: false },
64
- ],
65
- '@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }],
66
- '@typescript-eslint/require-await': 'error',
67
- '@typescript-eslint/return-await': 'error',
68
- '@typescript-eslint/switch-exhaustiveness-check': 'error',
69
- '@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
70
- '@typescript-eslint/naming-convention': [
71
- 'warn',
72
- ...require('./naming-convention'),
73
- // force use is/should/has for boolean variables
74
- {
75
- selector: 'variable',
76
- types: ['boolean'],
77
- format: ['PascalCase'],
78
- prefix: ['is', 'should', 'has', 'can', 'did', 'will', 'enable', 'loading'],
79
- },
80
- ],
81
-
82
- // collisions
83
- 'dot-notation': 'off',
84
- 'prefer-promise-reject-errors': 'off',
85
- 'consistent-return': 'off',
86
- },
87
- },
88
- ],
89
- };
package/typescript.js DELETED
@@ -1,169 +0,0 @@
1
- /** @type { import('eslint').Linter.Config } */
2
- module.exports = {
3
- overrides: [
4
- {
5
- files: ['*.ts', '*.tsx'],
6
- parser: '@typescript-eslint/parser',
7
- plugins: ['@typescript-eslint/eslint-plugin'],
8
- extends: ['plugin:@typescript-eslint/recommended'],
9
- settings: {
10
- 'import/parsers': {
11
- '@typescript-eslint/parser': ['.ts', '.tsx'],
12
- },
13
- 'import/resolver': {
14
- node: {
15
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts', '.json', '.mjs'],
16
- },
17
- },
18
- },
19
- rules: {
20
- '@typescript-eslint/adjacent-overload-signatures': 'error',
21
- '@typescript-eslint/array-type': 'error',
22
- '@typescript-eslint/ban-ts-comment': [
23
- 'error',
24
- {
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,
30
- },
31
- ],
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': [
41
- 'warn',
42
- { prefer: 'type-imports', disallowTypeAnnotations: false, fixStyle: 'separate-type-imports' },
43
- ],
44
- '@typescript-eslint/default-param-last': 'warn',
45
- '@typescript-eslint/explicit-function-return-type': 'off',
46
- '@typescript-eslint/explicit-member-accessibility': 'off',
47
- '@typescript-eslint/explicit-module-boundary-types': 'off',
48
- '@typescript-eslint/generic-type-naming': 'off',
49
- '@typescript-eslint/init-declarations': 'off',
50
- '@typescript-eslint/lines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true }],
51
- '@typescript-eslint/member-naming': 'off',
52
- '@typescript-eslint/member-ordering': 'off',
53
- '@typescript-eslint/method-signature-style': ['warn', 'property'],
54
- '@typescript-eslint/naming-convention': ['warn', ...require('./naming-convention')],
55
- '@typescript-eslint/no-array-constructor': 'error',
56
- '@typescript-eslint/no-base-to-string': 'off', // false negative
57
- '@typescript-eslint/no-confusing-non-null-assertion': 'error',
58
- '@typescript-eslint/no-dupe-class-members': 'error',
59
- '@typescript-eslint/no-duplicate-enum-values': 'error',
60
- '@typescript-eslint/no-dynamic-delete': 'error',
61
- '@typescript-eslint/no-empty-function': 'error',
62
- '@typescript-eslint/no-empty-interface': 'off', // Annoying with auto-fix on save.
63
- '@typescript-eslint/no-explicit-any': 'off',
64
- '@typescript-eslint/no-extra-non-null-assertion': 'error',
65
- '@typescript-eslint/no-extraneous-class': ['warn', { allowWithDecorator: true }],
66
- '@typescript-eslint/no-import-type-side-effects': 'warn',
67
- '@typescript-eslint/no-inferrable-types': 'off',
68
- '@typescript-eslint/no-invalid-this': ['error', { capIsConstructor: false }],
69
- '@typescript-eslint/no-invalid-void-type': 'error',
70
- '@typescript-eslint/no-loop-func': 'error',
71
- '@typescript-eslint/no-loss-of-precision': 'error',
72
- '@typescript-eslint/no-magic-numbers': ['off', { ignoreEnums: true }], // Not good enough yet
73
- '@typescript-eslint/no-misused-new': 'error',
74
- '@typescript-eslint/no-namespace': 'error',
75
- '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
76
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
77
- '@typescript-eslint/no-non-null-assertion': 'off',
78
- '@typescript-eslint/no-redeclare': ['off', { ignoreDeclarationMerge: true }], // useful in FP.
79
- '@typescript-eslint/no-require-imports': 'error',
80
- '@typescript-eslint/no-restricted-imports': 'off',
81
- '@typescript-eslint/no-shadow': 'error',
82
- '@typescript-eslint/no-this-alias': 'error',
83
- '@typescript-eslint/no-type-alias': 'off',
84
- '@typescript-eslint/no-unnecessary-type-constraint': 'warn',
85
- '@typescript-eslint/no-unsafe-argument': 'off',
86
- '@typescript-eslint/no-unsafe-assignment': 'off',
87
- '@typescript-eslint/no-unsafe-call': 'off',
88
- '@typescript-eslint/no-unsafe-declaration-merging': 'warn',
89
- '@typescript-eslint/no-unsafe-member-access': 'off',
90
- '@typescript-eslint/no-unsafe-return': 'off',
91
- '@typescript-eslint/no-untyped-public-signature': 'off',
92
- '@typescript-eslint/no-unused-expressions': 'error',
93
- '@typescript-eslint/no-unused-vars-experimental': 'off', // Why two rules?
94
- '@typescript-eslint/no-unused-vars': [
95
- 'warn',
96
- { argsIgnorePattern: '^_', varsIgnorePattern: '^([iI]gnore(d)?)|(_+)', args: 'after-used', ignoreRestSiblings: true },
97
- ],
98
- '@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: true }],
99
- '@typescript-eslint/no-useless-constructor': 'error',
100
- '@typescript-eslint/no-useless-empty-export': 'warn',
101
- '@typescript-eslint/no-var-requires': 'error',
102
- '@typescript-eslint/object-curly-spacing': 'warn',
103
- '@typescript-eslint/parameter-properties': 'off',
104
- '@typescript-eslint/padding-line-between-statements': [
105
- 'warn',
106
- {
107
- blankLine: 'always',
108
- prev: '*',
109
- next: ['class', 'for', 'while', 'switch', 'do', 'directive', 'function', 'iife', 'block-like'],
110
- },
111
- { blankLine: 'always', prev: ['block-like', 'block'], next: ['return'] },
112
- { blankLine: 'always', prev: ['block-like'], next: ['const', 'let', 'var'] },
113
- { blankLine: 'always', prev: ['const', 'let', 'var'], next: ['type', 'interface'] },
114
- { blankLine: 'always', prev: ['multiline-const', 'multiline-let', 'multiline-var'], next: ['if'] },
115
- ],
116
- '@typescript-eslint/prefer-as-const': 'warn',
117
- '@typescript-eslint/prefer-enum-initializers': 'off',
118
- '@typescript-eslint/prefer-for-of': 'warn',
119
- '@typescript-eslint/prefer-function-type': 'warn',
120
- '@typescript-eslint/prefer-literal-enum-member': ['error', { allowBitwiseExpressions: true }],
121
- '@typescript-eslint/prefer-namespace-keyword': 'error',
122
- '@typescript-eslint/prefer-readonly-parameter-types': [
123
- 'off',
124
- { checkParameterProperties: true, ignoreInferredTypes: false, treatMethodsAsReadonly: true },
125
- ], // I'm not sure...
126
- '@typescript-eslint/prefer-readonly': 'off',
127
- '@typescript-eslint/prefer-readonlysemi': 'off', // Annoying with auto-fix on save.
128
- '@typescript-eslint/prefer-ts-expect-error': 'off',
129
- '@typescript-eslint/promise-function-async': 'off',
130
- '@typescript-eslint/restrict-plus-operands': 'off',
131
- '@typescript-eslint/sort-type-constituents': [
132
- 'warn',
133
- {
134
- checkIntersections: true,
135
- checkUnions: true,
136
- groupOrder: [
137
- 'named',
138
- 'keyword',
139
- 'operator',
140
- 'literal',
141
- 'function',
142
- 'import',
143
- 'conditional',
144
- 'object',
145
- 'tuple',
146
- 'intersection',
147
- 'union',
148
- 'nullish',
149
- ],
150
- },
151
- ],
152
- '@typescript-eslint/strict-boolean-expressions': 'off', // Annoying
153
- '@typescript-eslint/space-before-blocks': 'off',
154
-
155
- '@typescript-eslint/triple-slash-reference': 'error',
156
- '@typescript-eslint/typedef': ['error', { parameter: false, arrowParameter: false, variableDeclaration: false }],
157
- '@typescript-eslint/unified-signatures': 'error',
158
- '@typescript-eslint/key-spacing': 'off',
159
-
160
- // open issues
161
- 'react/jsx-no-useless-fragment': 'off', // Need useless-fragment for JSX return type
162
- 'import/named': 'off',
163
- 'import/namespace': 'off',
164
- 'import/default': 'off',
165
- 'import/no-named-as-default-member': 'off',
166
- },
167
- },
168
- ],
169
- };
package/utils.js DELETED
@@ -1,21 +0,0 @@
1
- const readPkgUp = require('read-pkg-up');
2
- const fs = require('node:fs');
3
-
4
- const { packageJson } = readPkgUp.sync({
5
- cwd: fs.realpathSync(process.cwd()),
6
- });
7
-
8
- const hasProperty = (obj, prop) => typeof obj === 'object' && Reflect.has(obj, prop);
9
-
10
- const hasDep = dep => {
11
- const types = ['peerDependencies', 'dependencies', 'devDependencies', 'optionalDependencies'];
12
- return types.some(type => hasProperty(packageJson[type], dep));
13
- };
14
-
15
- const isEsm = () => {
16
- return packageJson.type === 'module';
17
- };
18
-
19
- module.exports.hasDep = hasDep;
20
- module.exports.isEsm = isEsm;
21
- module.exports.exts = '+(js|jsx|mjs|cjs|ts|tsx|mts|cts)';