-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy path.eslintrc.js
More file actions
129 lines (127 loc) · 3.67 KB
/
Copy path.eslintrc.js
File metadata and controls
129 lines (127 loc) · 3.67 KB
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
const fs = require('fs');
const packages = fs
.readdirSync(`${__dirname}/packages`, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
module.exports = {
parser: '@babel/eslint-parser',
parserOptions: {
requireConfigFile: false,
babelOptions: {
presets: ['@babel/preset-react'],
},
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:cypress/recommended',
'prettier',
'plugin:import/recommended',
],
env: {
es6: true,
browser: true,
node: true,
jest: true,
'cypress/globals': true,
},
globals: {
DECAP_CMS_VERSION: false,
DECAP_CMS_APP_VERSION: false,
DECAP_CMS_CORE_VERSION: false,
CMS_ENV: false,
},
rules: {
'no-console': [0],
'react/prop-types': [0],
// With the new React JSX transform (jsx: "react-jsx"), React doesn't need to be in scope
'react/react-in-jsx-scope': 'off',
'react/jsx-uses-react': 'off',
'import/no-named-as-default': 0,
'import/order': [
'error',
{
'newlines-between': 'always',
groups: [['builtin', 'external'], ['internal', 'parent', 'sibling', 'index'], ['type']],
},
],
'no-duplicate-imports': 'error',
'@emotion/no-vanilla': 'error',
'@emotion/pkg-renaming': 'error',
'@emotion/import-from-emotion': 'error',
'@emotion/styled-import': 'error',
'require-atomic-updates': [0],
'object-shorthand': ['error', 'always'],
'func-style': ['error', 'declaration'],
'prefer-const': [
'error',
{
destructuring: 'all',
},
],
'unicorn/prefer-string-slice': 'error',
'react/no-unknown-property': [
'error',
{ ignore: ['css', 'bold', 'italic', 'delete', 'strikethrough'] },
],
},
plugins: ['babel', '@emotion', 'cypress', 'unicorn'],
settings: {
react: {
version: 'detect',
},
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
exports: {},
},
'import/core-modules': [...packages, 'decap-cms-app/dist/esm'],
},
overrides: [
{
files: ['packages/decap-cms-widget-richtext/src/**/*.js'],
rules: {
// PlateJS re-exports named APIs through package export subpaths that
// eslint-plugin-import does not reliably trace, even though Node resolves them.
'import/named': 'off',
},
},
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:cypress/recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:import/recommended',
'plugin:import/typescript',
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
rules: {
'no-duplicate-imports': [0], // handled by @typescript-eslint
'@typescript-eslint/ban-types': [0], // TODO enable in future
'@typescript-eslint/no-non-null-assertion': [0],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': [0],
'@typescript-eslint/explicit-module-boundary-types': [0],
'@typescript-eslint/no-duplicate-imports': 'error',
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: true, variables: true },
],
// With the new React JSX transform (jsx: "react-jsx"), React doesn't need to be in scope
'react/react-in-jsx-scope': 'off',
'react/jsx-uses-react': 'off',
},
},
],
};