Skip to content

Commit 25b7686

Browse files
committed
Feature #59940: Add ESLint config
1 parent 246253b commit 25b7686

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

assets/js/postcode-eu-autofill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global wp, PostcodeNl, PostcodeEuSettings, PostcodeNlAddressFieldMapping, PostcodeNlStateToValueMapping */
1+
/* global PostcodeEuSettings, PostcodeNlAddressFieldMapping, PostcodeNlStateToValueMapping */
22
(function () {
33
'use strict';
44

eslint.config.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import globals from 'globals';
2+
import pluginJs from '@eslint/js';
3+
import pluginReact from 'eslint-plugin-react';
4+
import reactHooks from 'eslint-plugin-react-hooks';
5+
6+
7+
/** @type {import('eslint').Linter.Config[]} */
8+
export default [
9+
{
10+
files: ['**/*.{js,mjs,cjs,jsx}'],
11+
},
12+
{
13+
languageOptions: {
14+
globals: {
15+
...globals.browser,
16+
jQuery: 'readonly',
17+
wp: 'readonly',
18+
wcSettings: 'readonly',
19+
PostcodeNl: 'readonly',
20+
},
21+
},
22+
},
23+
pluginJs.configs.recommended,
24+
pluginReact.configs.flat.recommended,
25+
reactHooks.configs['recommended-latest'],
26+
{
27+
rules: {
28+
'no-unused-vars': 'warn',
29+
'no-extra-semi': 'warn',
30+
'react/prop-types': 'off',
31+
'react/react-in-jsx-scope': 'off',
32+
'react-hooks/exhaustive-deps': [
33+
'warn',
34+
{
35+
additionalHooks: '^(useSelect|useSuspenseSelect)$',
36+
},
37+
],
38+
},
39+
},
40+
];

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
"start": "wp-scripts start"
1313
},
1414
"devDependencies": {
15+
"@eslint/js": "^9.22.0",
1516
"@woocommerce/dependency-extraction-webpack-plugin": "^3.0.1",
1617
"@wordpress/scripts": "^27.9.0",
18+
"eslint": "^8.57.1",
19+
"eslint-plugin-react": "^7.37.4",
20+
"eslint-plugin-react-hooks": "^5.2.0",
21+
"globals": "^16.0.0",
1722
"webpack-livereload-plugin": "^3.0.2"
1823
},
1924
"dependencies": {

0 commit comments

Comments
 (0)