Skip to content

Commit

Permalink
feat(react): react/jsx now included by default
Browse files Browse the repository at this point in the history
  • Loading branch information
glebec committed Dec 23, 2016
1 parent b592dd4 commit b790aa1
Show file tree
Hide file tree
Showing 7 changed files with 386 additions and 391 deletions.
281 changes: 2 additions & 279 deletions .eslintrc.js

Large diffs are not rendered by default.

22 changes: 3 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

### Global

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

```sh
npm install -g eslint-config-fullstack
npm install -g eslint eslint-config-fullstack eslint-plugin-react
```

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

### Local

A specific project can extend this definition by including `eslint-config-fullstack` as a saved dependency, and a local `.eslintrc.json` which `{ "extends": "fullstack" }`.
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" }`.

## Extending

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

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.

## React / JSX

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`:

```sh
npm install -g eslint-plugin-react
```

Then change your `.eslintrc.json` to extend the react sub-config:

```json
{
"extends": "fullstack/react"
}
```

## Background

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.
Expand Down
34 changes: 32 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
'use strict';
var base = require('./.eslintrc.js');

module.exports = base;
/**
* Fullstack Education Group
* ESLint config for teaching full-stack ES5/6 JS
* See http://eslint.org/docs/developer-guide/shareable-configs
* Authored by Gabriel Lebec, 2016
*/

module.exports = {

extends: [
'./rules/base',
'./rules/react'
].map(require.resolve),

env: {
es6: true,
browser: true,
node: true,
mocha: true,
jasmine: true,
jquery: true,
},

parserOptions: {
ecmaVersion: 6
},

globals: {
angular: true
}

};
86 changes: 3 additions & 83 deletions react.js
Original file line number Diff line number Diff line change
@@ -1,86 +1,6 @@
'use strict';

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

// To opt-in, use `"extends": "fullstack/react"`.

module.exports = {
extends: [
require.resolve('./index'), // base config
'plugin:react/recommended' // overridden below, unless this package falls behind plugin
],
plugins: [
'react'
],
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
},
rules: { // https://github.com/yannickcr/eslint-plugin-react

// general React rules

'react/display-name': 1, // Prevent missing displayName in a React component definition
'react/forbid-component-props': 0, // Forbid certain props on Components
'react/forbid-prop-types': 0, // Forbid certain propTypes
'react/no-array-index-key': 1, // Prevent using Array index in `key` props
'react/no-children-prop': 1, // Prevent passing children as props
'react/no-danger': 1, // Prevent usage of dangerous JSX properties
'react/no-danger-with-children': 1, // Prevent problem with children and props.dangerouslySetInnerHTML
'react/no-deprecated': 1, // Prevent usage of deprecated methods
'react/no-did-mount-set-state': 1, // Prevent usage of setState in componentDidMount
'react/no-did-update-set-state': 1, // Prevent usage of setState in componentDidUpdate
'react/no-direct-mutation-state': 2, // Prevent direct mutation of this.state
'react/no-find-dom-node': 1, // Prevent usage of findDOMNode
'react/no-is-mounted': 1, // Prevent usage of isMounted
'react/no-multi-comp': [1, { ignoreStateless: true }], // Prevent multiple component definition per file
'react/no-render-return-value': 1, // Prevent usage of the return value of React.render
'react/no-set-state': 0, // Prevent usage of setState
'react/no-string-refs': 1, // Prevent using string references in ref attribute.
'react/no-unescaped-entities': 0, // Prevent invalid characters from appearing in markup
'react/no-unknown-property': 1, // Prevent usage of unknown DOM property (fixable)
'react/no-unused-prop-types': 1, // Prevent definitions of unused prop types
'react/prefer-es6-class': 0, // Enforce ES5 or ES6 class for React Components
'react/prefer-stateless-function': 1, // Enforce stateless React Components to be written as a pure function
'react/prop-types': 0, // Prevent missing props validation in a React component definition
'react/react-in-jsx-scope': 1, // Prevent missing React when using JSX,
'react/require-default-props': 1, // Enforce a defaultProps definition for every prop that is not a required prop
'react/require-optimization': 0, // Enforce React components to have a shouldComponentUpdate method
'react/require-render-return': 1, // Enforce ES5 or ES6 class for returning value in render function
'react/self-closing-comp': 1, // Prevent extra closing tags for components without children (fixable)
'react/sort-comp': 0, // Enforce component methods order
'react/sort-prop-types': 0, // Enforce propTypes declarations alphabetical sorting
'react/style-prop-object': 1, // Enforce style prop value being an object

// JSX-specific rules

'react/jsx-boolean-value': 0, // Enforce boolean attributes notation in JSX (fixable)
'react/jsx-closing-bracket-location': 0, // Validate closing bracket location in JSX (fixable)
'react/jsx-curly-spacing': 0, // Enforce or disallow spaces inside of curly braces in JSX attributes (fixable)
'react/jsx-equals-spacing': 0, // Enforce or disallow spaces around equal signs in JSX attributes (fixable)
'react/jsx-filename-extension': 0, // Restrict file extensions that may contain JSX
'react/jsx-first-prop-new-line': [1, 'multiline-multiprop'], // Enforce position of the first prop in JSX (fixable)
'react/jsx-handler-names': 0, // Enforce event handler naming conventions in JSX
'react/jsx-indent': 0, // Validate JSX indentation (fixable)
'react/jsx-indent-props': 0, // Validate props indentation in JSX (fixable)
'react/jsx-key': 1, // Validate JSX has key prop when in array or iterator
'react/jsx-max-props-per-line': 0, // Limit maximum of props on a single line in JSX
'react/jsx-no-bind': 0, // Prevent usage of .bind() and arrow functions in JSX props
'react/jsx-no-comment-textnodes': 1, // Prevent comments from being inserted as text nodes
'react/jsx-no-duplicate-props': 1, // Prevent duplicate props in JSX
'react/jsx-no-literals': 0, // Prevent usage of unwrapped JSX strings
'react/jsx-no-target-blank': 1, // Prevent usage of unsafe target='_blank'
'react/jsx-no-undef': 1, // Disallow undeclared variables in JSX
'react/jsx-pascal-case': 1, // Enforce PascalCase for user-defined JSX components
'react/jsx-sort-props': 0, // Enforce props alphabetical sorting
'react/jsx-space-before-closing': 0, // Validate spacing before closing bracket in JSX (fixable)
'react/jsx-tag-spacing': 1, // Validate whitespace in and around the JSX opening and closing brackets (fixable)
'react/jsx-uses-react': 1, // Prevent React to be incorrectly marked as unused
'react/jsx-uses-vars': 1, // Prevent variables used in JSX to be incorrectly marked as unused
'react/jsx-wrap-multilines': 1, // Prevent missing parentheses around multilines JSX (fixable)
}
};
module.exports = require('./index');
Loading

0 comments on commit b790aa1

Please sign in to comment.