Skip to content

Commit

Permalink
[new] support es2016
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Mollweide committed Feb 13, 2018
1 parent 7cbc7e9 commit f7f9318
Show file tree
Hide file tree
Showing 28 changed files with 327 additions and 142 deletions.
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@
$ npm install --save-dev eslint eslint-plugin-import @namics/eslint-config
```

## Usage
- `@namics/eslint-config/configurations/es6-browser` - ES6 + browser
- `@namics/eslint-config/configurations/es6-react` - ES6 + react
## Usage ES7 (ES2016)
- `@namics/eslint-config/configurations/es7-browser` - ES7 + browser
- `@namics/eslint-config/configurations/es7-react` - ES7 + react
- `@namics/eslint-config/configurations/es7-node` - ES7 + node

## Usage ES6 (ES2015) - deprecated
- `@namics/eslint-config/configurations/es6-browser` - ES6 + browser (deprecated)
- `@namics/eslint-config/configurations/es6-react` - ES6 + react (deprecated)
- `@namics/eslint-config/configurations/es6-node` - ES6 + node
- `@namics/eslint-config/configurations/flow` - flow
- `@namics/eslint-config/configurations/es5-browser` - ES5 + browser (deprecated)
- `@namics/eslint-config/configurations/es5-node` - ES5 + node (deprecated)

## Usage with Flow
- [configuration with flowtype](./documentation/with-flow.md)

## Usage with Prettier
- [configuration with prettier](./documentation/with-prettier.md)


### .eslintrc.js (add globals here if needed)
```
Expand All @@ -26,10 +35,6 @@ module.exports = {
};
```

####
- [configuration with flowtype](./documentation/with-flow.md)
- [configuration with prettier](./documentation/with-prettier.md)

### .eslintignore
```
/.idea/
Expand All @@ -46,28 +51,28 @@ module.exports = {
then run `npm run lint`

### Example usage in project tree
- .eslintrc.js (es6-react)
- .eslintrc.js (es7-react)
- .eslintignore
- src
- app.jsx
- test
- .eslintrc.js (es6-node)
- .eslintrc.js (es7-node)
- index.js
- scripts
- .eslintrc.js (es5-node)
- .eslintrc.js (es6-node)
- index.js

## Documentation
- [Best practices](./documentation/best-practices.md) (ES5 + ES6)
- [Style](./documentation/style.md) (ES5 + ES6)
- [Variables](./documentation/variables.md) (ES5 + ES6)
- [Errors](./documentation/errors.md) (ES5 + ES6)
- [Node](./documentation/node.md) (ES5 + ES6)
- [ES6](./documentation/es6.md) (ES6)
- [Imports](./documentation/imports.md) (ES6)
- [React](./documentation/react.md) (ES6)
- [React A11y](./documentation/react-a11y.md) (ES6)
- [Flow](./documentation/flow.md) (ES6)
- [Best practices](./documentation/best-practices.md) (ES5/6/7)
- [Style](./documentation/style.md) (ES5/6/7)
- [Variables](./documentation/variables.md) (ES5/6/7)
- [Errors](./documentation/errors.md) (ES5/6/7)
- [Node](./documentation/node.md) (ES5/6/7)
- [ES6](./documentation/es6.md) (ES6/7)
- [Imports](./documentation/imports.md) (ES6/7)
- [React](./documentation/react.md) (ES6/7)
- [React A11y](./documentation/react-a11y.md) (ES6/7)
- [Flow](./documentation/flow.md) (ES6/7)

## Thanks to
* [Namics.](https://www.namics.com/en/)
Expand Down
8 changes: 6 additions & 2 deletions configurations/es6-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ module.exports = {
browser: true,
node: false,
amd: false,
mocha: false,
jasmine: false,
mocha: true,
jasmine: true,
jest: true,
jquery: true,
serviceworker: true,
worker: true,
},

};
8 changes: 6 additions & 2 deletions configurations/es6-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ module.exports = {
browser: false,
node: true,
amd: false,
mocha: false,
jasmine: false,
mocha: true,
jasmine: true,
jest: true,
jquery: true,
serviceworker: true,
worker: true,
},

};
2 changes: 1 addition & 1 deletion configurations/es6-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
},
'react': {
'pragma': 'React',
'version': '0.15',
'version': '16',
},
},

