Skip to content

Commit

Permalink
🎨 Add custom plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dbenfouzari committed Aug 23, 2020
1 parent 11fd84b commit e75b47b
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
example/
.babelrc
tests/
renovate.json5
src/
.github
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Benefits are multiple : it will avoid many conflits caused by a committer that i

I personnaly enable it on every project I work on, and I can't do without it.

### `eslint-plugin-i18next`
### `@dbenfouzari/eslint-plugin-react-native`

It's `off` by default.
You can enable it by doing
Expand All @@ -79,7 +79,7 @@ You can enable it by doing
{
"extends": ["@dbenfouzari/react-native"],
"rules": {
"i18next/no-literal-string": ["error"]
"@dbenfouzari/react-native/no-child-string": ["error"]
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"devDependencies": {
"@dbenfouzari/eslint-config-react-native": "file:..",
"@dbenfouzari/eslint-config-react-native": "../",
"eslint": "7.7.0",
"typescript": "3.9.7",
"prettier": "2.0.5"
"prettier": "2.0.5",
"typescript": "3.9.7"
}
}
25 changes: 11 additions & 14 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,17 @@
lodash "^4.17.19"
to-fast-properties "^2.0.0"

"@dbenfouzari/eslint-config-react-native@file:..":
version "1.0.5"
"@dbenfouzari/eslint-config-react-native@../":
version "1.1.0"
dependencies:
"@dbenfouzari/eslint-plugin-react-native" "1.0.0"
"@react-native-community/eslint-config" "2.0.0"
eslint-plugin-import "2.22.0"

"@dbenfouzari/[email protected]":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@dbenfouzari/eslint-plugin-react-native/-/eslint-plugin-react-native-1.0.0.tgz#587af386bbd62eb324408227df027f5fa6d5ea90"
integrity sha512-bxt5fygrLdqhrlDNIUwzKTW2RL7Tafa3QlNgZaeNO3W6N3IKHxww74SYR/Mmz6UUySnGgU2+3Na/bQbfzqmcew==

"@react-native-community/[email protected]":
version "2.0.0"
Expand Down Expand Up @@ -514,13 +523,6 @@ [email protected]:
dependencies:
lodash "^4.17.10"

eslint-plugin-i18next@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-i18next/-/eslint-plugin-i18next-4.5.0.tgz#fd22baf05427c8a7c622b027e4e54fc4b23fbcd2"
integrity sha512-HDl5ydddzv9t7d9b5TAHp+XGukpKIqMMTv+/x9uvyqVGHDoJRt1JqDPCQRXFWc9F9JlpvJXydkoD2OyI/w2MHQ==
dependencies:
requireindex "~1.1.0"

[email protected]:
version "2.22.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.22.0.tgz#92f7736fe1fde3e2de77623c838dd992ff5ffb7e"
Expand Down Expand Up @@ -1270,11 +1272,6 @@ regexpp@^3.0.0, regexpp@^3.1.0:
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2"
integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==

requireindex@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162"
integrity sha1-5UBLgVV+91225JxacgBIk/4D4WI=

resolve-from@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dbenfouzari/eslint-config-react-native",
"version": "1.1.0",
"version": "1.1.1",
"description": "React-Native ESLint config",
"main": "lib/index.js",
"repository": {
Expand All @@ -23,8 +23,8 @@
"typescript": ">= 3"
},
"dependencies": {
"@dbenfouzari/eslint-plugin-react-native": "1.0.0",
"@react-native-community/eslint-config": "2.0.0",
"eslint-plugin-i18next": "^4.5.0",
"eslint-plugin-import": "2.22.0"
},
"devDependencies": {
Expand All @@ -33,7 +33,6 @@
"@babel/preset-env": "7.11.0",
"@react-native-community/eslint-config": "2.0.0",
"eslint": "7.7.0",
"eslint-plugin-i18next": "4.5.0",
"eslint-plugin-import": "2.22.0",
"jest": "26.4.1",
"react": "16.13.1",
Expand Down
6 changes: 4 additions & 2 deletions src/configs/i18next.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
plugins: ["i18next"],
extends: ["plugin:i18next/recommended"],
plugins: ["@dbenfouzari/react-native"],
rules: {
"@dbenfouzari/react-native/no-child-string": ["error"],
},
};
3 changes: 0 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ module.exports = {
extends: ["./configs/default", "./configs/i18next", "./configs/import"].map(
require.resolve
),
rules: {
"i18next/no-literal-string": 'off'
}
};
2 changes: 1 addition & 1 deletion tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("Normal config", () => {
{
filePath: path.resolve(invalidTs),
messages: expect.any(Array),
errorCount: 9,
errorCount: 10,
warningCount: 3,
fixableErrorCount: 5,
fixableWarningCount: 3,
Expand Down
17 changes: 5 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,11 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@dbenfouzari/[email protected]":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@dbenfouzari/eslint-plugin-react-native/-/eslint-plugin-react-native-1.0.0.tgz#587af386bbd62eb324408227df027f5fa6d5ea90"
integrity sha512-bxt5fygrLdqhrlDNIUwzKTW2RL7Tafa3QlNgZaeNO3W6N3IKHxww74SYR/Mmz6UUySnGgU2+3Na/bQbfzqmcew==

"@istanbuljs/load-nyc-config@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
Expand Down Expand Up @@ -2159,13 +2164,6 @@ [email protected]:
dependencies:
lodash "^4.17.10"

eslint-plugin-i18next@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-i18next/-/eslint-plugin-i18next-4.5.0.tgz#fd22baf05427c8a7c622b027e4e54fc4b23fbcd2"
integrity sha512-HDl5ydddzv9t7d9b5TAHp+XGukpKIqMMTv+/x9uvyqVGHDoJRt1JqDPCQRXFWc9F9JlpvJXydkoD2OyI/w2MHQ==
dependencies:
requireindex "~1.1.0"

[email protected]:
version "2.22.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.22.0.tgz#92f7736fe1fde3e2de77623c838dd992ff5ffb7e"
Expand Down Expand Up @@ -4512,11 +4510,6 @@ require-main-filename@^2.0.0:
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==

requireindex@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162"
integrity sha1-5UBLgVV+91225JxacgBIk/4D4WI=

resolve-cwd@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d"
Expand Down

0 comments on commit e75b47b

Please sign in to comment.