Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: eslint config #1779

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
**/dist/*
**/node_modules/*
**/*.min.*
**/*.ts
**/*.tsx
example/**/*
**/dist/
**/node_modules/
example/**/*
**/react-i18next.js
**/react-i18next.min.js
91 changes: 24 additions & 67 deletions .eslintrc.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file are all formatting related exception for the overrides at the bottom.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 }]
}
}
]
}
6 changes: 2 additions & 4 deletions icu.macro.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createMacro } = require('babel-plugin-macros');

Check warning on line 1 in icu.macro.js

View workflow job for this annotation

GitHub Actions / Check code quality (lint and format)

'babel-plugin-macros' should be listed in the project's dependencies, not devDependencies

// copy to:
// https://astexplorer.net/#/gist/642aebbb9e449e959f4ad8907b4adf3a/4a65742e2a3e926eb55eaa3d657d1472b9ac7970
Expand Down Expand Up @@ -320,10 +320,8 @@
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, '')
Expand Down
3 changes: 2 additions & 1 deletion lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -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'],
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 0 additions & 9 deletions test/.eslintrc.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this piece of config into the root .eslintrc.json so it's easier to upgrade to ESLint v9's flat config in the future.

This file was deleted.