@graphcommerce/eslint-config-pwa 9.1.0-canary.54 → 10.0.0-canary.56
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/CHANGELOG.md +82 -0
- package/index.mjs +271 -0
- package/package.json +21 -14
- package/index.js +0 -225
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.0.0-canary.56
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#2546](https://github.com/graphcommerce-org/graphcommerce/pull/2546) [`ed9332a`](https://github.com/graphcommerce-org/graphcommerce/commit/ed9332a7f78966d932041d9a7725641edc92b28d) - ## GraphCommerce 10 - Turbopack Support
|
|
8
|
+
|
|
9
|
+
This major release brings full Turbopack compatibility, dramatically improving development speed.
|
|
10
|
+
|
|
11
|
+
### 🚀 Turbopack-Compatible Interceptor System
|
|
12
|
+
|
|
13
|
+
The entire plugin/interceptor system has been rewritten to work with Turbopack:
|
|
14
|
+
|
|
15
|
+
- **No more Webpack plugins** - Removed `InterceptorPlugin` webpack plugin entirely
|
|
16
|
+
- **File-based interception** - Original files are moved to `.original.tsx` and replaced with interceptor content
|
|
17
|
+
- **Direct imports** - Interceptors import from `.original` files instead of embedding source
|
|
18
|
+
- **New CLI commands**:
|
|
19
|
+
- `graphcommerce codegen-interceptors` - Generate interceptor files
|
|
20
|
+
- `graphcommerce cleanup-interceptors` - Reset interceptor system, restore original files
|
|
21
|
+
- **Stable file hashing** - Deterministic interceptor generation for better caching
|
|
22
|
+
|
|
23
|
+
### ⚙️ Treeshakable Configuration System
|
|
24
|
+
|
|
25
|
+
Replaced Webpack `DefinePlugin`-based `import.meta.graphCommerce` with a new generated configuration system:
|
|
26
|
+
|
|
27
|
+
- **New `codegen-config-values` command** - Generates TypeScript files with precise typing
|
|
28
|
+
- **Schema-driven** - Dynamically introspects Zod schemas to determine all available properties
|
|
29
|
+
- **Fully treeshakable** - Unused config values are eliminated from the bundle
|
|
30
|
+
- **Type-safe** - Uses `Get<GraphCommerceConfig, 'path'>` for nested property access
|
|
31
|
+
- **Separate files for nested objects** - Optimal treeshaking for complex configurations
|
|
32
|
+
|
|
33
|
+
### 🔧 withGraphCommerce Changes
|
|
34
|
+
|
|
35
|
+
- **Removed** `InterceptorPlugin` - No longer needed with file-based interception
|
|
36
|
+
- **Removed** `DefinePlugin` for `import.meta.graphCommerce` - Replaced with generated config
|
|
37
|
+
- **Removed** `@mui/*` alias rewrites - No longer required
|
|
38
|
+
- **Added** Turbopack loader rules for `.yaml`, `.yml`, and `.po` files
|
|
39
|
+
- **Added** `serverExternalPackages` for all `@whatwg-node/*` packages
|
|
40
|
+
- **Added** `optimizePackageImports` for better bundle optimization
|
|
41
|
+
- **Added** `images.qualities: [52, 75]` for Next.js image optimization
|
|
42
|
+
|
|
43
|
+
### 📦 Lingui Configuration
|
|
44
|
+
|
|
45
|
+
- **Renamed** `lingui.config.js` → `lingui.config.ts` with TypeScript support
|
|
46
|
+
- **Updated** `@graphcommerce/lingui-next/config` to TypeScript with proper exports
|
|
47
|
+
- **Simplified** formatter options
|
|
48
|
+
|
|
49
|
+
### ⚛️ React 19 & Next.js 16 Compatibility
|
|
50
|
+
|
|
51
|
+
- Updated `RefObject<T>` types for React 19 (now includes `null` by default)
|
|
52
|
+
- Replaced deprecated `React.VFC` with `React.FC`
|
|
53
|
+
- Fixed `useRef` calls to require explicit initial values
|
|
54
|
+
- Updated `MutableRefObject` usage in `framer-scroller`
|
|
55
|
+
|
|
56
|
+
### 📋 ESLint 9 Flat Config
|
|
57
|
+
|
|
58
|
+
- Migrated from legacy `.eslintrc` to new flat config format (`eslint.config.mjs`)
|
|
59
|
+
- Updated `@typescript-eslint/*` packages to v8
|
|
60
|
+
- Fixed AST selector for `SxProps` rule (`typeParameters` → `typeArguments`)
|
|
61
|
+
|
|
62
|
+
### 🔄 Apollo Client
|
|
63
|
+
|
|
64
|
+
- Fixed deprecated `name` option → `clientAwareness: { name: 'ssr' }`
|
|
65
|
+
- Updated error handling types to accept `ApolloError | null | undefined`
|
|
66
|
+
|
|
67
|
+
### ⚠️ Breaking Changes
|
|
68
|
+
|
|
69
|
+
- **Node.js 24.x not supported** - Restricted to `>=20 <24.0.0` due to [nodejs/undici#4290](https://github.com/nodejs/undici/issues/4290)
|
|
70
|
+
- **Interceptor files changed** - Original components now at `.original.tsx`
|
|
71
|
+
- **Config access changed** - Use generated config values instead of `import.meta.graphCommerce`
|
|
72
|
+
- **ESLint config format** - Must use flat config (`eslint.config.mjs`)
|
|
73
|
+
- **Lingui config** - Rename `lingui.config.js` to `lingui.config.ts`
|
|
74
|
+
|
|
75
|
+
### 🗑️ Removed
|
|
76
|
+
|
|
77
|
+
- `InterceptorPlugin` webpack plugin
|
|
78
|
+
- `configToImportMeta` utility
|
|
79
|
+
- Webpack `DefinePlugin` usage for config
|
|
80
|
+
- `@mui/*` modern alias rewrites
|
|
81
|
+
- Debug plugins (`CircularDependencyPlugin`, `DuplicatesPlugin`) ([@paales](https://github.com/paales))
|
|
82
|
+
|
|
83
|
+
## 9.1.0-canary.55
|
|
84
|
+
|
|
3
85
|
## 9.1.0-canary.54
|
|
4
86
|
|
|
5
87
|
## 9.1.0-canary.53
|
package/index.mjs
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'
|
|
4
|
+
import { FlatCompat } from '@eslint/eslintrc'
|
|
5
|
+
import eslint from '@eslint/js'
|
|
6
|
+
import nextPlugin from '@next/eslint-plugin-next'
|
|
7
|
+
import typescriptPlugin from '@typescript-eslint/eslint-plugin'
|
|
8
|
+
import typescriptParser from '@typescript-eslint/parser'
|
|
9
|
+
import importPlugin from 'eslint-plugin-import'
|
|
10
|
+
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'
|
|
11
|
+
import reactPlugin from 'eslint-plugin-react'
|
|
12
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks'
|
|
13
|
+
import globals from 'globals'
|
|
14
|
+
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
16
|
+
const __dirname = path.dirname(__filename)
|
|
17
|
+
|
|
18
|
+
const compat = new FlatCompat({
|
|
19
|
+
baseDirectory: __dirname,
|
|
20
|
+
recommendedConfig: eslint.configs.recommended,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
24
|
+
export default [
|
|
25
|
+
// React hooks recommended rules
|
|
26
|
+
reactHooksPlugin.configs.flat.recommended,
|
|
27
|
+
|
|
28
|
+
// Global ignores
|
|
29
|
+
{
|
|
30
|
+
ignores: [
|
|
31
|
+
'**/node_modules/**',
|
|
32
|
+
'**/.next/**',
|
|
33
|
+
'**/dist/**',
|
|
34
|
+
'**/.mesh/**',
|
|
35
|
+
'**/generated/**',
|
|
36
|
+
'**/*.interceptor.tsx',
|
|
37
|
+
'**/*.interceptor.ts',
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
// Base config for all files
|
|
42
|
+
{
|
|
43
|
+
languageOptions: {
|
|
44
|
+
ecmaVersion: 2022,
|
|
45
|
+
sourceType: 'module',
|
|
46
|
+
globals: {
|
|
47
|
+
...globals.browser,
|
|
48
|
+
...globals.node,
|
|
49
|
+
...globals.es2022,
|
|
50
|
+
Atomics: 'readonly',
|
|
51
|
+
SharedArrayBuffer: 'readonly',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
plugins: {
|
|
55
|
+
react: reactPlugin,
|
|
56
|
+
'@next/next': nextPlugin,
|
|
57
|
+
import: importPlugin,
|
|
58
|
+
'jsx-a11y': jsxA11yPlugin,
|
|
59
|
+
},
|
|
60
|
+
settings: {
|
|
61
|
+
react: {
|
|
62
|
+
version: 'detect',
|
|
63
|
+
},
|
|
64
|
+
'import/resolver': {
|
|
65
|
+
typescript: true,
|
|
66
|
+
node: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
rules: {
|
|
70
|
+
// eslint
|
|
71
|
+
'default-case': 'off',
|
|
72
|
+
'no-plusplus': 'off',
|
|
73
|
+
'no-param-reassign': ['error', { props: false }],
|
|
74
|
+
'no-console': [1, { allow: ['warn', 'error', 'info'] }],
|
|
75
|
+
'spaced-comment': ['error', 'always', { markers: ['/'] }],
|
|
76
|
+
'prefer-const': ['error', { destructuring: 'all' }],
|
|
77
|
+
'no-underscore-dangle': [
|
|
78
|
+
'error',
|
|
79
|
+
{ allow: ['__typename', '__type', '_N_X', '_N_Y', '__N', '__NEXT'] },
|
|
80
|
+
],
|
|
81
|
+
'no-restricted-syntax': [
|
|
82
|
+
'error',
|
|
83
|
+
{
|
|
84
|
+
selector: 'ForInStatement',
|
|
85
|
+
message:
|
|
86
|
+
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
selector: 'LabeledStatement',
|
|
90
|
+
message:
|
|
91
|
+
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
selector: 'WithStatement',
|
|
95
|
+
message:
|
|
96
|
+
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
selector: 'TSTypeReference[typeName.name="SxProps"]:not([typeArguments])',
|
|
100
|
+
message: 'SxProps must have Theme parameter to avoid significant compiler slowdown.',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
selector: 'TSTypeReference[typeName.name="Components"]:not([typeArguments])',
|
|
104
|
+
message: 'Components must have Theme parameter to avoid significant compiler slowdown.',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
|
|
108
|
+
// import
|
|
109
|
+
'import/prefer-default-export': 'off',
|
|
110
|
+
'import/no-extraneous-dependencies': [
|
|
111
|
+
'error',
|
|
112
|
+
{
|
|
113
|
+
devDependencies: [
|
|
114
|
+
'next.config.js',
|
|
115
|
+
'next.config.ts',
|
|
116
|
+
'**/test/**',
|
|
117
|
+
'**/*.d.ts',
|
|
118
|
+
'**/*.spec.ts',
|
|
119
|
+
'**/__tests__/**',
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
'import/order': 'off',
|
|
124
|
+
'import/no-relative-packages': 'error',
|
|
125
|
+
|
|
126
|
+
// next
|
|
127
|
+
'@next/next/no-html-link-for-pages': 'off',
|
|
128
|
+
|
|
129
|
+
// jsx-a11y
|
|
130
|
+
'jsx-a11y/anchor-is-valid': 'off',
|
|
131
|
+
|
|
132
|
+
// react
|
|
133
|
+
'react/prop-types': 'off',
|
|
134
|
+
'react/jsx-props-no-spreading': 'off',
|
|
135
|
+
'react/react-in-jsx-scope': 'off',
|
|
136
|
+
'react/require-default-props': 'off',
|
|
137
|
+
'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }],
|
|
138
|
+
'react/self-closing-comp': ['warn'],
|
|
139
|
+
'react/jsx-no-duplicate-props': ['error', { ignoreCase: false }],
|
|
140
|
+
'react/function-component-definition': [
|
|
141
|
+
'error',
|
|
142
|
+
{
|
|
143
|
+
namedComponents: 'function-declaration',
|
|
144
|
+
unnamedComponents: 'arrow-function',
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
|
|
148
|
+
|
|
149
|
+
// react-hooks (base rules come from flat config below, we just customize exhaustive-deps)
|
|
150
|
+
'react-hooks/exhaustive-deps': [
|
|
151
|
+
'error',
|
|
152
|
+
{ additionalHooks: '(useIsomorphicLayoutEffect|useMemoDeep)' },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
// TypeScript files
|
|
158
|
+
{
|
|
159
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
160
|
+
languageOptions: {
|
|
161
|
+
parser: typescriptParser,
|
|
162
|
+
parserOptions: {
|
|
163
|
+
projectService: true,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
plugins: {
|
|
167
|
+
'@typescript-eslint': typescriptPlugin,
|
|
168
|
+
},
|
|
169
|
+
rules: {
|
|
170
|
+
...typescriptPlugin.configs.recommended.rules,
|
|
171
|
+
'@typescript-eslint/indent': 'off',
|
|
172
|
+
'@typescript-eslint/semi': 'off',
|
|
173
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
174
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
175
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
176
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
177
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
|
178
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
179
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
180
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
181
|
+
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
|
|
182
|
+
'@typescript-eslint/no-unbound-method': 'off',
|
|
183
|
+
'@typescript-eslint/no-restricted-imports': [
|
|
184
|
+
'warn',
|
|
185
|
+
{
|
|
186
|
+
paths: [
|
|
187
|
+
{
|
|
188
|
+
name: 'next/image',
|
|
189
|
+
message: "Please use `import { Image } from '@graphcommerce/image'` instead.",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: '@mui/system',
|
|
193
|
+
message: "Please use `@mui/material'` instead.",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: '@mui/material',
|
|
197
|
+
importNames: [
|
|
198
|
+
'Autocomplete',
|
|
199
|
+
'Checkbox',
|
|
200
|
+
'Radio',
|
|
201
|
+
'Select',
|
|
202
|
+
'Slider',
|
|
203
|
+
'Switch',
|
|
204
|
+
'TextField',
|
|
205
|
+
'ToggleButtonGroup',
|
|
206
|
+
],
|
|
207
|
+
message: `Please use \`import { SelectElement, TextFieldElement, etc } from '@graphcommerce/ecommerce-ui'\` for usage in forms. https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/ecommerce-ui/components/FormComponents You can add '// eslint-disable-next-line @typescript-eslint/no-restricted-imports' comment if you're sure you want to use it.`,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: '@mui/material',
|
|
211
|
+
importNames: ['useMediaQuery'],
|
|
212
|
+
message: `useMediaQuery can cause large CLS/LCP issues when used to render a specific UI on a breakpoint. See https://mui.com/system/display/#hiding-elements for alternatives. You can add '// eslint-disable-next-line @typescript-eslint/no-restricted-imports' comment if you're sure you want to use it.`,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: '@emotion/react',
|
|
216
|
+
importNames: ['Theme', 'GlobalProps', 'ThemeContext'],
|
|
217
|
+
message: 'Import from @mui/material instead of @emotion/react.',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
patterns: [
|
|
221
|
+
{
|
|
222
|
+
group: ['*.interceptor'],
|
|
223
|
+
message: 'Importing *.interceptor is NOT allowed',
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
'@typescript-eslint/consistent-type-imports': 'warn',
|
|
229
|
+
'import/no-duplicates': 'off',
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
// TSX files - no default export
|
|
234
|
+
{
|
|
235
|
+
files: ['**/*.tsx'],
|
|
236
|
+
rules: { 'import/no-default-export': 'error' },
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
// Copy files - relax rules
|
|
240
|
+
{
|
|
241
|
+
files: ['**/copy/**/*.tsx'],
|
|
242
|
+
rules: { 'import/no-extraneous-dependencies': 'off' },
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
// Pages - allow default export
|
|
246
|
+
{
|
|
247
|
+
files: ['**/pages/**/*.tsx'],
|
|
248
|
+
rules: { 'import/no-default-export': 'off' },
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
// Test files
|
|
252
|
+
{
|
|
253
|
+
files: ['**/*.spec.ts', '**/*.spec.tsx', '**/__tests__/**', 'scripts/**', 'test/**'],
|
|
254
|
+
languageOptions: {
|
|
255
|
+
globals: {
|
|
256
|
+
...globals.jest,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
rules: {
|
|
260
|
+
'import/no-extraneous-dependencies': 'off',
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
// JavaScript files
|
|
265
|
+
{
|
|
266
|
+
files: ['**/*.js', '**/*.jsx', '**/*.mjs'],
|
|
267
|
+
rules: {
|
|
268
|
+
semi: 'off',
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
]
|
package/package.json
CHANGED
|
@@ -2,22 +2,29 @@
|
|
|
2
2
|
"name": "@graphcommerce/eslint-config-pwa",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "
|
|
6
|
-
"
|
|
5
|
+
"version": "10.0.0-canary.56",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.mjs"
|
|
10
|
+
},
|
|
7
11
|
"dependencies": {
|
|
8
|
-
"@
|
|
9
|
-
"@
|
|
10
|
-
"@
|
|
11
|
-
"@typescript-
|
|
12
|
-
"eslint": "
|
|
13
|
-
"eslint-
|
|
14
|
-
"eslint
|
|
15
|
-
"eslint
|
|
16
|
-
"eslint-
|
|
12
|
+
"@eslint/compat": "^1.2.9",
|
|
13
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
14
|
+
"@eslint/js": "^9.39.1",
|
|
15
|
+
"@graphcommerce/typescript-config-pwa": "10.0.0-canary.56",
|
|
16
|
+
"@next/eslint-plugin-next": "16.0.6",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
18
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
19
|
+
"eslint": "^9.39.1",
|
|
20
|
+
"eslint-config-prettier": "10.1.8",
|
|
21
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
22
|
+
"eslint-plugin-import": "2.32.0",
|
|
17
23
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
18
|
-
"eslint-plugin-react": "^7.37.
|
|
19
|
-
"eslint-plugin-react-hooks": "
|
|
20
|
-
"
|
|
24
|
+
"eslint-plugin-react": "^7.37.5",
|
|
25
|
+
"eslint-plugin-react-hooks": "7.0.1",
|
|
26
|
+
"globals": "^16.2.0",
|
|
27
|
+
"typescript": "5.9.3"
|
|
21
28
|
},
|
|
22
29
|
"sideEffects": false
|
|
23
30
|
}
|
package/index.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
es2022: true,
|
|
5
|
-
node: true,
|
|
6
|
-
},
|
|
7
|
-
extends: ['airbnb', 'plugin:import/recommended', 'prettier'],
|
|
8
|
-
globals: {
|
|
9
|
-
Atomics: 'readonly',
|
|
10
|
-
SharedArrayBuffer: 'readonly',
|
|
11
|
-
},
|
|
12
|
-
parserOptions: {
|
|
13
|
-
ecmaFeatures: {
|
|
14
|
-
jsx: true,
|
|
15
|
-
},
|
|
16
|
-
ecmaVersion: 2018,
|
|
17
|
-
sourceType: 'module',
|
|
18
|
-
},
|
|
19
|
-
plugins: ['react', '@next/eslint-plugin-next'],
|
|
20
|
-
rules: {
|
|
21
|
-
// eslint
|
|
22
|
-
'default-case': 'off',
|
|
23
|
-
'no-plusplus': 'off',
|
|
24
|
-
'no-param-reassign': ['error', { props: false }],
|
|
25
|
-
'no-console': [1, { allow: ['warn', 'error', 'info'] }],
|
|
26
|
-
'spaced-comment': ['error', 'always', { markers: ['/'] }],
|
|
27
|
-
'prefer-const': ['error', { destructuring: 'all' }],
|
|
28
|
-
'no-underscore-dangle': [
|
|
29
|
-
'error',
|
|
30
|
-
{ allow: ['__typename', '__type', '_N_X', '_N_Y', '__N', '__NEXT'] },
|
|
31
|
-
],
|
|
32
|
-
'no-restricted-syntax': [
|
|
33
|
-
'error',
|
|
34
|
-
{
|
|
35
|
-
selector: 'ForInStatement',
|
|
36
|
-
message:
|
|
37
|
-
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
selector: 'LabeledStatement',
|
|
41
|
-
message:
|
|
42
|
-
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
selector: 'WithStatement',
|
|
46
|
-
message:
|
|
47
|
-
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
selector: 'TSTypeReference[typeName.name="SxProps"]:not([typeParameters])',
|
|
51
|
-
message: 'SxProps must have Theme parameter to avoid significant compiler slowdown.',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
selector: 'TSTypeReference[typeName.name="Components"]:not([typeParameters])',
|
|
55
|
-
message: 'Components must have Theme parameter to avoid significant compiler slowdown.',
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
|
|
59
|
-
// plugin:import/recommended & plugin:import/typescript
|
|
60
|
-
'import/prefer-default-export': 'off',
|
|
61
|
-
'import/no-extraneous-dependencies': [
|
|
62
|
-
'error',
|
|
63
|
-
{
|
|
64
|
-
devDependencies: [
|
|
65
|
-
'next.config.js',
|
|
66
|
-
'**/test/**',
|
|
67
|
-
'**/*.d.ts',
|
|
68
|
-
'**/*.spec.ts',
|
|
69
|
-
'**/__tests__/**',
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
'import/order': 'off', // Handled by prettier
|
|
74
|
-
'import/no-relative-packages': 'error',
|
|
75
|
-
|
|
76
|
-
// next
|
|
77
|
-
'@next/next/no-html-link-for-pages': 'off',
|
|
78
|
-
|
|
79
|
-
// jsx-a11y
|
|
80
|
-
'jsx-a11y/anchor-is-valid': 'off',
|
|
81
|
-
|
|
82
|
-
// react
|
|
83
|
-
'react/prop-types': 'off',
|
|
84
|
-
'react/jsx-props-no-spreading': 'off',
|
|
85
|
-
'react/react-in-jsx-scope': 'off',
|
|
86
|
-
'react/require-default-props': 'off',
|
|
87
|
-
'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }],
|
|
88
|
-
'react-hooks/exhaustive-deps': [
|
|
89
|
-
'error',
|
|
90
|
-
{ additionalHooks: '(useIsomorphicLayoutEffect|useMemoDeep)' },
|
|
91
|
-
],
|
|
92
|
-
'react/self-closing-comp': ['warn'],
|
|
93
|
-
'react/jsx-no-duplicate-props': ['error', { ignoreCase: false }],
|
|
94
|
-
'react/function-component-definition': [
|
|
95
|
-
'error',
|
|
96
|
-
{
|
|
97
|
-
namedComponents: 'function-declaration',
|
|
98
|
-
unnamedComponents: 'arrow-function',
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
|
|
102
|
-
},
|
|
103
|
-
overrides: [
|
|
104
|
-
// TypeScript files
|
|
105
|
-
{
|
|
106
|
-
files: ['*.ts', '*.tsx'],
|
|
107
|
-
extends: [
|
|
108
|
-
'airbnb-typescript',
|
|
109
|
-
'airbnb/hooks',
|
|
110
|
-
'plugin:@typescript-eslint/recommended',
|
|
111
|
-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
112
|
-
'plugin:import/typescript',
|
|
113
|
-
],
|
|
114
|
-
parser: '@typescript-eslint/parser',
|
|
115
|
-
parserOptions: {
|
|
116
|
-
project: ['./tsconfig.json'],
|
|
117
|
-
},
|
|
118
|
-
plugins: ['@typescript-eslint'],
|
|
119
|
-
rules: {
|
|
120
|
-
'@typescript-eslint/indent': 'off',
|
|
121
|
-
'@typescript-eslint/semi': 'off',
|
|
122
|
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
123
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
124
|
-
'@typescript-eslint/no-unsafe-call': 'off',
|
|
125
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
126
|
-
'@typescript-eslint/no-unsafe-return': 'off',
|
|
127
|
-
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
128
|
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
129
|
-
'@typescript-eslint/naming-convention': 'off',
|
|
130
|
-
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
|
|
131
|
-
'@typescript-eslint/no-unbound-method': 'off',
|
|
132
|
-
'@typescript-eslint/no-restricted-imports': [
|
|
133
|
-
'warn',
|
|
134
|
-
{
|
|
135
|
-
paths: [
|
|
136
|
-
{
|
|
137
|
-
name: 'next/image',
|
|
138
|
-
message: "Please use `import { Image } from '@graphcommerce/image'` instead.",
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: '@mui/system',
|
|
142
|
-
message: "Please use `@mui/material'` instead.",
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: '@mui/material',
|
|
146
|
-
importNames: [
|
|
147
|
-
'Autocomplete',
|
|
148
|
-
'Checkbox',
|
|
149
|
-
'Radio',
|
|
150
|
-
'Select',
|
|
151
|
-
'Slider',
|
|
152
|
-
'Switch',
|
|
153
|
-
'TextField',
|
|
154
|
-
'ToggleButtonGroup',
|
|
155
|
-
],
|
|
156
|
-
message: `Please use \`import { SelectElement, TextFieldElement, etc } from '@graphcommerce/ecommerce-ui'\` for usage in forms. https://github.com/graphcommerce-org/graphcommerce/tree/main/packages/ecommerce-ui/components/FormComponents You can add '// eslint-disable-next-line @typescript-eslint/no-restricted-imports' comment if you're sure you want to use it.`,
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
name: '@mui/material',
|
|
160
|
-
importNames: ['useMediaQuery'],
|
|
161
|
-
message: `useMediaQuery can cause large CLS/LCP issues when used to render a specific UI on a breakpoint. See https://mui.com/system/display/#hiding-elements for alternatives. You can add '// eslint-disable-next-line @typescript-eslint/no-restricted-imports' comment if you're sure you want to use it.`,
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
name: '@emotion/react',
|
|
165
|
-
importNames: ['Theme', 'GlobalProps', 'ThemeContext'],
|
|
166
|
-
message: 'Import from @mui/material instead of @emotion/react.',
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
patterns: [
|
|
170
|
-
{
|
|
171
|
-
group: ['*.interceptor'],
|
|
172
|
-
message: 'Importing *.interceptor is NOT allowed',
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
'@typescript-eslint/consistent-type-imports': 'warn',
|
|
178
|
-
'import/no-duplicates': 'off',
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
files: ['*.tsx'],
|
|
183
|
-
rules: { 'import/no-default-export': ['error'] },
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
files: ['**/copy/**/*.tsx'],
|
|
187
|
-
rules: { 'import/no-extraneous-dependencies': 'off' },
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
files: ['**/pages/**/*.tsx'],
|
|
191
|
-
rules: { 'import/no-default-export': 'off' },
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
files: ['**/*.interceptor.tsx', '**/*.interceptor.ts'],
|
|
195
|
-
rules: {
|
|
196
|
-
'import/export': 'off',
|
|
197
|
-
'import/first': 'off',
|
|
198
|
-
'import/no-extraneous-dependencies': 'off',
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
files: ['generated/*'],
|
|
203
|
-
rules: {
|
|
204
|
-
'@typescript-eslint/camelcase': 'off',
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
files: ['**/*.spec.ts', '**/*.spec.tsx', '**/__tests__/**', 'scripts/**', 'test/**'],
|
|
209
|
-
env: {
|
|
210
|
-
jest: true,
|
|
211
|
-
},
|
|
212
|
-
rules: {
|
|
213
|
-
'import/no-extraneous-dependencies': 'off',
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
// JavaScript files override
|
|
217
|
-
{
|
|
218
|
-
files: ['*.js', '*.jsx', '*.mjs'],
|
|
219
|
-
extends: ['airbnb', 'airbnb/hooks', 'plugin:import/recommended', 'prettier'],
|
|
220
|
-
rules: {
|
|
221
|
-
semi: 'off',
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
],
|
|
225
|
-
}
|