This repository was archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.eslintrc.js
134 lines (128 loc) · 3.2 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
// NOTE: These packages need decoupling from browser APIs to work in react-native
const browserProxies = [
'react-cosmos-apollo-proxy',
'react-cosmos-xhr-proxy',
'react-cosmos-fetch-proxy',
'react-cosmos-localstorage-proxy'
];
module.exports = {
parser: 'babel-eslint',
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:react/recommended',
'plugin:flowtype/recommended'
],
env: {
'shared-node-browser': true,
commonjs: true,
es6: true
},
settings: {
react: {
version: '16.4'
}
},
rules: {
'spaced-comment': 2,
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: 'return' }
],
// Cosmos uses console.log/warn/error to inform users ¯\_(ツ)_/¯
// Not ideal, because temporary console calls can be committed by mistake.
'no-console': 0,
// I don't believe in default exports anymore
'import/default': 0,
// There are a lot lot of test components in the repo...
'react/prop-types': 0,
'react/display-name': 0,
'react/no-string-refs': 0,
'react/no-unescaped-entities': 0,
// TODO: Replace deprecated methods
'react/no-deprecated': 1,
// flowtype/generic-spacing conflicts with Prettier
'flowtype/generic-spacing': 0
},
overrides: [
nodeEnv([
'.jest/config{,.ts}.js',
'scripts/**/*.js',
'packages/{react-cosmos-config,react-cosmos-scripts,react-cosmos-telescope}/src/**/*.js',
'packages/{react-cosmos-shared,react-cosmos-classic,react-cosmos-voyager2}/src/server/**/*.js',
'packages/react-cosmos-classic/bin/**/*.js',
'packages/react-cosmos-voyager/scripts/generate-use-cases.js',
'packages/react-cosmos-playground/webpack.config.js',
'examples/apollo/server.js',
'examples/browserify/server.js',
'examples/mixed-paths/webpack.config.js',
'examples/webpack-dll/{webpack.config,webpack.vendor.config}.js'
]),
browserEnv([
`packages/{${[
'react-cosmos-playground',
'react-querystring-router',
...browserProxies
].join(',')}}/src/**/*.js`,
'packages/{react-cosmos-classic,react-cosmos-voyager2}/src/client/**/*.js',
'packages/react-cosmos-loader/src/dom/**/*.js'
]),
jestEnv([
'.jest/setup-framework.js',
'**/__mocks__/**/*.js',
'**/__tests__/**/*.js',
'**/?(*.)test.js',
'**/testHelpers/**/*.js',
'packages/react-cosmos-telescope/src/**/*.js'
]),
cypressEnv(['cypress/**/*.js']),
userBuildEnv(['packages/react-cosmos-classic/src/client/**/*.js'])
]
};
function nodeEnv(files) {
return {
files,
env: {
node: true
}
};
}
function browserEnv(files) {
return {
files,
env: {
browser: true
}
};
}
function jestEnv(files) {
return {
files,
env: {
jest: true,
node: true
}
};
}
function cypressEnv(files) {
return {
files,
env: {
mocha: true
},
globals: {
cy: true
}
};
}
function userBuildEnv(files) {
return {
files,
globals: {
__DEV__: true,
// Enable use of process.env.NODE_ENV
process: true
}
};
}