@cedarjs/eslint-config 5.0.3 → 5.0.4-next.167

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/shared.js DELETED
@@ -1,202 +0,0 @@
1
- // This ESLint configuration is shared between the Redwood framework,
2
- // and Redwood projects.
3
- //
4
- // Our ESLint configuration is a mixture between ESLint's recommended
5
- // rules [^1], React's recommended rules [^2], and a bit of our own stylistic
6
- // flair:
7
- // - no semicolons
8
- // - comma dangle when multiline
9
- // - single quotes
10
- // - always use parenthesis around arrow functions
11
- // - enforced import sorting
12
- //
13
- // [^1] https://eslint.org/docs/rules/
14
- // [^2] https://www.npmjs.com/package/eslint-plugin-react#list-of-supported-rules
15
-
16
- module.exports = {
17
- extends: [
18
- 'eslint:recommended',
19
- 'plugin:react/recommended',
20
- 'plugin:prettier/recommended',
21
- 'plugin:jest-dom/recommended',
22
- ],
23
- // @NOTE parserOptions defined separately for project and framework
24
- parser: '@babel/eslint-parser',
25
- plugins: [
26
- 'prettier',
27
- '@babel',
28
- 'import',
29
- 'jsx-a11y',
30
- 'react',
31
- 'react-hooks',
32
- 'jest-dom',
33
- '@cedarjs',
34
- ],
35
- // In addition to this, eslint also has some implicit ignore patterns, like
36
- // `node_modules`.
37
- // See https://eslint.org/docs/latest/use/configure/ignore-deprecated
38
- ignorePatterns: ['dist'],
39
- settings: {
40
- react: {
41
- version: 'detect',
42
- },
43
- // For the import/order rule. Configures how it tells if an import is "internal" or not.
44
- // An "internal" import is basically just one that's aliased.
45
- //
46
- // See...
47
- // - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#groups-array
48
- // - https://github.com/import-js/eslint-plugin-import/blob/main/README.md#importinternal-regex
49
- 'import/internal-regex': '^src/',
50
- },
51
- rules: {
52
- '@cedarjs/process-env-computed': 'error',
53
- 'prettier/prettier': 'warn',
54
- 'no-console': 'off',
55
- 'prefer-object-spread': 'warn',
56
- 'prefer-spread': 'warn',
57
- 'no-unused-expressions': [
58
- 'error',
59
- { allowShortCircuit: true, allowTernary: true },
60
- ],
61
- 'no-useless-escape': 'off',
62
- camelcase: ['warn', { properties: 'never' }],
63
- 'no-new': 'warn',
64
- 'new-cap': ['error', { newIsCap: true, capIsNew: false }],
65
- 'no-unused-vars': [
66
- 'error',
67
- { varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
68
- ],
69
- // React rules
70
- 'react/prop-types': 'off',
71
- 'react/display-name': 'off',
72
- 'react-hooks/exhaustive-deps': 'warn',
73
- 'import/order': [
74
- 'error',
75
- {
76
- 'newlines-between': 'always',
77
- // We set this to an empty array to override the default value, which is `['builtin', 'external', 'object']`.
78
- // Judging by the number of issues on the repo, this option seems to be notoriously tricky to understand.
79
- // From what I can tell, if the value of this is `['builtin']` that means it won't sort builtins.
80
- // But we have a rule for builtins below (react), so that's not what we want.
81
- //
82
- // See...
83
- // - https://github.com/import-js/eslint-plugin-import/pull/1570
84
- // - https://github.com/import-js/eslint-plugin-import/issues/1565
85
- pathGroupsExcludedImportTypes: [],
86
- // Only doing this to add internal. The order here maters.
87
- // See https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#groups-array
88
- groups: [
89
- 'builtin',
90
- 'external',
91
- 'internal',
92
- 'parent',
93
- 'sibling',
94
- 'index',
95
- ],
96
- pathGroups: [
97
- {
98
- pattern: 'react',
99
- group: 'builtin',
100
- position: 'after',
101
- },
102
- {
103
- pattern: '@cedarjs/**',
104
- group: 'external',
105
- position: 'after',
106
- },
107
- {
108
- // Matches...
109
- // - src/directives/**/*.{js,ts}
110
- // - src/services/**/*.{js,ts}
111
- // - src/graphql/**/*.sdl.{js,ts}
112
- //
113
- // Uses https://github.com/isaacs/minimatch under the hood
114
- // See https://github.com/isaacs/node-glob#glob-primer for syntax
115
- pattern: 'src/*/**/*.?(sdl.){js,ts}',
116
- patternOptions: {
117
- nobrace: true,
118
- noglobstar: true,
119
- },
120
- group: 'internal',
121
- position: 'before',
122
- },
123
- ],
124
- alphabetize: {
125
- order: 'asc',
126
- caseInsensitive: true,
127
- },
128
- },
129
- ],
130
- 'no-restricted-imports': [
131
- 'error',
132
- {
133
- patterns: [
134
- {
135
- group: ['$api/*'],
136
- message:
137
- 'Importing from $api is only supported in *.routeHooks.{js,ts} files',
138
- },
139
- ],
140
- },
141
- ],
142
- },
143
- overrides: [
144
- {
145
- files: ['*.tsx', '*.js', '*.jsx'],
146
- excludedFiles: ['api/src/**'],
147
- rules: {
148
- 'react-hooks/rules-of-hooks': 'error',
149
- },
150
- },
151
- {
152
- files: ['*.ts', '*.tsx'],
153
- parser: '@typescript-eslint/parser',
154
- extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
155
- rules: {
156
- // TODO: look into enabling these eventually
157
- '@typescript-eslint/no-empty-function': 'off',
158
- '@typescript-eslint/prefer-function-type': 'off',
159
-
160
- // Specific 'recommended' rules we alter
161
- '@typescript-eslint/no-var-requires': 'off',
162
- '@typescript-eslint/no-require-imports': 'off',
163
- '@typescript-eslint/no-empty-object-type': 'off',
164
- '@typescript-eslint/no-unused-vars': [
165
- 'error',
166
- { varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
167
- ],
168
- },
169
- },
170
- {
171
- files: ['*.test.*', '**/__mocks__/**'],
172
- env: {
173
- node: true,
174
- es6: true,
175
- commonjs: true,
176
- jest: true,
177
- },
178
- },
179
- {
180
- files: [
181
- '.babelrc.js',
182
- 'babel.config.js',
183
- '.eslintrc.js',
184
- '*.config.js',
185
- '*.config.cjs',
186
- 'jest.setup.js',
187
- ],
188
- env: {
189
- node: true,
190
- commonjs: true,
191
- jest: true,
192
- },
193
- },
194
- {
195
- files: [
196
- 'web/src/**/*.routeHooks.{js,ts}',
197
- 'web/src/entry.server.{jsx,tsx}',
198
- ],
199
- rules: { 'no-restricted-imports': 'off' },
200
- },
201
- ],
202
- }