diff --git a/.eslintignore b/.eslintignore index ed39856f2..22e295c24 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,5 @@ -**/dist/* -**/node_modules/* -**/*.min.* -**/*.ts -**/*.tsx -example/**/* \ No newline at end of file +**/dist/ +**/node_modules/ +example/**/* +**/react-i18next.js +**/react-i18next.min.js diff --git a/.eslintrc.json b/.eslintrc.json index 6ca5d97aa..9291598cb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,37 +16,12 @@ "rules": { "no-debugger": 0, "no-alert": 0, - "no-unused-vars": [ - 1, - { - "argsIgnorePattern": "res|next|^err" - } - ], - "prefer-arrow-callback": [ - "error", - { - "allowNamedFunctions": true - } - ], - "prefer-const": [ - "error", - { - "destructuring": "all" - } - ], + "no-unused-vars": [1, { "argsIgnorePattern": "res|next|^err" }], + "prefer-arrow-callback": ["error", { "allowNamedFunctions": true }], + "prefer-const": ["error", { "destructuring": "all" }], "arrow-body-style": [2, "as-needed"], - "no-unused-expressions": [ - 2, - { - "allowTaggedTemplates": true - } - ], - "no-param-reassign": [ - 2, - { - "props": false - } - ], + "no-unused-expressions": [2, { "allowTaggedTemplates": true }], + "no-param-reassign": [2, { "props": false }], "no-console": 0, "no-use-before-define": 0, "no-nested-ternary": 0, @@ -63,53 +38,35 @@ "consistent-return": 0, "react/display-name": 1, "react/no-array-index-key": 0, - "react/jsx-no-useless-fragment": [ - "error", - { - "allowExpressions": true - } - ], + "react/jsx-no-useless-fragment": ["error", { "allowExpressions": true }], "react/react-in-jsx-scope": 0, "react/prefer-stateless-function": 0, "react/forbid-prop-types": 0, "react/no-unescaped-entities": 0, "react/prop-types": 0, "jsx-a11y/accessible-emoji": 0, - "react/jsx-filename-extension": [ - 1, - { - "extensions": [".js", ".jsx"] - } - ], - "react/no-unknown-property": [ - "error", - { - "ignore": ["i18nIsDynamicList"] - } - ], + "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], + "react/no-unknown-property": ["error", { "ignore": ["i18nIsDynamicList"] }], "radix": 0, "no-shadow": [ 2, - { - "hoist": "all", - "allow": ["resolve", "reject", "done", "next", "err", "error"] - } - ], - "quotes": [ - 2, - "single", - { - "avoidEscape": true, - "allowTemplateLiterals": true - } + { "hoist": "all", "allow": ["resolve", "reject", "done", "next", "err", "error"] } ], + "quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }], "jsx-a11y/href-no-hash": "off", - "jsx-a11y/anchor-is-valid": [ - "warn", - { - "aspects": ["invalidHref"] - } - ], + "jsx-a11y/anchor-is-valid": ["warn", { "aspects": ["invalidHref"] }], "react/jsx-props-no-spreading": 0 - } + }, + "overrides": [ + { + "files": ["test/*"], + "extends": ["plugin:testing-library/react", "plugin:jest-dom/recommended"], + "globals": { + "globalThis": false + }, + "rules": { + "testing-library/no-node-access": ["error", { "allowContainerFirstChild": true }] + } + } + ] } diff --git a/icu.macro.js b/icu.macro.js index c16dfac23..9835e34ff 100644 --- a/icu.macro.js +++ b/icu.macro.js @@ -320,10 +320,8 @@ function processTrans(children, babel, componentStartIndex = 0) { return res; } -// eslint-disable-next-line no-control-regex -const leadingNewLineAndWhitespace = new RegExp('^\n\\s+', 'g'); -// eslint-disable-next-line no-control-regex -const trailingNewLineAndWhitespace = new RegExp('\n\\s+$', 'g'); +const leadingNewLineAndWhitespace = /^\n\s+/g; +const trailingNewLineAndWhitespace = /\n\s+$/g; function trimIndent(text) { const newText = text .replace(leadingNewLineAndWhitespace, '') diff --git a/lint-staged.config.mjs b/lint-staged.config.mjs index ff0f7eb0d..c427777fb 100644 --- a/lint-staged.config.mjs +++ b/lint-staged.config.mjs @@ -1,3 +1,4 @@ export default { - '*': ['prettier --write --ignore-unknown'], + '!*.?(c|m){js,ts}?(x)': ['prettier --write '], + '*.?(c|m){js,ts}?(x)': ['prettier --write --ignore-unknown', 'eslint --cache --fix --env-info'], }; diff --git a/package.json b/package.json index 3146434a9..ece86599a 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,8 @@ }, "scripts": { "clean": "rimraf dist && mkdirp dist", - "lint": "eslint ./src ./test", + "lint": "eslint --cache .", + "lint:fix": "eslint --cache --fix .", "format": "prettier . --check", "format:fix": "prettier . --write --list-different", "copy": "cpy ./dist/umd/react-i18next.min.js ./dist/umd/react-i18next.js . --flat && echo '{\"type\":\"module\"}' > dist/es/package.json", diff --git a/test/.eslintrc.json b/test/.eslintrc.json deleted file mode 100644 index 4a6cfa3ce..000000000 --- a/test/.eslintrc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": ["plugin:testing-library/react", "plugin:jest-dom/recommended"], - "globals": { - "globalThis": false - }, - "rules": { - "testing-library/no-node-access": ["error", { "allowContainerFirstChild": true }] - } -}