From a7e8108825cadbe8a8ca5740c27fea204a6cd2cb Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Tue, 8 Sep 2015 18:57:48 -0700 Subject: [PATCH] add eslint rules from fbjs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: As @​zpao suggested (reference #58) here is the new PR with the rules from [facebook/fbjs#49](https://github.com/facebook/fbjs/pull/49). I'll still need some guidance on what should be Relay specific. At the moment with the current fbjs rules there is a lot of errors on [no-undef](http://eslint.org/docs/rules/no-undef.html) (example: $FlowIssue, $FixMe, $Enum and also when defining Flow types, this is related to [babel-eslint/known-issues](https://github.com/babel/babel-eslint#known-issues) - [babel-eslint#130](https://github.com/babel/babel-eslint/issues/130) and [babel-eslint#132](https://github.com/babel/babel-eslint/issues/132)) @​josephsavona @​zpao what are your thoughts? Closes https://github.com/facebook/relay/pull/202 Reviewed By: @josephsavona Differential Revision: D2417828 --- .eslintignore | 9 +++++++++ .eslintrc | 18 ++++++++++++++++++ package.json | 6 +++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .eslintignore create mode 100644 .eslintrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000000..7fbc22107e7d2 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,9 @@ +dist/ +docs/ +examples/ +node_modules/ +lib/ +scripts/ +# TODO: Enable ESLint for website. +website/ +*.md diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000000000..589dcb6a5d59b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,18 @@ +--- +parser: babel-eslint + +extends: + - ./node_modules/fbjs-scripts/eslint/.eslintrc + +plugins: + - react + +globals: + $Enum: true + $FixMe: true + $FlowFixMe: true + $FlowIssue: true + Iterator: true + IteratorResult: true + ReactClass: true + ReactElement: true diff --git a/package.json b/package.json index a06b05a02e07b..c70eb1f45c9a7 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "prepublish": "npm run build", "test": "f() { EXIT=0; npm run typecheck || EXIT=$?; NODE_ENV=test jest $@ || EXIT=$?; exit $EXIT; }; f", "typecheck": "flow check src/", - "update-schema": "babel-node ./scripts/jest/updateSchema.js" + "update-schema": "babel-node ./scripts/jest/updateSchema.js", + "lint": "eslint ." }, "dependencies": { "babel-runtime": "5.8.20", @@ -36,10 +37,13 @@ }, "devDependencies": { "babel-core": "^5.8.23", + "babel-eslint": "^4.1.1", "babel-loader": "^5.3.2", "babel-relay-plugin": "^0.2.1", "del": "^1.2.0", "envify": "^3.4.0", + "eslint": "^1.3.1", + "eslint-plugin-react": "^3.3.1", "fbjs-scripts": "^0.2.0", "flow-bin": "0.14.0", "graphql": "^0.4.2",