Skip to content

Commit

Permalink
remove duplicate test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwullems committed Jan 10, 2020
2 parents d7423f1 + 5fac02c commit cf1cf2e
Show file tree
Hide file tree
Showing 82 changed files with 2,649 additions and 1,136 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
@@ -1,6 +1,7 @@
{
"root": true,
"extends": "airbnb-base",
"extends": ["airbnb-base", "plugin:eslint-plugin/recommended"],
"plugins": ["eslint-plugin"],
"env": {
"es6": true,
"node": true
Expand All @@ -15,6 +16,7 @@
"rules": {
"comma-dangle": [2, "never"],
"object-curly-spacing": [2, "never"],
"object-shorthand": [2, "always"],
"array-bracket-spacing": [2, "never"],
"max-len": [2, 120, {
"ignoreStrings": true,
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -13,7 +13,7 @@ before_script:
- 'if [ -n "${ESLINT-}" ]; then npm install --no-save "eslint@${ESLINT}" ; fi'
script:
- 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi'
- 'if [ -n "${TEST-}" ]; then npm run unit-test ; fi'
- 'if [ -z "${PRETEST-}" ] && [ -n "${TEST-}" ]; then npm run unit-test ; fi'
env:
global:
- TEST=true
Expand Down
57 changes: 57 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,61 @@ 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).

## [7.17.0] - 2019-11-28

### Added
* [`jsx-no-target-blank`][]: add `allowReferrer` option ([#2478][] @eps1lon)
* [`jsx-handler-names`][]: add `checkLocalVariables` option ([#2470][] @aub)
* [`prop-types`][]: Support Flow Type spread ([#2446][] @moroine)
* [`jsx-props-no-spreading`][]: add `explicitSpread` option to allow explicit spread of props ([#2449][] @pawelnvk)
* [`jsx-no-target-blank`][]: warn on `target={'_blank'}` expressions ([#2451][] @timkraut)
* [`require-default-props`]: add option to ignore functional components ([#2532][] @RedTn)

### Fixed
* [`sort-prop-types`][], [`jsx-sort-default-props`][]: disable broken autofix ([#2505][] @webOS101)
* [`no-typos`][]: improve report location ([#2468][] @golopot)
* [`jsx-no-literals`][]: trim whitespace for `allowedStrings` check ([#2436][] @cainlevy)
* [`jsx-curly-brace-presence`][]: Fix filter of undefined error with whitespace inside jsx attr curlies ([#2460][] @dustinyoste)
* [`no-render-return-value`][]: should warn when used in assignment expression ([#2462][] @jichu4n)
* [`jsx-curly-brace-presence`][]: allow trailing spaces in literal ([#2448][] @doochik)

### Changed
* [Deps] update `jsx-ast-utils`, `object.fromentries`, `resolve`
* [eslint] fix func-names and change object-shorthand to 'always' ([#2483][] @golopot)
* [Docs] `jsx-first-prop-new-line`: Fix documentation formatting ([#2489][] @pjg)
* [Docs] [`prop-types`][]: Update 'skipUndeclared' in rule options ([#2504][] @cjnickel)
* [Docs] [`jsx-first-prop-new-line`][]: fix wrong rule name ([#2500][] @zgayjjf)
* [eslint] enable eslint-plugin-eslint-plugin ([#2469][] @golopot)
* [Docs] [`jsx-props-no-multi-spaces`][]: suggest using core rule instead ([#2463][] @golopot)
* [Docs] [`jsx-first-prop-new-line`][]: add rule options ([#2465][] @SerdarMustafa1)
* [Docs] [`jsx-no-target-blank`][]: Add section about overriding for trusted links ([#2438][] @aschriner)
* [Docs] fix typo ([#2453][] @cainwatson)
* [Docs] [`no-unused-prop-types`][]: clean up prose ([#2273][] @coryhouse)
* [Docs] [`jsx-no-bind`][]: add section about React Hooks ([#2443][] @kdex)

[#2532]: https://github.com/yannickcr/eslint-plugin-react/pull/2532
[#2505]: https://github.com/yannickcr/eslint-plugin-react/pull/2505
[#2504]: https://github.com/yannickcr/eslint-plugin-react/pull/2504
[#2500]: https://github.com/yannickcr/eslint-plugin-react/pull/2500
[#2489]: https://github.com/yannickcr/eslint-plugin-react/pull/2489
[#2483]: https://github.com/yannickcr/eslint-plugin-react/pull/2483
[#2478]: https://github.com/yannickcr/eslint-plugin-react/pull/2478
[#2470]: https://github.com/yannickcr/eslint-plugin-react/pull/2470
[#2469]: https://github.com/yannickcr/eslint-plugin-react/pull/2469
[#2468]: https://github.com/yannickcr/eslint-plugin-react/pull/2468
[#2465]: https://github.com/yannickcr/eslint-plugin-react/pull/2465
[#2463]: https://github.com/yannickcr/eslint-plugin-react/pull/2463
[#2460]: https://github.com/yannickcr/eslint-plugin-react/pull/2460
[#2453]: https://github.com/yannickcr/eslint-plugin-react/pull/2453
[#2451]: https://github.com/yannickcr/eslint-plugin-react/pull/2451
[#2449]: https://github.com/yannickcr/eslint-plugin-react/pull/2449
[#2448]: https://github.com/yannickcr/eslint-plugin-react/pull/2448
[#2446]: https://github.com/yannickcr/eslint-plugin-react/pull/2446
[#2443]: https://github.com/yannickcr/eslint-plugin-react/pull/2443
[#2438]: https://github.com/yannickcr/eslint-plugin-react/pull/2438
[#2436]: https://github.com/yannickcr/eslint-plugin-react/pull/2436
[#2273]: https://github.com/yannickcr/eslint-plugin-react/pull/2273

## [7.16.0] - 2019-10-04

### Added
Expand Down Expand Up @@ -2754,4 +2809,6 @@ If you're still not using React 15 you can keep the old behavior by setting the
[`static-property-placement`]: docs/rules/static-property-placement.md
[`jsx-curly-newline`]: docs/rules/jsx-curly-newline.md
[`jsx-no-useless-fragment`]: docs/rules/jsx-no-useless-fragment.md
[`jsx-no-script-url`]: docs/rules/jsx-no-script-url.md
[`no-adjacent-inline-elements`]: docs/rules/no-adjacent-inline-elements.md
[`function-component-definition`]: docs/rules/function-component-definition.md
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -168,6 +168,7 @@ Enable the rules that you would like to use.
* [react/jsx-no-comment-textnodes](docs/rules/jsx-no-comment-textnodes.md): Prevent comments from being inserted as text nodes
* [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-script-url](docs/rules/jsx-no-script-url.md): Prevent usage of `javascript:` URLs
* [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-no-useless-fragment](docs/rules/jsx-no-useless-fragment.md): Disallow unnecessary fragments (fixable)
Expand Down
6 changes: 6 additions & 0 deletions docs/rules/jsx-first-prop-new-line.md
Expand Up @@ -99,6 +99,12 @@ The following patterns are **not** considered warnings when configured `"multili
/>
```

## Rule Options

```jsx
"react/jsx-first-prop-new-line": `"always" | "never" | "multiline" | "multiline-multiprop"`
```

## When not to use

If you are not using JSX then you can disable this rule.
4 changes: 3 additions & 1 deletion docs/rules/jsx-handler-names.md
Expand Up @@ -30,13 +30,15 @@ The following patterns are **not** considered warnings:
...
"react/jsx-handler-names": [<enabled>, {
"eventHandlerPrefix": <eventHandlerPrefix>,
"eventHandlerPropPrefix": <eventHandlerPropPrefix>
"eventHandlerPropPrefix": <eventHandlerPropPrefix>,
"checkLocalVariables": <boolean>
}]
...
```

* `eventHandlerPrefix`: Prefix for component methods used as event handlers. Defaults to `handle`
* `eventHandlerPropPrefix`: Prefix for props that are used as event handlers. Defaults to `on`
* `checkLocalVariables`: Determines whether event handlers stored as local variables are checked. Defaults to `false`

## When Not To Use It

Expand Down
30 changes: 24 additions & 6 deletions docs/rules/jsx-no-literals.md
@@ -1,11 +1,10 @@
# Prevent usage of string literals in JSX (react/jsx-no-literals)

There are a couple of scenarios where you want to avoid string literals in JSX. Either to enforce consistency and reducing strange behaviour, or for enforcing that literals aren't kept in JSX so they can be translated.
There are a few scenarios where you want to avoid string literals in JSX. You may want to enforce consistency, reduce syntax highlighting issues, or ensure that strings are part of a translation system.

## Rule Details

In JSX when using a literal string you can wrap it in a JSX container `{'TEXT'}`. This rules by default requires that you wrap all literal strings.
Prevents any odd artifacts of highlighters if your unwrapped string contains an enclosing character like `'` in contractions and enforces consistency.
By default this rule requires that you wrap all literal strings in a JSX container `{'TEXT'}`.

The following patterns are considered warnings:

Expand All @@ -19,14 +18,20 @@ The following patterns are **not** considered warnings:
var Hello = <div>{'test'}</div>;
```

### Options
```jsx
var Hello = <div>
{'test'}
</div>;
```

## Rule Options

There are two options:

* `noStrings` - Enforces no string literals used as children, wrapped or unwrapped.
* `allowedStrings` - an array of unique string values that would otherwise warn, but will be ignored.
* `allowedStrings` - An array of unique string values that would otherwise warn, but will be ignored.

To use, you can specify like the following:
To use, you can specify as follows:

```js
"react/jsx-no-literals": [<enabled>, {"noStrings": true, "allowedStrings": ["allowed"]}]
Expand All @@ -42,6 +47,12 @@ var Hello = <div>test</div>;
var Hello = <div>{'test'}</div>;
```

```jsx
var Hello = <div>
{'test'}
</div>;
```

The following are **not** considered warnings:

```jsx
Expand All @@ -59,6 +70,13 @@ var Hello = <div>{translate('my.translation.key')}</div>
var Hello = <div>allowed</div>
```

```jsx
// an allowed string surrounded by only whitespace
var Hello = <div>
allowed
</div>;
```

## When Not To Use It

If you do not want to enforce any style JSX literals, then you can disable this rule.
57 changes: 57 additions & 0 deletions docs/rules/jsx-no-script-url.md
@@ -0,0 +1,57 @@
# Prevent usage of `javascript:` URLs (react/jsx-no-script-url)

**In React 16.9** any URLs starting with `javascript:` [scheme](https://wiki.whatwg.org/wiki/URL_schemes#javascript:_URLs) log a warning.
React considers the pattern as a dangerous attack surface, see [details](https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#deprecating-javascript-urls).
**In a future major release**, React will throw an error if it encounters a `javascript:` URL.

## Rule Details

The following patterns are considered warnings:

```jsx
<a href="javascript:"></a>
<a href="javascript:void(0)"></a>
<a href="j\n\n\na\rv\tascript:"></a>
```

The following patterns are **not** considered warnings:

```jsx
<Foo href="javascript:"></Foo>
<a href={"javascript:"}></a>
```

## Rule Options
```json
{
"react/jsx-no-script-url": [
"error",
[
{
"name": "Link",
"props": ["to"]
},
{
"name": "Foo",
"props": ["href", "to"]
}
]
]
}
```

Allows you to indicate a specific list of properties used by a custom component to be checked.

### name
Component name.

### props
List of properties that should be validated.

The following patterns are considered warnings with the options listed above:

```jsx
<Link to="javascript:void(0)"></Link>
<Foo href="javascript:void(0)"></Foo>
<Foo to="javascript:void(0)"></Foo>
```
3 changes: 2 additions & 1 deletion docs/rules/jsx-no-target-blank.md
Expand Up @@ -14,10 +14,11 @@ This rule aims to prevent user generated links from creating security vulnerabil
## Rule Options
```json
...
"react/jsx-no-target-blank": [<enabled>, { "enforceDynamicLinks": <enforce> }]
"react/jsx-no-target-blank": [<enabled>, { "allowReferrer": <allow-referrer>, "enforceDynamicLinks": <enforce> }]
...
```

* allow-referrer: optional boolean. If `true` does not require `noreferrer`. Defaults to `false`.
* enabled: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
* enforce: optional string, 'always' or 'never'

Expand Down
2 changes: 2 additions & 0 deletions docs/rules/jsx-props-no-multi-spaces.md
Expand Up @@ -29,3 +29,5 @@ The following patterns are **not** considered warnings:
## When Not To Use It

If you are not using JSX or don't care about the space between two props in the same line.

If you have enabled the core rule `no-multi-spaces` with eslint >= 3, you don't need this rule.
2 changes: 0 additions & 2 deletions docs/rules/jsx-sort-default-props.md
Expand Up @@ -2,8 +2,6 @@

Some developers prefer to sort `defaultProps` declarations alphabetically to be able to find necessary declarations easier at a later time. Others feel that it adds complexity and becomes a burden to maintain.

**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.

## Rule Details

This rule checks all components and verifies that all `defaultProps` declarations are sorted alphabetically. A spread attribute resets the verification. The default configuration of the rule is case-sensitive.
Expand Down
24 changes: 24 additions & 0 deletions docs/rules/no-adjacent-inline-elements.md
@@ -0,0 +1,24 @@
# Prevent adjacent inline elements not separated by whitespace. (no-adjacent-inline-elements)

Adjacent inline elements not separated by whitespace will bump up against each
other when viewed in an unstyled manner, which usually isn't desirable.

## Rule Details

The following patterns are considered warnings:

```jsx
<div><a></a><a></a></div>
<div><a></a><span></span></div>

React.createElement("div", undefined, [React.createElement("a"), React.createElement("span")]);
```

The following patterns are not considered warnings:

```jsx
<div><div></div><div></div></div>
<div><a></a> <a></a></div>

React.createElement("div", undefined, [React.createElement("a"), " ", React.createElement("a")]);
```
3 changes: 3 additions & 0 deletions docs/rules/no-typos.md
Expand Up @@ -86,6 +86,9 @@ class MyComponent extends React.Component {
}
}

class MyComponent extends React.Component {
getDerivedStateFromProps() {}
}
```

The following patterns are **not** considered warnings:
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/prop-types.md
Expand Up @@ -102,14 +102,14 @@ This rule can take one argument to ignore some specific props during validation.

```js
...
"react/prop-types": [<enabled>, { ignore: <ignore>, customValidators: <customValidator> }]
"react/prop-types": [<enabled>, { ignore: <ignore>, customValidators: <customValidator>, skipUndeclared: <skipUndeclared> }]
...
```

* `enabled`: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
* `ignore`: optional array of props name to ignore during validation.
* `customValidators`: optional array of validators used for propTypes validation.
* `skipUndeclared`: only error on components that have a propTypes block declared
* `skipUndeclared`: optional boolean to only error on components that have a propTypes block declared.

### As for "exceptions"

Expand Down

0 comments on commit cf1cf2e

Please sign in to comment.