From 30cce21ae6c4e960ea629908fc8c307e41e2bae8 Mon Sep 17 00:00:00 2001 From: Benjamin Woodruff Date: Thu, 4 Jun 2015 17:04:45 -0700 Subject: [PATCH] Load custom eslint rules as plugin, w/o --rulesdir This allows us to load the eslint rules without requiring command-line arguments, which avoids breaking editors with eslint plugins. https://github.com/eslint/eslint/issues/2180#issuecomment-87722150 --- .eslintrc | 3 ++- eslint-rules/README.md | 5 +++++ eslint-rules/index.js | 7 +++++++ eslint-rules/package.json | 4 ++++ grunt/tasks/eslint.js | 2 +- package.json | 1 + 6 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 eslint-rules/README.md create mode 100644 eslint-rules/index.js create mode 100644 eslint-rules/package.json diff --git a/.eslintrc b/.eslintrc index 1994a45550899..de1cba208d118 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,6 +3,7 @@ parser: babel-eslint plugins: - react + - react-internal env: browser: true @@ -97,4 +98,4 @@ rules: # CUSTOM RULES # the second argument of warning/invariant should be a literal string - warning-and-invariant-args: 2 + react-internal/warning-and-invariant-args: 2 diff --git a/eslint-rules/README.md b/eslint-rules/README.md new file mode 100644 index 0000000000000..9d081e69e72f2 --- /dev/null +++ b/eslint-rules/README.md @@ -0,0 +1,5 @@ +# Custom ESLint Rules + +This is a dummy npm package that allows us to treat it as an eslint-plugin. It's not actually published, nor are the rules here useful for users of react. If you want to lint your react code, try . + +**If you modify this rule, you must re-run `npm install ./eslint-rules` for it to take effect.** diff --git a/eslint-rules/index.js b/eslint-rules/index.js new file mode 100644 index 0000000000000..5efee2d47caf2 --- /dev/null +++ b/eslint-rules/index.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = { + rules: { + 'warning-and-invariant-args': require('./warning-and-invariant-args'), + }, +}; diff --git a/eslint-rules/package.json b/eslint-rules/package.json new file mode 100644 index 0000000000000..6424cce415ee3 --- /dev/null +++ b/eslint-rules/package.json @@ -0,0 +1,4 @@ +{ + "name": "eslint-plugin-react-internal", + "version": "0.0.0" +} diff --git a/grunt/tasks/eslint.js b/grunt/tasks/eslint.js index 67784713bf403..061300dcd3ef2 100644 --- a/grunt/tasks/eslint.js +++ b/grunt/tasks/eslint.js @@ -6,7 +6,7 @@ module.exports = function() { var done = this.async(); grunt.util.spawn({ cmd: 'node_modules/.bin/eslint', - args: ['.', '--rulesdir=eslint-rules'], + args: ['.'], opts: {stdio: 'inherit'}, // allows colors to passthrough }, function(err, result, code) { if (err) { diff --git a/package.json b/package.json index 4164b37b79462..48b92ff8427c1 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "es5-shim": "^4.0.0", "eslint": "^0.21.2", "eslint-plugin-react": "^2.5.0", + "eslint-plugin-react-internal": "file:eslint-rules", "eslint-tester": "^0.7.0", "grunt": "~0.4.2", "grunt-cli": "^0.1.13",