Skip to content

Commit

Permalink
Load custom eslint rules as plugin, w/o --rulesdir
Browse files Browse the repository at this point in the history
This allows us to load the eslint rules without requiring command-line
arguments, which avoids breaking editors with eslint plugins.

eslint/eslint#2180 (comment)
  • Loading branch information
bgw committed Jun 5, 2015
1 parent 58302a7 commit 30cce21
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parser: babel-eslint

plugins:
- react
- react-internal

env:
browser: true
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions eslint-rules/README.md
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/yannickcr/eslint-plugin-react>.

**If you modify this rule, you must re-run `npm install ./eslint-rules` for it to take effect.**
7 changes: 7 additions & 0 deletions eslint-rules/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
rules: {
'warning-and-invariant-args': require('./warning-and-invariant-args'),
},
};
4 changes: 4 additions & 0 deletions eslint-rules/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "eslint-plugin-react-internal",
"version": "0.0.0"
}
2 changes: 1 addition & 1 deletion grunt/tasks/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 30cce21

Please sign in to comment.