From 45c28fa78573808e3891a13f7a6fff9bf33676d9 Mon Sep 17 00:00:00 2001 From: Frederic Germain Date: Sun, 8 Jul 2018 17:32:08 +0200 Subject: [PATCH] Use eslint-local-rules plugin This allows to avoid having errors in editors that supports eslint cf https://github.com/eslint/eslint/issues/8769 --- .eslintrc.json | 6 +++--- Makefile | 4 ++-- eslint-local-rules.js | 9 +++++++++ package.json | 3 ++- yarn.lock | 4 ++++ 5 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 eslint-local-rules.js diff --git a/.eslintrc.json b/.eslintrc.json index feeff75a73..e1ccbfc363 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { "root": true, "extends": "babel", - "plugins": ["prettier"], + "plugins": ["local-rules", "prettier"], "rules": { "curly": ["error", "multi-line"], "prettier/prettier": "error", @@ -14,8 +14,8 @@ { "files": ["packages/*/src/**/*.js", "codemods/*/src/**/*.js"], "rules": { - "no-undefined-identifier": "error", - "no-deprecated-clone": "error" + "local-rules/no-undefined-identifier": "error", + "local-rules/no-deprecated-clone": "error" } }, { diff --git a/Makefile b/Makefile index 1ebbbf7068..9e5dd536d5 100644 --- a/Makefile +++ b/Makefile @@ -47,10 +47,10 @@ flow: ./node_modules/.bin/flow check --strip-root lint: - ./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --rulesdir="./scripts/eslint_rules" + ./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe fix: - ./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix --rulesdir="./scripts/eslint_rules" + ./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix clean: test-clean rm -rf packages/babel-polyfill/browser* diff --git a/eslint-local-rules.js b/eslint-local-rules.js new file mode 100644 index 0000000000..73af83e484 --- /dev/null +++ b/eslint-local-rules.js @@ -0,0 +1,9 @@ +"use strict"; + +const noDeprecatedClone = require("./scripts/eslint_rules/no-deprecated-clone"); +const noUndefinedIdentifier = require("./scripts/eslint_rules/no-undefined-identifier"); + +module.exports = { + "no-deprecated-clone": noDeprecatedClone, + "no-undefined-identifier": noUndefinedIdentifier, +}; diff --git a/package.json b/package.json index c15bd94a5f..bf911bbbea 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "eslint": "^5.3.0", "eslint-config-babel": "^7.0.2", "eslint-plugin-flowtype": "^2.50.0", + "eslint-plugin-local-rules": "0.1.0", "eslint-plugin-prettier": "^2.6.2", "flow-bin": "^0.80.0", "graceful-fs": "^4.1.11", @@ -77,7 +78,7 @@ }, "lint-staged": { "*.js": [ - "eslint --format=codeframe --rulesdir='./scripts/eslint_rules'" + "eslint --format=codeframe" ] }, "jest": { diff --git a/yarn.lock b/yarn.lock index e0c6706a87..19329132bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3077,6 +3077,10 @@ eslint-plugin-flowtype@^2.50.0: dependencies: lodash "^4.17.10" +eslint-plugin-local-rules@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-local-rules/-/eslint-plugin-local-rules-0.1.0.tgz#6808bb4c1b9a432f6e54ff4dfb290073e1cdf700" + eslint-plugin-prettier@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.2.tgz#71998c60aedfa2141f7bfcbf9d1c459bf98b4fad"