eslint-config-airbnb
Advanced tools
Comparing version 0.0.9 to 0.1.0
20
index.js
@@ -1,13 +0,7 @@ | ||
const reactRules = require('./react'); | ||
const base = require('./base'); | ||
// clone this so we aren't mutating a module | ||
const eslintrc = JSON.parse(JSON.stringify(base)); | ||
// manually merge in React rules | ||
eslintrc.plugins = reactRules.plugins; | ||
Object.keys(reactRules.rules).forEach(function assignRule(ruleId) { | ||
eslintrc.rules[ruleId] = reactRules.rules[ruleId]; | ||
}); | ||
module.exports = eslintrc; | ||
module.exports = { | ||
'extends': [ | ||
'eslint-config-airbnb/base', | ||
'eslint-config-airbnb/rules/react', | ||
], | ||
rules: {} | ||
}; |
{ | ||
"name": "eslint-config-airbnb", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"description": "Airbnb's ESLint config, following our styleguide", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "./node_modules/.bin/eslint .", | ||
"test": "./node_modules/.bin/babel-tape-runner ./test/test-*.js" | ||
"lint": "eslint .", | ||
"test": "babel-tape-runner ./test/test-*.js" | ||
}, | ||
@@ -29,6 +29,6 @@ "repository": { | ||
"devDependencies": { | ||
"babel-eslint": "4.0.10", | ||
"babel-eslint": "4.1.3", | ||
"babel-tape-runner": "1.2.0", | ||
"eslint": "1.1.0", | ||
"eslint-plugin-react": "3.2.3", | ||
"eslint": "1.5.1", | ||
"eslint-plugin-react": "3.4.2", | ||
"react": "0.13.3", | ||
@@ -35,0 +35,0 @@ "tape": "4.2.0" |
@@ -7,12 +7,26 @@ # eslint-config-airbnb | ||
### With React Style | ||
We export three ESLint configurations for your usage. | ||
1. `npm install --save-dev eslint-config-airbnb babel-eslint eslint-plugin-react` | ||
### eslint-config-airbnb | ||
Our default export contains all of our ESLint rules, including EcmaScript 6+ | ||
and React. It requires `eslint`, `babel-eslint`, and `eslint-plugin-react`. | ||
1. `npm install --save-dev eslint-config-airbnb babel-eslint eslint-plugin-react eslint` | ||
2. add `"extends": "airbnb"` to your .eslintrc | ||
### Without React Style | ||
### eslint-config-airbnb/base | ||
1. `npm install --save-dev eslint-config-airbnb babel-eslint ` | ||
Lints ES6+ but does not lint React. Requires `eslint` and `babel-eslint`. | ||
1. `npm install --save-dev eslint-config-airbnb babel-eslint eslint` | ||
2. add `"extends": "airbnb/base"` to your .eslintrc | ||
### eslint-config-airbnb/legacy | ||
Lints ES5 and below. Only requires `eslint`. | ||
1. `npm install --save-dev eslint-config-airbnb eslint` | ||
2. add `"extends": "airbnb/legacy"` to your .eslintrc | ||
See [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript) and | ||
@@ -34,4 +48,22 @@ the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) | ||
### 0.1.0 | ||
- switch to modular rules files courtesy the [eslint-config-default][ecd] | ||
project and [@taion][taion]. [PR][pr-modular] | ||
- export `eslint-config-airbnb/legacy` for ES5-only users. | ||
`eslint-config-airbnb/legacy` does not require the `babel-eslint` parser. | ||
[PR][pr-legacy] | ||
[ecd]: https://github.com/walmartlabs/eslint-config-defaults | ||
[taion]: https://github.com/taion | ||
[pr-modular]: https://github.com/airbnb/javascript/pull/526 | ||
[pr-legacy]: https://github.com/airbnb/javascript/pull/527 | ||
### 0.0.9 | ||
- add rule no-undef | ||
- add rule id-length | ||
### 0.0.8 | ||
- now has a changelog | ||
- now is modular (see instructions above for with react and without react versions) |
@@ -0,13 +1,30 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import test from 'tape'; | ||
import base from '../base'; | ||
test('base: does not reference react', t => { | ||
t.plan(2); | ||
const files = { | ||
base: require('../base') | ||
}; | ||
t.notOk(base.plugins, 'plugins is unspecified'); | ||
fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => { | ||
if (name === 'react.js') { | ||
return; | ||
} | ||
// scan rules for react/ and fail if any exist | ||
const reactRuleIds = Object.keys(base.rules) | ||
.filter(ruleId => ruleId.indexOf('react/') === 0); | ||
t.deepEquals(reactRuleIds, [], 'there are no react/ rules'); | ||
files[name] = require(`../rules/${name}`); | ||
}); | ||
Object.keys(files).forEach(name => { | ||
const config = files[name]; | ||
test(`${name}: does not reference react`, t => { | ||
t.plan(2); | ||
t.notOk(config.plugins, 'plugins is unspecified'); | ||
// scan rules for react/ and fail if any exist | ||
const reactRuleIds = Object.keys(config.rules) | ||
.filter(ruleId => ruleId.indexOf('react/') === 0); | ||
t.deepEquals(reactRuleIds, [], 'there are no react/ rules'); | ||
}); | ||
}); |
import test from 'tape'; | ||
import { CLIEngine } from 'eslint'; | ||
import eslintrc from '../'; | ||
import baseConfig from '../base'; | ||
import reactRules from '../rules/react'; | ||
@@ -8,2 +10,5 @@ const cli = new CLIEngine({ | ||
baseConfig: eslintrc, | ||
// This rule fails when executing on text. | ||
rules: {indent: 0}, | ||
}); | ||
@@ -29,4 +34,4 @@ | ||
t.plan(2); | ||
t.equal(eslintrc.parser, 'babel-eslint', 'uses babel-eslint'); | ||
t.equal(eslintrc.plugins[0], 'react', 'uses eslint-plugin-react'); | ||
t.equal(baseConfig.parser, 'babel-eslint', 'uses babel-eslint'); | ||
t.equal(reactRules.plugins[0], 'react', 'uses eslint-plugin-react'); | ||
}); | ||
@@ -37,9 +42,9 @@ | ||
const result = lint(wrapComponent(` | ||
componentWillMount() { } | ||
componentDidMount() { } | ||
setFoo() { } | ||
getFoo() { } | ||
setBar() { } | ||
someMethod() { } | ||
renderDogs() { } | ||
componentWillMount() {} | ||
componentDidMount() {} | ||
setFoo() {} | ||
getFoo() {} | ||
setBar() {} | ||
someMethod() {} | ||
renderDogs() {} | ||
render() { return <div />; } | ||
@@ -56,9 +61,9 @@ `)); | ||
const result = lint(wrapComponent(` | ||
someMethod() { } | ||
componentWillMount() { } | ||
componentDidMount() { } | ||
setFoo() { } | ||
getFoo() { } | ||
setBar() { } | ||
renderDogs() { } | ||
someMethod() {} | ||
componentWillMount() {} | ||
componentDidMount() {} | ||
setFoo() {} | ||
getFoo() {} | ||
setBar() {} | ||
renderDogs() {} | ||
render() { return <div />; } | ||
@@ -74,9 +79,9 @@ `)); | ||
const result = lint(wrapComponent(` | ||
componentWillMount() { } | ||
componentDidMount() { } | ||
someMethod() { } | ||
setFoo() { } | ||
getFoo() { } | ||
setBar() { } | ||
renderDogs() { } | ||
componentWillMount() {} | ||
componentDidMount() {} | ||
someMethod() {} | ||
setFoo() {} | ||
getFoo() {} | ||
setBar() {} | ||
renderDogs() {} | ||
render() { return <div />; } | ||
@@ -83,0 +88,0 @@ `)); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25248
19
606
68
2
1