forked from elementor/elementor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
120 lines (120 loc) · 3.44 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
module.exports = {
extends: [
'plugin:react/recommended',
'plugin:no-jquery/deprecated',
'plugin:@wordpress/eslint-plugin/recommended-with-formatting',
'plugin:@elementor/editor/recommended',
'plugin:import/typescript',
],
plugins: [
'babel',
'react',
'@elementor/editor',
'no-jquery',
'@typescript-eslint',
],
parser: '@typescript-eslint/parser',
globals: {
wp: true,
window: true,
document: true,
_: false,
jQuery: false,
JSON: false,
elementorFrontend: true,
require: true,
elementor: true,
DialogsManager: true,
module: true,
React: true,
PropTypes: true,
__: true,
},
parserOptions: {
ecmaVersion: 2017,
requireConfigFile: false,
sourceType: 'module',
babelOptions: {
plugins: [
'@babel/plugin-syntax-import-assertions',
],
parserOpts: {
plugins: [ 'jsx' ],
},
},
},
rules: {
// Custom canceled rules
'no-var': 'off',
'wrap-iife': 'off',
'computed-property-spacing': [ 'error', 'always' ],
'comma-dangle': [ 'error', 'always-multiline' ],
'no-undef': 'off',
'no-unused-vars': [ 'warn', { ignoreRestSiblings: true } ],
'dot-notation': 'error',
'no-shadow': 'error',
'no-lonely-if': 'error',
'no-mixed-operators': 'error',
'no-nested-ternary': 'error',
'no-cond-assign': 'error',
indent: [ 1, 'tab', { SwitchCase: 1 } ],
'padded-blocks': [ 'error', 'never' ],
'one-var-declaration-per-line': 'error',
'array-bracket-spacing': [ 'error', 'always' ],
'no-else-return': 'error',
'no-console': 'warn',
// End of custom canceled rules
'arrow-parens': [ 'error', 'always' ],
'brace-style': [ 'error', '1tbs' ],
'jsx-quotes': 'error',
'no-bitwise': [ 'error', { allow: [ '^' ] } ],
'no-caller': 'error',
'no-debugger': 'warn',
'no-eval': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[callee.name=/^__|_n|_x$/]:not([arguments.0.type=/^Literal|BinaryExpression$/])',
message: 'Translate function arguments must be string literals.',
},
{
selector: 'CallExpression[callee.name=/^_n|_x$/]:not([arguments.1.type=/^Literal|BinaryExpression$/])',
message: 'Translate function arguments must be string literals.',
},
{
selector: 'CallExpression[callee.name=_nx]:not([arguments.2.type=/^Literal|BinaryExpression$/])',
message: 'Translate function arguments must be string literals.',
},
],
'prefer-const': 'warn',
yoda: [ 'error', 'always', {
onlyEquality: true,
} ],
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'error',
'react/no-deprecated': 'warn', // Temporary until we remove the deprecated components
'babel/semi': 1,
'jsdoc/check-tag-names': [ 'error', { definedTags: [ 'jest-environment' ] } ],
'jsdoc/require-returns-description': 'off', // We prefer self-explanatory method names
'import/no-unresolved': [ 2, { ignore: [ 'elementor', 'modules', '@wordpress/i18n', 'e-utils', 'e-styles', 'react' ] } ],
'import/no-extraneous-dependencies': 'off',
'@wordpress/i18n-ellipsis': 'off', // We don't use the ellipsis char because everything is already translated with regular '...'
'capitalized-comments': [
'error',
'always',
{
ignorePattern: 'webpackChunkName|webpackIgnore|jQuery',
ignoreConsecutiveComments: true,
},
],
'spaced-comment': [ 'error', 'always', { markers: [ '!' ] } ],
},
settings: {
'import/resolver': {
node: {
extensions: [ '.js', '.jsx', '.ts', '.tsx', '.json' ],
},
},
jsdoc: { mode: 'typescript' },
},
};