From c155ae09e02d42d67373b2c7cae7ee6cf7a05fa2 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 2 Apr 2020 13:41:17 +0300 Subject: [PATCH] Move custom ESLint rules into internal package (#2498) Based on https://github.com/facebook/react/commit/30cce21ae6c4e960ea629908fc8c307e41e2bae8#diff-a7adbbe27ccec89b583ac77c28b521ac --- .eslintrc.yml | 8 ++++++++ package.json | 3 ++- resources/eslint-rules/README.md | 6 ++++++ resources/eslint-rules/index.js | 9 +++++++++ resources/eslint-rules/package.json | 4 ++++ yarn.lock | 4 ++++ 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 resources/eslint-rules/README.md create mode 100644 resources/eslint-rules/index.js create mode 100644 resources/eslint-rules/package.json diff --git a/.eslintrc.yml b/.eslintrc.yml index f5a7646727..6a996d30b3 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -6,10 +6,18 @@ env: node: true reportUnusedDisableDirectives: true plugins: + - graphql-internal - flowtype - import rules: + ############################################################################## + # Internal rules located in 'resources/eslint-rules'. + # See './resources/eslint-rules/README.md' + ############################################################################## + + graphql-internal/no-dir-import: error + ############################################################################## # `eslint-plugin-flowtype` rule list based on `v4.6.x` # https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype diff --git a/package.json b/package.json index 8618d5c1ac..621e7fb8b9 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "test:ci": "yarn check --integrity && npm run prettier:check && npm run lint -- --no-cache && npm run check && npm run testonly:cover && npm run check:ts && npm run check:spelling && npm run build", "testonly": "mocha --full-trace src/**/__tests__/**/*-test.js", "testonly:cover": "nyc npm run testonly", - "lint": "eslint --rulesdir './resources/eslint-rules' --rule 'no-dir-import: error' --cache --ext .js,.ts src resources", + "lint": "eslint --cache --ext .js,.ts src resources", "benchmark": "node --noconcurrent_sweeping --expose-gc --predictable ./resources/benchmark.js", "prettier": "prettier --ignore-path .gitignore --write --list-different \"**/*.{js,ts,md,json,yml}\"", "prettier:check": "prettier --ignore-path .gitignore --check \"**/*.{js,ts,md,json,yml}\"", @@ -56,6 +56,7 @@ "dtslint": "3.3.0", "eslint": "6.8.0", "eslint-plugin-flowtype": "4.6.0", + "eslint-plugin-graphql-internal": "link:./resources/eslint-rules", "eslint-plugin-import": "2.20.1", "flow-bin": "0.120.1", "mocha": "7.1.0", diff --git a/resources/eslint-rules/README.md b/resources/eslint-rules/README.md new file mode 100644 index 0000000000..fd8a496025 --- /dev/null +++ b/resources/eslint-rules/README.md @@ -0,0 +1,6 @@ +# Custom ESLint Rules + +This is a dummy npm package that allows us to treat it as an `eslint-plugin-graphql-internal`. +It's not actually published, nor are the rules here useful for users of graphql. + +**If you modify this rule, you must re-run `yarn` for it to take effect.** diff --git a/resources/eslint-rules/index.js b/resources/eslint-rules/index.js new file mode 100644 index 0000000000..b8370f5772 --- /dev/null +++ b/resources/eslint-rules/index.js @@ -0,0 +1,9 @@ +// @noflow + +'use strict'; + +module.exports = { + rules: { + 'no-dir-import': require('./no-dir-import'), + }, +}; diff --git a/resources/eslint-rules/package.json b/resources/eslint-rules/package.json new file mode 100644 index 0000000000..60cbef8ee9 --- /dev/null +++ b/resources/eslint-rules/package.json @@ -0,0 +1,4 @@ +{ + "name": "eslint-plugin-graphql-internal", + "version": "0.0.0" +} diff --git a/yarn.lock b/yarn.lock index 0ff2053d3c..c00410aa64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1728,6 +1728,10 @@ eslint-plugin-flowtype@4.6.0: dependencies: lodash "^4.17.15" +"eslint-plugin-graphql-internal@link:./resources/eslint-rules": + version "0.0.0" + uid "" + eslint-plugin-import@2.20.1: version "2.20.1" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.20.1.tgz#802423196dcb11d9ce8435a5fc02a6d3b46939b3"