Skip to content

Commit

Permalink
Merge branch 'master' into 226-unused-prop-types
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
Evgueni Naverniouk committed Jul 14, 2016
2 parents 74f0cbe + ae5a43b commit 7b9fdb6
Show file tree
Hide file tree
Showing 26 changed files with 672 additions and 211 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
language: node_js
node_js:
- 0.10
- 0.12
- iojs
- 4
- 5
- '6'
- '5'
- '4'
after_success:
- npm run coveralls
83 changes: 83 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,89 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [6.0.0-alpha.1] - 2016-07-08
### Fixed
* Fix `prop-types` crash when accessing constructor on props ([#654][])
* Fix `jsx-filename-extension` to not check filenames on text input ([#662][] @ljharb)
* Fix `no-comment-textnodes` incorrectly catching urls ([#664][] @petersendidit)

### Breaking
* Add ESLint as peerDependency ([#657][] @jokeyrhyme)
* Add Node.js 0.10 as minimum required version ([#657][] @jokeyrhyme)

### Changed
* Update dependencies
* Update Travis CI and AppVeyor CI configurations (@ljharb)

[6.0.0-alpha.1]: https://github.com/yannickcr/eslint-plugin-react/compare/v5.2.2...v6.0.0-alpha.1
[#654]: https://github.com/yannickcr/eslint-plugin-react/issues/654
[#662]: https://github.com/yannickcr/eslint-plugin-react/issues/662
[#664]: https://github.com/yannickcr/eslint-plugin-react/issues/664
[#657]: https://github.com/yannickcr/eslint-plugin-react/pull/657

## [5.2.2] - 2016-06-17
### Fixed
* Fix `jsx-no-bind` crash ([#641][])

[5.2.2]: https://github.com/yannickcr/eslint-plugin-react/compare/v5.2.1...v5.2.2
[#641]: https://github.com/yannickcr/eslint-plugin-react/issues/641

## [5.2.1] - 2016-06-17
### Fixed
* Fix `jsx-pascal-case` for namespaced components ([#637][] @evcohen)

[5.2.1]: https://github.com/yannickcr/eslint-plugin-react/compare/v5.2.0...v5.2.1
[#637]: https://github.com/yannickcr/eslint-plugin-react/issues/637

## [5.2.0] - 2016-06-17
### Added
* Add `require-optimization` rule ([#240][] @EvNaverniouk)
* Add `jsx-filename-extension` rule ([#495][] @lencioni)
* Add `no-render-return-value` rule ([#531][] @iamdustan)
* Add `no-comment-textnodes` rule ([#616][] @benvinegar)
* Add `objectLiterals` option to `jsx-curly-spacing` ([#388][], [#211][] @casesandberg @ljharb)
* Add option to `self-closing-comp` to check html tags ([#572][] @gitim)
* Add `ignore` option to `no-unknown-property` rule ([#631][] @insin)
* Add support for ES7 bind operator to `jsx-handler-names` ([#630][])
* Add support for explicit declaration that class extends React.Component ([#68][] @gausie)

### Fixed
* Fix `jsx-closing-bracket-location` multiline prop support ([#493][] @tuures)
* Fix `prop-types` for props that where not assigned to the right component ([#591][])
* Fix `display-name` when JSON style is used for defining components ([#590][] @gitim)
* Fix `jsx-no-bind` for bind detection in render when assigned to a variable ([#474][] @petersendidit)
* Fix `jsx-curly-spacing` for spread operator ([#606][] @gitim)
* Fix `sort-comp` crash on spread operator ([#624][])
* Fix `prop-types` crash when destructuring props with spread only

### Changed
* Update dependencies
* Add [doctrine](https://github.com/eslint/doctrine) as a dependency ([#68][] @gausie)
* Add [jsx-ast-utils](https://github.com/evcohen/jsx-ast-utils) as a dependency ([#634][] @evcohen)
* Documentation improvements ([#594][] @lencioni, [#598][] @mLuby, [#633][] @appsforartists)

[5.2.0]: https://github.com/yannickcr/eslint-plugin-react/compare/v5.1.1...v5.2.0
[#68]: https://github.com/yannickcr/eslint-plugin-react/issues/68
[#211]: https://github.com/yannickcr/eslint-plugin-react/issues/211
[#240]: https://github.com/yannickcr/eslint-plugin-react/issues/240
[#388]: https://github.com/yannickcr/eslint-plugin-react/issues/388
[#474]: https://github.com/yannickcr/eslint-plugin-react/issues/474
[#493]: https://github.com/yannickcr/eslint-plugin-react/pull/493
[#495]: https://github.com/yannickcr/eslint-plugin-react/issues/495
[#531]: https://github.com/yannickcr/eslint-plugin-react/issues/531
[#572]: https://github.com/yannickcr/eslint-plugin-react/issues/572
[#590]: https://github.com/yannickcr/eslint-plugin-react/issues/590
[#591]: https://github.com/yannickcr/eslint-plugin-react/issues/591
[#594]: https://github.com/yannickcr/eslint-plugin-react/pull/594
[#598]: https://github.com/yannickcr/eslint-plugin-react/pull/598
[#606]: https://github.com/yannickcr/eslint-plugin-react/issues/606
[#616]: https://github.com/yannickcr/eslint-plugin-react/pull/616
[#624]: https://github.com/yannickcr/eslint-plugin-react/issues/624
[#630]: https://github.com/yannickcr/eslint-plugin-react/issues/630
[#631]: https://github.com/yannickcr/eslint-plugin-react/pull/631
[#633]: https://github.com/yannickcr/eslint-plugin-react/pull/633
[#634]: https://github.com/yannickcr/eslint-plugin-react/pull/634

## [5.1.1] - 2016-05-10
### Fixed
* Fix `require-render-return` crash ([#589][])
Expand Down
130 changes: 68 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,61 +68,67 @@ With ESLint 2.x.x:
}
```

Finally, enable all of the rules that you would like to use.
Finally, enable all of the rules that you would like to use. Use [our preset](#user-content-recommended-configuration) to get reasonable defaults quickly, and/or choose your own:

The plugin has a [recommended configuration](#user-content-recommended-configuration) that enforces React good practices.
```json
"rules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
}
```

# List of supported rules

* [display-name](docs/rules/display-name.md): Prevent missing `displayName` in a React component definition
* [forbid-prop-types](docs/rules/forbid-prop-types.md): Forbid certain propTypes
* [no-danger](docs/rules/no-danger.md): Prevent usage of dangerous JSX properties
* [no-deprecated](docs/rules/no-deprecated.md): Prevent usage of deprecated methods
* [no-did-mount-set-state](docs/rules/no-did-mount-set-state.md): Prevent usage of `setState` in `componentDidMount`
* [no-did-update-set-state](docs/rules/no-did-update-set-state.md): Prevent usage of `setState` in `componentDidUpdate`
* [no-direct-mutation-state](docs/rules/no-direct-mutation-state.md): Prevent direct mutation of `this.state`
* [no-is-mounted](docs/rules/no-is-mounted.md): Prevent usage of `isMounted`
* [no-multi-comp](docs/rules/no-multi-comp.md): Prevent multiple component definition per file
* [no-render-return-value](docs/rules/no-render-return-value.md): Prevent usage of the return value of `React.render`
* [no-set-state](docs/rules/no-set-state.md): Prevent usage of `setState`
* [no-string-refs](docs/rules/no-string-refs.md): Prevent using string references in `ref` attribute.
* [no-unknown-property](docs/rules/no-unknown-property.md): Prevent usage of unknown DOM property (fixable)
* [prefer-es6-class](docs/rules/prefer-es6-class.md): Enforce ES5 or ES6 class for React Components
* [prefer-stateless-function](docs/rules/prefer-stateless-function.md): Enforce stateless React Components to be written as a pure function
* [prop-types](docs/rules/prop-types.md): Prevent missing props validation in a React component definition
* [react-in-jsx-scope](docs/rules/react-in-jsx-scope.md): Prevent missing `React` when using JSX
* [require-extension](docs/rules/require-extension.md): Restrict file extensions that may be required
* [require-optimization](docs/rules/require-optimization.md): Enforce React components to have a shouldComponentUpdate method
* [require-render-return](docs/rules/require-render-return.md): Enforce ES5 or ES6 class for returning value in render function
* [self-closing-comp](docs/rules/self-closing-comp.md): Prevent extra closing tags for components without children
* [sort-comp](docs/rules/sort-comp.md): Enforce component methods order
* [sort-prop-types](docs/rules/sort-prop-types.md): Enforce propTypes declarations alphabetical sorting
* [unused-prop-types](docs/rules/unused-prop-types.md): Prevent definitions of unused prop types
* [wrap-multilines](docs/rules/wrap-multilines.md): Prevent missing parentheses around multilines JSX (fixable)
* [react/display-name](docs/rules/display-name.md): Prevent missing `displayName` in a React component definition
* [react/forbid-prop-types](docs/rules/forbid-prop-types.md): Forbid certain propTypes
* [react/no-comment-textnodes](docs/rules/no-comment-textnodes.md): Prevent comments from being inserted as text nodes
* [react/no-danger](docs/rules/no-danger.md): Prevent usage of dangerous JSX properties
* [react/no-deprecated](docs/rules/no-deprecated.md): Prevent usage of deprecated methods
* [react/no-did-mount-set-state](docs/rules/no-did-mount-set-state.md): Prevent usage of `setState` in `componentDidMount`
* [react/no-did-update-set-state](docs/rules/no-did-update-set-state.md): Prevent usage of `setState` in `componentDidUpdate`
* [react/no-direct-mutation-state](docs/rules/no-direct-mutation-state.md): Prevent direct mutation of `this.state`
* [react/no-is-mounted](docs/rules/no-is-mounted.md): Prevent usage of `isMounted`
* [react/no-multi-comp](docs/rules/no-multi-comp.md): Prevent multiple component definition per file
* [react/no-render-return-value](docs/rules/no-render-return-value.md): Prevent usage of the return value of `React.render`
* [react/no-set-state](docs/rules/no-set-state.md): Prevent usage of `setState`
* [react/no-string-refs](docs/rules/no-string-refs.md): Prevent using string references in `ref` attribute.
* [react/no-unknown-property](docs/rules/no-unknown-property.md): Prevent usage of unknown DOM property (fixable)
* [react/prefer-es6-class](docs/rules/prefer-es6-class.md): Enforce ES5 or ES6 class for React Components
* [react/prefer-stateless-function](docs/rules/prefer-stateless-function.md): Enforce stateless React Components to be written as a pure function
* [react/prop-types](docs/rules/prop-types.md): Prevent missing props validation in a React component definition
* [react/react-in-jsx-scope](docs/rules/react-in-jsx-scope.md): Prevent missing `React` when using JSX
* [react/require-extension](docs/rules/require-extension.md): Restrict file extensions that may be required
* [react/require-optimization](docs/rules/require-optimization.md): Enforce React components to have a shouldComponentUpdate method
* [react/require-render-return](docs/rules/require-render-return.md): Enforce ES5 or ES6 class for returning value in render function
* [react/self-closing-comp](docs/rules/self-closing-comp.md): Prevent extra closing tags for components without children
* [react/sort-comp](docs/rules/sort-comp.md): Enforce component methods order
* [react/sort-prop-types](docs/rules/sort-prop-types.md): Enforce propTypes declarations alphabetical sorting
* [react/unused-prop-types](docs/rules/unused-prop-types.md): Prevent definitions of unused prop types
* [react/wrap-multilines](docs/rules/wrap-multilines.md): Prevent missing parentheses around multilines JSX (fixable)

## JSX-specific rules

* [jsx-boolean-value](docs/rules/jsx-boolean-value.md): Enforce boolean attributes notation in JSX (fixable)
* [jsx-closing-bracket-location](docs/rules/jsx-closing-bracket-location.md): Validate closing bracket location in JSX (fixable)
* [jsx-curly-spacing](docs/rules/jsx-curly-spacing.md): Enforce or disallow spaces inside of curly braces in JSX attributes (fixable)
* [jsx-equals-spacing](docs/rules/jsx-equals-spacing.md): Enforce or disallow spaces around equal signs in JSX attributes (fixable)
* [jsx-filename-extension](docs/rules/jsx-filename-extension.md): Restrict file extensions that may contain JSX
* [jsx-first-prop-new-line](docs/rules/jsx-first-prop-new-line.md): Enforce position of the first prop in JSX
* [jsx-handler-names](docs/rules/jsx-handler-names.md): Enforce event handler naming conventions in JSX
* [jsx-indent](docs/rules/jsx-indent.md): Validate JSX indentation
* [jsx-indent-props](docs/rules/jsx-indent-props.md): Validate props indentation in JSX (fixable)
* [jsx-key](docs/rules/jsx-key.md): Validate JSX has key prop when in array or iterator
* [jsx-max-props-per-line](docs/rules/jsx-max-props-per-line.md): Limit maximum of props on a single line in JSX
* [jsx-no-bind](docs/rules/jsx-no-bind.md): Prevent usage of `.bind()` and arrow functions in JSX props
* [jsx-no-duplicate-props](docs/rules/jsx-no-duplicate-props.md): Prevent duplicate props in JSX
* [jsx-no-literals](docs/rules/jsx-no-literals.md): Prevent usage of unwrapped JSX strings
* [jsx-no-target-blank](docs/rules/jsx-no-target-blank.md): Prevent usage of unsafe `target='_blank'`
* [jsx-no-undef](docs/rules/jsx-no-undef.md): Disallow undeclared variables in JSX
* [jsx-pascal-case](docs/rules/jsx-pascal-case.md): Enforce PascalCase for user-defined JSX components
* [jsx-sort-props](docs/rules/jsx-sort-props.md): Enforce props alphabetical sorting
* [jsx-space-before-closing](docs/rules/jsx-space-before-closing.md): Validate spacing before closing bracket in JSX (fixable)
* [jsx-uses-react](docs/rules/jsx-uses-react.md): Prevent React to be incorrectly marked as unused
* [jsx-uses-vars](docs/rules/jsx-uses-vars.md): Prevent variables used in JSX to be incorrectly marked as unused
* [react/jsx-boolean-value](docs/rules/jsx-boolean-value.md): Enforce boolean attributes notation in JSX (fixable)
* [react/jsx-closing-bracket-location](docs/rules/jsx-closing-bracket-location.md): Validate closing bracket location in JSX (fixable)
* [react/jsx-curly-spacing](docs/rules/jsx-curly-spacing.md): Enforce or disallow spaces inside of curly braces in JSX attributes (fixable)
* [react/jsx-equals-spacing](docs/rules/jsx-equals-spacing.md): Enforce or disallow spaces around equal signs in JSX attributes (fixable)
* [react/jsx-filename-extension](docs/rules/jsx-filename-extension.md): Restrict file extensions that may contain JSX
* [react/jsx-first-prop-new-line](docs/rules/jsx-first-prop-new-line.md): Enforce position of the first prop in JSX
* [react/jsx-handler-names](docs/rules/jsx-handler-names.md): Enforce event handler naming conventions in JSX
* [react/jsx-indent](docs/rules/jsx-indent.md): Validate JSX indentation
* [react/jsx-indent-props](docs/rules/jsx-indent-props.md): Validate props indentation in JSX (fixable)
* [react/jsx-key](docs/rules/jsx-key.md): Validate JSX has key prop when in array or iterator
* [react/jsx-max-props-per-line](docs/rules/jsx-max-props-per-line.md): Limit maximum of props on a single line in JSX
* [react/jsx-no-bind](docs/rules/jsx-no-bind.md): Prevent usage of `.bind()` and arrow functions in JSX props
* [react/jsx-no-duplicate-props](docs/rules/jsx-no-duplicate-props.md): Prevent duplicate props in JSX
* [react/jsx-no-literals](docs/rules/jsx-no-literals.md): Prevent usage of unwrapped JSX strings
* [react/jsx-no-target-blank](docs/rules/jsx-no-target-blank.md): Prevent usage of unsafe `target='_blank'`
* [react/jsx-no-undef](docs/rules/jsx-no-undef.md): Disallow undeclared variables in JSX
* [react/jsx-pascal-case](docs/rules/jsx-pascal-case.md): Enforce PascalCase for user-defined JSX components
* [react/jsx-sort-props](docs/rules/jsx-sort-props.md): Enforce props alphabetical sorting
* [react/jsx-space-before-closing](docs/rules/jsx-space-before-closing.md): Validate spacing before closing bracket in JSX (fixable)
* [react/jsx-uses-react](docs/rules/jsx-uses-react.md): Prevent React to be incorrectly marked as unused
* [react/jsx-uses-vars](docs/rules/jsx-uses-vars.md): Prevent variables used in JSX to be incorrectly marked as unused

## React Native rules

Expand All @@ -147,20 +153,20 @@ See [ESLint documentation](http://eslint.org/docs/user-guide/configuring#extendi

The rules enabled in this configuration are:

* [display-name](docs/rules/display-name.md)
* [jsx-no-duplicate-props](docs/rules/jsx-no-duplicate-props.md)
* [jsx-no-undef](docs/rules/jsx-no-undef.md)
* [jsx-uses-react](docs/rules/jsx-uses-react.md)
* [jsx-uses-vars](docs/rules/jsx-uses-vars.md)
* [no-danger](docs/rules/no-danger.md)
* [no-deprecated](docs/rules/no-deprecated.md)
* [no-did-mount-set-state](docs/rules/no-did-mount-set-state.md) with `allow-in-func` option
* [no-did-update-set-state](docs/rules/no-did-update-set-state.md) with `allow-in-func` option
* [no-direct-mutation-state](docs/rules/no-direct-mutation-state.md)
* [no-is-mounted](docs/rules/no-is-mounted.md)
* [no-unknown-property](docs/rules/no-unknown-property.md)
* [prop-types](docs/rules/prop-types.md)
* [react-in-jsx-scope](docs/rules/react-in-jsx-scope.md)
* [react/display-name](docs/rules/display-name.md)
* [react/jsx-no-duplicate-props](docs/rules/jsx-no-duplicate-props.md)
* [react/jsx-no-undef](docs/rules/jsx-no-undef.md)
* [react/jsx-uses-react](docs/rules/jsx-uses-react.md)
* [react/jsx-uses-vars](docs/rules/jsx-uses-vars.md)
* [react/no-danger](docs/rules/no-danger.md)
* [react/no-deprecated](docs/rules/no-deprecated.md)
* [react/no-did-mount-set-state](docs/rules/no-did-mount-set-state.md) with `allow-in-func` option
* [react/no-did-update-set-state](docs/rules/no-did-update-set-state.md) with `allow-in-func` option
* [react/no-direct-mutation-state](docs/rules/no-direct-mutation-state.md)
* [react/no-is-mounted](docs/rules/no-is-mounted.md)
* [react/no-unknown-property](docs/rules/no-unknown-property.md)
* [react/prop-types](docs/rules/prop-types.md)
* [react/react-in-jsx-scope](docs/rules/react-in-jsx-scope.md)

**Note**: This configuration will also enable JSX in [parser options](http://eslint.org/docs/user-guide/configuring#specifying-parser-options).

Expand Down
4 changes: 1 addition & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
environment:
matrix:
- nodejs_version: '0.10'
- nodejs_version: '0.12'
- nodejs_version: '3'
- nodejs_version: '4'
- nodejs_version: '5'
- nodejs_version: '6'
install:
- ps: Install-Product node $env:nodejs_version
- set CI=true
Expand Down
22 changes: 15 additions & 7 deletions docs/rules/jsx-curly-spacing.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,34 @@ The following patterns are not warnings:
<Hello name={ {firstname: 'John', lastname: 'Doe'} } />;
```

#### Alternative
#### Granular spacing controls

When setting the `alternative` option to `true` you must collapse the curly braces:
You can specify an additional `spacing` property that is an object with the following possible values:

```json
"jsx-curly-spacing": [2, "always", {"alternative": true}]
"jsx-curly-spacing": [2, "always", {"spacing": {
"objectLiterals": "never"
}}]
```

When `"always"` is used and `alternative` is `true`, the following pattern is not warnings:
* `objectLiterals`: This controls different spacing requirements when the value inside the jsx curly braces is an object literal.

All spacing options accept either the string `"always"` or the string `"never"`. Note that the default value for all "spacing" options matches the first "always"/"never" option provided.

When `"always"` is used but `objectLiterals` is `"never"`, the following pattern is not considered a warning:

```js
<App foo={{ bar: true, baz: true }} />;
<App blah={ 3 } foo={{ bar: true, baz: true }} />;
```

When `"always"` is used and `alternative` is `true`, the following pattern is considered warnings:
When `"never"` is used and `objectLiterals` is `"always"`, the following pattern is not considered a warning:

```js
<App foo={ {bar: true, baz: true} } />;
<App blah={3} foo={ {bar: true, baz: true} } />;
```

Please note that spacing of the object literal curly braces themselves is controlled by the built-in [`object-curly-spacing`](http://eslint.org/docs/rules/object-curly-spacing) rule.

## When Not To Use It

You can turn this rule off if you are not concerned with the consistency around the spacing inside of JSX attributes.
11 changes: 11 additions & 0 deletions docs/rules/no-unknown-property.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ var React = require('react');
var Hello = <div className="hello">Hello World</div>;
```

## Rule Options

```js
...
"no-unknown-property": [<enabled>, { ignore: <ignore> }]
...
```

* `enabled`: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
* `ignore`: optional array of property and attribute names to ignore during validation.

## When Not To Use It

If you are not using JSX you can disable this rule.
Loading

0 comments on commit 7b9fdb6

Please sign in to comment.