forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
146 lines (143 loc) · 3.95 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
const path = require('path')
const findUp = require('findup-sync')
// Framework Babel config is monorepo root ./babel.config.js
// `yarn lint` runs for each workspace, which needs findup for path to root
const findBabelConfig = (cwd = process.cwd()) => {
const configPath = findUp('babel.config.js', { cwd })
if (!configPath) {
throw new Error(`Eslint-parser could not find a "babel.config.js" file`)
}
return configPath
}
module.exports = {
extends: path.join(__dirname, 'packages/eslint-config/shared.js'),
parserOptions: {
babelOptions: {
configFile: findBabelConfig(),
},
},
ignorePatterns: [
'dist',
'fixtures',
'packages/structure/**',
'packages/internal/src/build/babelPlugins/__tests__/__fixtures__/**/*',
'packages/core/**/__fixtures__/**/*',
'packages/codemods/**/__testfixtures__/**/*',
'packages/core/config/storybook/**/*',
'packages/create-redwood-app/template/web/src/Routes.tsx',
],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'import/order': [
'error',
{
'newlines-between': 'always',
pathGroupsExcludedImportTypes: ['react'],
pathGroups: [
{
pattern: 'react',
group: 'builtin',
position: 'after',
},
{
pattern: '@redwoodjs/**',
group: 'external',
position: 'after',
},
{
pattern: 'src/lib/test',
group: 'parent',
position: 'before',
},
{
pattern: 'src/**',
group: 'parent',
position: 'before',
},
],
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
curly: 'error',
},
overrides: [
{
// We override import order of the CRWA graphql function because we want the grouped glob imports
// to be ordered separately.
// Note: for some reason, the pattern as eslints each file to match against the pattern
// the files pattern has to be the filename and not the relative path (as one might expect)
files: ['graphql.ts'],
rules: {
'import/order': 'off',
},
},
{
files: ['packages/structure/**'],
rules: {
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-case-declarations': 'off',
'prefer-const': 'off',
'no-empty': 'warn',
'no-unused-expressions': 'off',
},
},
// Browser Context
//
// We prevent "window" from being used, and instead require "global".
// This is because prerender runs in the NodeJS context it's undefined.
{
files: [
'packages/auth/src/**',
'packages/forms/src/**',
'packages/prerender/src/browserUtils/**',
'packages/router/src/**',
'packages/web/src/**',
],
env: {
es6: true,
browser: true,
},
globals: {
React: 'readonly', // We auto-import React via Babel.
window: 'off', // Developers should use `global` instead of window. Since window is undefined in NodeJS.
},
},
// Entry.js rules
{
files: ['packages/web/src/entry/index.js'],
env: {
es6: true,
browser: true,
},
globals: {
React: 'readonly',
},
},
// NodeJS Context
{
files: [
'packages/api/src/**',
'packages/api-server/src/**',
'packages/cli/src/**',
'packages/core/config/**',
'packages/create-redwood-app/src/*.js',
'packages/internal/src/**',
'packages/prerender/src/**',
'packages/structure/src/**',
'packages/testing/src/**',
'packages/testing/config/**',
'packages/eslint-config/*.js',
'packages/record/src/**',
'packages/telemetry/src/**',
],
env: {
es6: true,
node: true,
},
},
],
}