diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..b9ab089727 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +# We can probably lint these later but not important at this point +src/vendor +src/vendor_deprecated +# estraverse stumbles on XJSSpreadAttribute so just ignore tests for now +src/**/__tests__/** +# This should be enabled but that folder has too much in it that doesn't belong +src/test diff --git a/package.json b/package.json index f8a4bcfbf8..2e281ec314 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "envify": "^3.0.0", "es3ify": "~0.1.2", "es5-shim": "^4.0.0", + "eslint": "0.11.0-alpha.0", "grunt": "~0.4.2", "grunt-cli": "~0.1.9", "grunt-compare-size": "~0.4.0", @@ -70,7 +71,8 @@ }, "scripts": { "test": "jest", - "jest": "jest" + "jest": "jest", + "lint": "eslint src" }, "jest": { "rootDir": "", diff --git a/src/.eslintrc b/src/.eslintrc new file mode 100644 index 0000000000..c9b9b50bc4 --- /dev/null +++ b/src/.eslintrc @@ -0,0 +1,52 @@ +--- +settings: + jsx: true + ecmascript: 6 + +env: + browser: true + node: true + +globals: + __DEV__: true + +rules: + # ERRORS + brace-style: 2 + space-after-keywords: 2 + strict: 2 + # We actually have a transform to support this and we fix this for bundled + # releases but not for the npm package, so enforce it strictly + no-comma-dangle: 2 + # Make this a warning for now. We do this in a few places so we might need to + # disable + no-unused-expressions: 2 + block-scoped-var: 2 + eol-last: 2 + dot-notation: 2 + consistent-return: 2 + + # WARNINGS + quotes: [1, 'single'] + # This is the only one that's hard to track since we don't lint just changes. + max-len: [1, 80] + + # WISHLIST. One day... + # We'll need a custom version of this that does a subset of the whole rule. + # Otherwise this is just too noisy. + # valid-jsdoc: 1 + + # DISABLED. These aren't compatible with our style + # We use this for private/internal variables + no-underscore-dangle: 0 + # We pass constructors around / access them from members + new-cap: 0 + # We do this a lot. + no-use-before-define: 0 + # We should have this enabled but https://github.com/eslint/eslint/issues/1542 + no-unused-vars: 0 + # We do this in a few places to align values + key-spacing: 0 + + # DISABLED. These currently cause errors when running. + no-multi-spaces: 0