PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / eslint.config.mjs

eslint.config.mjs in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at eslint.config.mjs

299 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { createRequire } from 'node:module';
2 import { fixupConfigRules } from '@eslint/compat';
3 import { FlatCompat } from '@eslint/eslintrc';
4 import wordpress from '@wordpress/eslint-plugin';
5 import noJquery from 'eslint-plugin-no-jquery';
6 import playwright from 'eslint-plugin-playwright';
7 import tseslint from 'typescript-eslint';
8
9 const require = createRequire( import.meta.url );
10 const compat = new FlatCompat( {
11 baseDirectory: import.meta.dirname,
12 resolvePluginsRelativeTo: import.meta.dirname,
13 } );
14
15 const localRules = require( './eslint-local-rules.js' );
16
17 const noJqueryRules = fixupConfigRules(
18 compat.extends( 'plugin:no-jquery/deprecated' ),
19 ).reduce( ( rules, config ) => ( { ...rules, ...config.rules } ), {} );
20
21 const elementorGlobals = {
22 wp: 'writable',
23 window: 'writable',
24 document: 'writable',
25 _: 'readonly',
26 jQuery: 'readonly',
27 JSON: 'readonly',
28 elementorFrontend: 'writable',
29 require: 'writable',
30 elementor: 'writable',
31 DialogsManager: 'writable',
32 module: 'writable',
33 React: 'writable',
34 PropTypes: 'writable',
35 __: 'writable',
36 };
37
38 export default [
39 {
40 ignores: [
41 'assets/lib/**/*.js',
42 'assets/js/',
43 '**/*.min.js',
44 '**/node_modules/**',
45 '**/vendor/**',
46 '**/vendor_prefixed/**',
47 'build/**',
48 'tests/qunit/setup/tinymce.js',
49 '/tmp/**',
50 'packages/**',
51 'eslint-local-rules.js',
52 '.eslintrc.js',
53 'scripts/create-version-change.js',
54 'coverage-report/',
55 'node_modules/',
56 '.sass-cache/',
57 'log/',
58 'vendor/',
59 'local-site/',
60 'tmp/',
61 '8888/',
62 '8889/',
63 'data/languages/',
64 'tests/data',
65 'http-playground/',
66 'assets/css/',
67 'assets/lib/swiper/css/swiper*.css',
68 '*.log',
69 '*.map',
70 '/templates/',
71 '/hello-elementor/',
72 '.turbo/',
73 'yarn.lock',
74 '.project/',
75 '.vscode/',
76 '!.vscode/extensions.json',
77 '.idea/',
78 'Thumbs.db',
79 '*.DS_Store',
80 'coverage/',
81 '.zimud.json',
82 '.phpunit.result.cache',
83 '.npmrc',
84 '.cursor/',
85 '!.cursor/rules/',
86 '.claude/',
87 '*.cache',
88 'test-results/',
89 '**/storageState-*.json',
90 'tests/playwright/config/local.config.js',
91 'playwright-report',
92 'tests/playwright/blob-report',
93 '**/allure-results',
94 'playwright-test-results',
95 '**/.env',
96 'docker-output/',
97 '.lighthouserc.js',
98 '.grunt-config/**',
99 '.github/scripts/**',
100 ],
101 },
102 ...wordpress.configs[ 'recommended-with-formatting' ],
103 ...fixupConfigRules( compat.extends( 'plugin:import/typescript' ) ),
104 {
105 plugins: {
106 'no-jquery': noJquery,
107 'local-rules': { rules: localRules },
108 },
109 languageOptions: {
110 ecmaVersion: 2023,
111 sourceType: 'module',
112 globals: elementorGlobals,
113 parserOptions: {
114 requireConfigFile: false,
115 babelOptions: {
116 plugins: [ '@babel/plugin-syntax-import-assertions' ],
117 parserOpts: {
118 plugins: [ 'jsx' ],
119 },
120 },
121 },
122 },
123 settings: {
124 'import/resolver': {
125 node: {
126 extensions: [ '.js', '.jsx', '.ts', '.tsx', '.json' ],
127 },
128 },
129 jsdoc: { mode: 'typescript' },
130 },
131 linterOptions: {
132 reportUnusedDisableDirectives: 'off',
133 },
134 rules: {
135 ...noJqueryRules,
136 'no-var': 'off',
137 'wrap-iife': 'off',
138 'computed-property-spacing': [ 'error', 'always' ],
139 'comma-dangle': [ 'error', 'always-multiline' ],
140 'no-undef': 'off',
141 'no-unused-vars': [ 'error', { ignoreRestSiblings: true, caughtErrors: 'none' } ],
142 'dot-notation': 'error',
143 'no-shadow': 'error',
144 'no-lonely-if': 'error',
145 'no-mixed-operators': 'error',
146 'no-nested-ternary': 'error',
147 'no-cond-assign': 'error',
148 indent: [ 1, 'tab', { SwitchCase: 1 } ],
149 'padded-blocks': [ 'error', 'never' ],
150 'one-var-declaration-per-line': 'error',
151 'array-bracket-spacing': [ 'error', 'always' ],
152 'no-else-return': 'error',
153 'no-console': 'error',
154 'arrow-parens': [ 'error', 'always' ],
155 'brace-style': [ 'error', '1tbs' ],
156 'jsx-quotes': 'error',
157 'no-bitwise': [ 'error', { allow: [ '^' ] } ],
158 'no-caller': 'error',
159 'no-debugger': 'error',
160 'no-eval': 'error',
161 'no-restricted-syntax': [
162 'error',
163 {
164 selector:
165 'CallExpression[callee.name=/^__|_n|_x$/]:not([arguments.0.type=/^Literal|BinaryExpression$/])',
166 message: 'Translate function arguments must be string literals.',
167 },
168 {
169 selector:
170 'CallExpression[callee.name=/^_n|_x$/]:not([arguments.1.type=/^Literal|BinaryExpression$/])',
171 message: 'Translate function arguments must be string literals.',
172 },
173 {
174 selector:
175 'CallExpression[callee.name=_nx]:not([arguments.2.type=/^Literal|BinaryExpression$/])',
176 message: 'Translate function arguments must be string literals.',
177 },
178 ],
179 'prefer-const': 'error',
180 yoda: [
181 'error',
182 'always',
183 {
184 onlyEquality: true,
185 },
186 ],
187 'react/react-in-jsx-scope': 'off',
188 'react/prop-types': 'error',
189 'react/no-deprecated': 'error',
190 semi: 'warn',
191 'jsdoc/check-tag-names': [
192 'error',
193 { definedTags: [ 'jest-environment' ] },
194 ],
195 'jsdoc/require-returns-description': 'off',
196 'jsdoc/no-undefined-types': 'off',
197 'import/default': 'error',
198 'import/no-unresolved': [
199 2,
200 {
201 ignore: [
202 'elementor',
203 'modules',
204 '@wordpress/i18n',
205 'e-utils',
206 'e-styles',
207 'react',
208 ],
209 },
210 ],
211 'import/no-extraneous-dependencies': 'off',
212 '@wordpress/i18n-ellipsis': 'off',
213 '@wordpress/i18n-translator-comments': 'off',
214 'capitalized-comments': [
215 'error',
216 'always',
217 {
218 ignorePattern: 'webpackChunkName|webpackIgnore|jQuery',
219 ignoreConsecutiveComments: true,
220 },
221 ],
222 'spaced-comment': [ 'error', 'always', { markers: [ '!' ] } ],
223 'space-in-parens': 'off',
224 'template-curly-spacing': 'off',
225 'quote-props': 'off',
226 'space-unary-ops': 'off',
227 },
228 },
229 {
230 files: [ 'scripts/**/*.mjs' ],
231 languageOptions: {
232 sourceType: 'module',
233 ecmaVersion: 'latest',
234 globals: {
235 ...elementorGlobals,
236 ...require( 'globals' ).node,
237 },
238 },
239 rules: {
240 'no-console': 'off',
241 'jsdoc/require-param': 'off',
242 },
243 },
244 ...tseslint.config(
245 {
246 files: [ '**/*.ts', '**/*.tsx' ],
247 extends: [ ...tseslint.configs.recommended ],
248 languageOptions: {
249 parserOptions: {
250 project: [ './tsconfig.json' ],
251 },
252 },
253 rules: {
254 '@typescript-eslint/await-thenable': 'error',
255 '@typescript-eslint/no-var-requires': 'error',
256 '@typescript-eslint/ban-ts-comment': 'error',
257 'local-rules/no-react-namespace': 'error',
258 '@typescript-eslint/no-unused-vars': [ 'error', { ignoreRestSiblings: true, caughtErrors: 'none' } ],
259 },
260 },
261 ),
262 {
263 files: [ 'tests/**/*.ts', 'tests/**/*.tsx' ],
264 rules: {
265 'local-rules/no-react-namespace': 'off',
266 },
267 },
268 {
269 files: [ 'tests/playwright/parallelTest.ts' ],
270 rules: {
271 'react-hooks/rules-of-hooks': 'off',
272 },
273 },
274 {
275 ...playwright.configs[ 'flat/recommended' ],
276 files: [
277 'tests/playwright/**/*.ts',
278 'tests/elements-regression/**/*.ts',
279 ],
280 rules: {
281 ...playwright.configs[ 'flat/recommended' ].rules,
282 'playwright/no-networkidle': 'warn',
283 'playwright/expect-expect': 'off',
284 'playwright/no-conditional-in-test': 'off',
285 'playwright/no-wait-for-selector': 'off',
286 'playwright/prefer-locator': 'off',
287 'playwright/no-wait-for-timeout': 'off',
288 'playwright/prefer-web-first-assertions': 'off',
289 'playwright/valid-title': 'off',
290 'playwright/prefer-to-have-count': 'off',
291 'playwright/no-unsafe-references': 'off',
292 'playwright/no-nested-step': 'off',
293 'playwright/no-conditional-expect': 'off',
294 'playwright/no-wait-for-navigation': 'off',
295 'playwright/valid-describe-callback': 'off',
296 },
297 },
298 ];
299