Skip to content

Commit ed956ac

Browse files
authored
fix: eslint config (#1779)
* style: update eslint config * style: run eslint * chore: centralise eslint config
1 parent 4d9bc0b commit ed956ac

6 files changed

+35
-88
lines changed

.eslintignore

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
**/dist/*
2-
**/node_modules/*
3-
**/*.min.*
4-
**/*.ts
5-
**/*.tsx
6-
example/**/*
1+
**/dist/
2+
**/node_modules/
3+
example/**/*
4+
**/react-i18next.js
5+
**/react-i18next.min.js

.eslintrc.json

+24-67
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,12 @@
1616
"rules": {
1717
"no-debugger": 0,
1818
"no-alert": 0,
19-
"no-unused-vars": [
20-
1,
21-
{
22-
"argsIgnorePattern": "res|next|^err"
23-
}
24-
],
25-
"prefer-arrow-callback": [
26-
"error",
27-
{
28-
"allowNamedFunctions": true
29-
}
30-
],
31-
"prefer-const": [
32-
"error",
33-
{
34-
"destructuring": "all"
35-
}
36-
],
19+
"no-unused-vars": [1, { "argsIgnorePattern": "res|next|^err" }],
20+
"prefer-arrow-callback": ["error", { "allowNamedFunctions": true }],
21+
"prefer-const": ["error", { "destructuring": "all" }],
3722
"arrow-body-style": [2, "as-needed"],
38-
"no-unused-expressions": [
39-
2,
40-
{
41-
"allowTaggedTemplates": true
42-
}
43-
],
44-
"no-param-reassign": [
45-
2,
46-
{
47-
"props": false
48-
}
49-
],
23+
"no-unused-expressions": [2, { "allowTaggedTemplates": true }],
24+
"no-param-reassign": [2, { "props": false }],
5025
"no-console": 0,
5126
"no-use-before-define": 0,
5227
"no-nested-ternary": 0,
@@ -63,53 +38,35 @@
6338
"consistent-return": 0,
6439
"react/display-name": 1,
6540
"react/no-array-index-key": 0,
66-
"react/jsx-no-useless-fragment": [
67-
"error",
68-
{
69-
"allowExpressions": true
70-
}
71-
],
41+
"react/jsx-no-useless-fragment": ["error", { "allowExpressions": true }],
7242
"react/react-in-jsx-scope": 0,
7343
"react/prefer-stateless-function": 0,
7444
"react/forbid-prop-types": 0,
7545
"react/no-unescaped-entities": 0,
7646
"react/prop-types": 0,
7747
"jsx-a11y/accessible-emoji": 0,
78-
"react/jsx-filename-extension": [
79-
1,
80-
{
81-
"extensions": [".js", ".jsx"]
82-
}
83-
],
84-
"react/no-unknown-property": [
85-
"error",
86-
{
87-
"ignore": ["i18nIsDynamicList"]
88-
}
89-
],
48+
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
49+
"react/no-unknown-property": ["error", { "ignore": ["i18nIsDynamicList"] }],
9050
"radix": 0,
9151
"no-shadow": [
9252
2,
93-
{
94-
"hoist": "all",
95-
"allow": ["resolve", "reject", "done", "next", "err", "error"]
96-
}
97-
],
98-
"quotes": [
99-
2,
100-
"single",
101-
{
102-
"avoidEscape": true,
103-
"allowTemplateLiterals": true
104-
}
53+
{ "hoist": "all", "allow": ["resolve", "reject", "done", "next", "err", "error"] }
10554
],
55+
"quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
10656
"jsx-a11y/href-no-hash": "off",
107-
"jsx-a11y/anchor-is-valid": [
108-
"warn",
109-
{
110-
"aspects": ["invalidHref"]
111-
}
112-
],
57+
"jsx-a11y/anchor-is-valid": ["warn", { "aspects": ["invalidHref"] }],
11358
"react/jsx-props-no-spreading": 0
114-
}
59+
},
60+
"overrides": [
61+
{
62+
"files": ["test/*"],
63+
"extends": ["plugin:testing-library/react", "plugin:jest-dom/recommended"],
64+
"globals": {
65+
"globalThis": false
66+
},
67+
"rules": {
68+
"testing-library/no-node-access": ["error", { "allowContainerFirstChild": true }]
69+
}
70+
}
71+
]
11572
}

icu.macro.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,8 @@ function processTrans(children, babel, componentStartIndex = 0) {
320320
return res;
321321
}
322322

323-
// eslint-disable-next-line no-control-regex
324-
const leadingNewLineAndWhitespace = new RegExp('^\n\\s+', 'g');
325-
// eslint-disable-next-line no-control-regex
326-
const trailingNewLineAndWhitespace = new RegExp('\n\\s+$', 'g');
323+
const leadingNewLineAndWhitespace = /^\n\s+/g;
324+
const trailingNewLineAndWhitespace = /\n\s+$/g;
327325
function trimIndent(text) {
328326
const newText = text
329327
.replace(leadingNewLineAndWhitespace, '')

lint-staged.config.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export default {
2-
'*': ['prettier --write --ignore-unknown'],
2+
'!*.?(c|m){js,ts}?(x)': ['prettier --write '],
3+
'*.?(c|m){js,ts}?(x)': ['prettier --write --ignore-unknown', 'eslint --cache --fix --env-info'],
34
};

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@
133133
},
134134
"scripts": {
135135
"clean": "rimraf dist && mkdirp dist",
136-
"lint": "eslint ./src ./test",
136+
"lint": "eslint --cache .",
137+
"lint:fix": "eslint --cache --fix .",
137138
"format": "prettier . --check",
138139
"format:fix": "prettier . --write --list-different",
139140
"copy": "cpy ./dist/umd/react-i18next.min.js ./dist/umd/react-i18next.js . --flat && echo '{\"type\":\"module\"}' > dist/es/package.json",

test/.eslintrc.json

-9
This file was deleted.

0 commit comments

Comments
 (0)