Expand Down
7 changes: 7 additions & 0 deletions configurations/es7-browser-disable-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {

extends: [
'./es7-disable-styles.js',
].map(require.resolve),

};
17 changes: 17 additions & 0 deletions configurations/es7-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {

extends: [
'./es7.js',
].map(require.resolve),
env: {
browser: true,
node: false,
amd: false,
mocha: true,
jasmine: true,
jest: true,
jquery: true,
serviceworker: true,
worker: true,
},
};
12 changes: 12 additions & 0 deletions configurations/es7-disable-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {

extends: [
'../rules/best-practices-disable-styles.js',
'../rules/errors-disable-styles.js',
'../rules/style-disable-styles.js',
'../rules/variables-disable-styles.js',
'../rules/imports-disable-styles.js',
'../rules/es6-disable-styles.js',
].map(require.resolve),

};
8 changes: 8 additions & 0 deletions configurations/es7-node-disable-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {

extends: [
'./es7-disable-styles.js',
'../rules/node-disable-styles.js',
].map(require.resolve),

};
19 changes: 19 additions & 0 deletions configurations/es7-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {

extends: [
'./es7.js',
'../rules/node.js',
].map(require.resolve),
env: {
browser: false,
node: true,
amd: false,
mocha: true,
jasmine: true,
jest: true,
jquery: true,
serviceworker: true,
worker: true,
},

};
8 changes: 8 additions & 0 deletions configurations/es7-react-disable-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
'extends': [
'./es7-disable-styles.js',
'../rules/react-disable-styles.js',
'../rules/react-a11y-disable-styles.js',
].map(require.resolve),

};
37 changes: 37 additions & 0 deletions configurations/es7-react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
'plugins': [
'jsx-a11y',
'react',
],
'extends': [
'./es7.js',
'../rules/react.js',
'../rules/react-a11y.js',
].map(require.resolve),
'env': {
'browser': true,
'node': false,
'amd': false,
'mocha': true,
'jasmine': true,
'jest': true,
'jquery': true,
'serviceworker': true,
'worker': true,
},
'parserOptions': {
'ecmaVersion': 7,
'sourceType': 'module',
'ecmaFeatures': {
'jsx': true,
},
},
'settings': {
'import/resolver': {
'node': {
'extensions': ['.js', '.jsx', '.json'],
},
},
},

};
32 changes: 32 additions & 0 deletions configurations/es7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {

env: {
es6: true,
},
plugins: [
'import',
],

settings: {
'import/resolver': {
node: {
extensions: ['.js', '.json'],
},
},
},
extends: [
'../rules/node-disable.js',
'../rules/best-practices.js',
'../rules/errors.js',
'../rules/style.js',
'../rules/variables.js',
'../rules/imports.js',
'../rules/es6.js',
].map(require.resolve),

parserOptions: {
ecmaVersion: 7,
sourceType: 'module',
},

};
2 changes: 1 addition & 1 deletion documentation/with-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Flowtype rules will be accepted if the flow annotation was defined in first line
```
module.exports = {
"extends": [
"@namics/eslint-config/configurations/es6-react.js",
"@namics/eslint-config/configurations/es7-react.js",
"@namics/eslint-config/configurations/flow.js"
]
};
Expand Down
18 changes: 9 additions & 9 deletions documentation/with-prettier.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
## with prettier

### ES6 + Prettier
### ES7 (ES2016) + Prettier
```
module.exports = {
"extends": [
"@namics/eslint-config/configurations/es6-browser.js",
"@namics/eslint-config/configurations/es6-browser-disable-styles.js"
"@namics/eslint-config/configurations/es7-browser.js",
"@namics/eslint-config/configurations/es7-browser-disable-styles.js"
]
};
```

### ES6 + React + Prettier
### ES7 (ES2016) + React + Prettier
```
module.exports = {
"extends": [
"@namics/eslint-config/configurations/es6-react.js",
"@namics/eslint-config/configurations/es6-react-disable-styles.js"
"@namics/eslint-config/configurations/es7-react.js",
"@namics/eslint-config/configurations/es7-react-disable-styles.js"
]
};
```

### ES6 + React + Flow + Prettier
### ES7 (ES2016) + React + Flow + Prettier
```
module.exports = {
"extends": [
"@namics/eslint-config/configurations/es6-react.js",
"@namics/eslint-config/configurations/es6-react-disable-styles.js",
"@namics/eslint-config/configurations/es7-react.js",
"@namics/eslint-config/configurations/es7-react-disable-styles.js",
"@namics/eslint-config/configurations/flow.js",
"@namics/eslint-config/configurations/flow-disable-styles.js"
]
Expand Down
43 changes: 24 additions & 19 deletions test/es6-react-disable-styles/rules/react/no-did-mount-set-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,37 @@
// <!START
// Bad
/*
const Hello = React.createClass({
class Hello extends Component {
componentDidMount() {
this.setState({
isLoading: true
isLoading: true
});
},
render() {
return <div>Hello {this.state.name}</div>;
return (
<div>
Hello {this.state.name}
</div>
);
}
});
}
*/

// Good
const Hello = React.createClass({
constructor() {
// initialState
this.state = {
isLoading: true
};
},
render() {
return (
<div>
Hello {this.state.name}
</div>
);
}
});
class Hello extends Component {
constructor() {
// initialState
this.state = {
isLoading: true
};
}

render() {
return (
<div>
Hello {this.state.name}
</div>
);
}
}
// END!>
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
// <!START
// Bad
/*
const Hello = React.createClass({
class Hello extends Component {
componentDidUpdate() {
this.setState({
name: this.props.name.toUpperCase()
});
},
}
render() {
return <div>Hello {this.state.name}</div>;
}
});
}
*/
// END!>
Loading

0 comments on commit f7f9318

Please sign in to comment.