Skip to content

Commit b790aa1

Browse files
committed
feat(react): react/jsx now included by default
1 parent b592dd4 commit b790aa1

File tree

7 files changed

+386
-391
lines changed

7 files changed

+386
-391
lines changed

.eslintrc.js

Lines changed: 2 additions & 279 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
### Global
1515

16-
Global installation is recommended for [Fullstack Education Group](http://www.fullstackacademy.com/) students:
16+
Global installation is recommended for [Fullstack Education Group](http://www.fullstackacademy.com/) students. To install or upgrade the config along with its peer dependencies:
1717

1818
```sh
19-
npm install -g eslint-config-fullstack
19+
npm install -g eslint eslint-config-fullstack eslint-plugin-react
2020
```
2121

2222
In your global `~/.eslintrc.json` file:
@@ -31,7 +31,7 @@ Note that the `eslint-config-` portion of the module name is assumed by ESLint.
3131

3232
### Local
3333

34-
A specific project can extend this definition by including `eslint-config-fullstack` as a saved dependency, and a local `.eslintrc.json` which `{ "extends": "fullstack" }`.
34+
A specific project can extend this definition by including `eslint eslint-config-fullstack eslint-plugin-react` as saved dev-dependencies, and a local `.eslintrc.json` which `{ "extends": "fullstack" }`.
3535

3636
## Extending
3737

@@ -48,22 +48,6 @@ Any [rules](http://eslint.org/docs/rules/) added to your global or local `.eslin
4848

4949
This turns on enforcing the use of semicolons, a rule which is silenced by default in the current version of the `eslint-config-fullstack` package.
5050

51-
## React / JSX
52-
53-
With version 2, `eslint-config-fullstack` now has preliminary support for React/JSX projects. Note that you must manually install the additional peer dependency `eslint-plugin-react`:
54-
55-
```sh
56-
npm install -g eslint-plugin-react
57-
```
58-
59-
Then change your `.eslintrc.json` to extend the react sub-config:
60-
61-
```json
62-
{
63-
"extends": "fullstack/react"
64-
}
65-
```
66-
6751
## Background
6852

6953
The [ESLint](http://http://eslint.org/) linting system is a popular one for its support of ES6 syntax, pluggable [rules](http://eslint.org/docs/rules/), automatic rule names in warning messages, and [shareable](http://eslint.org/docs/developer-guide/shareable-configs) / [extendable](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) config files.

index.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
'use strict';
2-
var base = require('./.eslintrc.js');
32

4-
module.exports = base;
3+
/**
4+
* Fullstack Education Group
5+
* ESLint config for teaching full-stack ES5/6 JS
6+
* See http://eslint.org/docs/developer-guide/shareable-configs
7+
* Authored by Gabriel Lebec, 2016
8+
*/
9+
10+
module.exports = {
11+
12+
extends: [
13+
'./rules/base',
14+
'./rules/react'
15+
].map(require.resolve),
16+
17+
env: {
18+
es6: true,
19+
browser: true,
20+
node: true,
21+
mocha: true,
22+
jasmine: true,
23+
jquery: true,
24+
},
25+
26+
parserOptions: {
27+
ecmaVersion: 6
28+
},
29+
30+
globals: {
31+
angular: true
32+
}
33+
34+
};

react.js

Lines changed: 3 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,6 @@
11
'use strict';
22

3-
// Specifies additional options to use in React / React-JSX projects.
4-
// Note that you need to manually install `eslint-plugin-react` as a peer
5-
// dependency (see https://goo.gl/I4AYlb for more details).
3+
// Deprecated, kept only for backwards compatibility.
4+
// The main module now includes react support by default.
65

7-
// To opt-in, use `"extends": "fullstack/react"`.
8-
9-
module.exports = {
10-
extends: [
11-
require.resolve('./index'), // base config
12-
'plugin:react/recommended' // overridden below, unless this package falls behind plugin
13-
],
14-
plugins: [
15-
'react'
16-
],
17-
parserOptions: {
18-
sourceType: 'module',
19-
ecmaFeatures: {
20-
jsx: true
21-
}
22-
},
23-
rules: { // https://github.com/yannickcr/eslint-plugin-react
24-
25-
// general React rules
26-
27-
'react/display-name': 1, // Prevent missing displayName in a React component definition
28-
'react/forbid-component-props': 0, // Forbid certain props on Components
29-
'react/forbid-prop-types': 0, // Forbid certain propTypes
30-
'react/no-array-index-key': 1, // Prevent using Array index in `key` props
31-
'react/no-children-prop': 1, // Prevent passing children as props
32-
'react/no-danger': 1, // Prevent usage of dangerous JSX properties
33-
'react/no-danger-with-children': 1, // Prevent problem with children and props.dangerouslySetInnerHTML
34-
'react/no-deprecated': 1, // Prevent usage of deprecated methods
35-
'react/no-did-mount-set-state': 1, // Prevent usage of setState in componentDidMount
36-
'react/no-did-update-set-state': 1, // Prevent usage of setState in componentDidUpdate
37-
'react/no-direct-mutation-state': 2, // Prevent direct mutation of this.state
38-
'react/no-find-dom-node': 1, // Prevent usage of findDOMNode
39-
'react/no-is-mounted': 1, // Prevent usage of isMounted
40-
'react/no-multi-comp': [1, { ignoreStateless: true }], // Prevent multiple component definition per file
41-
'react/no-render-return-value': 1, // Prevent usage of the return value of React.render
42-
'react/no-set-state': 0, // Prevent usage of setState
43-
'react/no-string-refs': 1, // Prevent using string references in ref attribute.
44-
'react/no-unescaped-entities': 0, // Prevent invalid characters from appearing in markup
45-
'react/no-unknown-property': 1, // Prevent usage of unknown DOM property (fixable)
46-
'react/no-unused-prop-types': 1, // Prevent definitions of unused prop types
47-
'react/prefer-es6-class': 0, // Enforce ES5 or ES6 class for React Components
48-
'react/prefer-stateless-function': 1, // Enforce stateless React Components to be written as a pure function
49-
'react/prop-types': 0, // Prevent missing props validation in a React component definition
50-
'react/react-in-jsx-scope': 1, // Prevent missing React when using JSX,
51-
'react/require-default-props': 1, // Enforce a defaultProps definition for every prop that is not a required prop
52-
'react/require-optimization': 0, // Enforce React components to have a shouldComponentUpdate method
53-
'react/require-render-return': 1, // Enforce ES5 or ES6 class for returning value in render function
54-
'react/self-closing-comp': 1, // Prevent extra closing tags for components without children (fixable)
55-
'react/sort-comp': 0, // Enforce component methods order
56-
'react/sort-prop-types': 0, // Enforce propTypes declarations alphabetical sorting
57-
'react/style-prop-object': 1, // Enforce style prop value being an object
58-
59-
// JSX-specific rules
60-
61-
'react/jsx-boolean-value': 0, // Enforce boolean attributes notation in JSX (fixable)
62-
'react/jsx-closing-bracket-location': 0, // Validate closing bracket location in JSX (fixable)
63-
'react/jsx-curly-spacing': 0, // Enforce or disallow spaces inside of curly braces in JSX attributes (fixable)
64-
'react/jsx-equals-spacing': 0, // Enforce or disallow spaces around equal signs in JSX attributes (fixable)
65-
'react/jsx-filename-extension': 0, // Restrict file extensions that may contain JSX
66-
'react/jsx-first-prop-new-line': [1, 'multiline-multiprop'], // Enforce position of the first prop in JSX (fixable)
67-
'react/jsx-handler-names': 0, // Enforce event handler naming conventions in JSX
68-
'react/jsx-indent': 0, // Validate JSX indentation (fixable)
69-
'react/jsx-indent-props': 0, // Validate props indentation in JSX (fixable)
70-
'react/jsx-key': 1, // Validate JSX has key prop when in array or iterator
71-
'react/jsx-max-props-per-line': 0, // Limit maximum of props on a single line in JSX
72-
'react/jsx-no-bind': 0, // Prevent usage of .bind() and arrow functions in JSX props
73-
'react/jsx-no-comment-textnodes': 1, // Prevent comments from being inserted as text nodes
74-
'react/jsx-no-duplicate-props': 1, // Prevent duplicate props in JSX
75-
'react/jsx-no-literals': 0, // Prevent usage of unwrapped JSX strings
76-
'react/jsx-no-target-blank': 1, // Prevent usage of unsafe target='_blank'
77-
'react/jsx-no-undef': 1, // Disallow undeclared variables in JSX
78-
'react/jsx-pascal-case': 1, // Enforce PascalCase for user-defined JSX components
79-
'react/jsx-sort-props': 0, // Enforce props alphabetical sorting
80-
'react/jsx-space-before-closing': 0, // Validate spacing before closing bracket in JSX (fixable)
81-
'react/jsx-tag-spacing': 1, // Validate whitespace in and around the JSX opening and closing brackets (fixable)
82-
'react/jsx-uses-react': 1, // Prevent React to be incorrectly marked as unused
83-
'react/jsx-uses-vars': 1, // Prevent variables used in JSX to be incorrectly marked as unused
84-
'react/jsx-wrap-multilines': 1, // Prevent missing parentheses around multilines JSX (fixable)
85-
}
86-
};
6+
module.exports = require('./index');

0 commit comments

Comments
 (0)