Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support eslint-plugin-react-hooks@2 #2090

Merged
merged 3 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,47 @@ install:
- 'if [ -n "${PACKAGE-}" ]; then cd "packages/${PACKAGE}"; fi'
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
- 'if [ -n "${ESLINT}" ]; then npm install --no-save "eslint@${ESLINT}"; fi'
- 'if [ -n "${REACT_HOOKS}" ]; then npm install --no-save "eslint-plugin-react-hooks@${REACT_HOOKS}"; fi'
script:
- 'if [ -n "${PREPUBLISH-}" ]; then npm run pretravis && npm run prepublish && npm run posttravis; elif [ -n "${LINT-}" ]; then npm run lint; else npm run travis; fi'
sudo: false
env:
matrix:
- 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb-base'
- 'TEST=true ESLINT=6 PACKAGE=eslint-config-airbnb'
- 'TEST=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb'
- 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base'
- 'TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb'
- 'TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb'
matrix:
fast_finish: true
include:
- node_js: "lts/*"
env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb-base
- node_js: "lts/*"
env: PREPUBLISH=true ESLINT=6 PACKAGE=eslint-config-airbnb
- node_js: "lts/*"
env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb
- node_js: "lts/*"
env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb-base
- node_js: "lts/*"
env: PREPUBLISH=true ESLINT=5 PACKAGE=eslint-config-airbnb
- node_js: "lts/*"
env: PREPUBLISH=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb
- node_js: "lts/*"
env: LINT=true
- node_js: "7"
env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base
- node_js: "7"
env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb
- node_js: "7"
env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb
- node_js: "6"
env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb-base
- node_js: "6"
env: TEST=true ESLINT=5 PACKAGE=eslint-config-airbnb
- node_js: "6"
env: TEST=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb
exclude:
allow_failures:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the two new PREPUBLISH entries under include need equivalent entries under allow_failures here (since currently those runs are failing). eg:

    - env: PREPUBLISH=true ESLINT=6 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb
    - env: PREPUBLISH=true ESLINT=5 REACT_HOOKS=1.7 PACKAGE=eslint-config-airbnb

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don't; they're failing by design on master since new eslint rules have been released that haven't yet been added to the config. I'll rebase your PR after I've fixed it, you don't have to worry about it.

- node_js: "11"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ Other Style Guides

const isJedi = getProp('jedi');
```

<a name="es2016-properties--exponentiation-operator"></a>
- [12.3](#es2016-properties--exponentiation-operator) Use exponentiation operator `**` when calculating exponentiations. eslint: [`no-restricted-properties`](https://eslint.org/docs/rules/no-restricted-properties).

Expand Down Expand Up @@ -1703,6 +1704,7 @@ Other Style Guides
return name;
}
```

<a name="variables--no-chain-assignment"></a><a name="13.5"></a>
- [13.5](#variables--no-chain-assignment) Don’t chain variable assignments. eslint: [`no-multi-assign`](https://eslint.org/docs/rules/no-multi-assign)

Expand Down
3 changes: 2 additions & 1 deletion linters/.markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

"comment": "MD007: Unordered list indentation: 2 spaces.",
"ul-indent": {
"indent": 2
"indent": 2,
"start_indented": true
},

"comment": "MD009: Disallow trailing spaces!",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "A mostly reasonable approach to JavaScript.",
"scripts": {
"preinstall": "npm run install:config && npm run install:config:base",
"postinstall": "rm -rf node_modules/markdownlint-cli/node_modules/markdownlint",
"install:config": "cd packages/eslint-config-airbnb && npm prune && npm install",
"install:config:base": "cd packages/eslint-config-airbnb-base && npm prune && npm install",
"lint": "markdownlint --config linters/.markdownlint.json README.md */README.md",
Expand Down Expand Up @@ -39,6 +40,7 @@
},
"homepage": "https://github.com/airbnb/javascript",
"devDependencies": {
"markdownlint-cli": "^0.13.0"
"markdownlint": "^0.19.0",
"markdownlint-cli": "^0.21.0"
}
}
4 changes: 2 additions & 2 deletions packages/eslint-config-airbnb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^1.7.0",
"eslint-plugin-react-hooks": "^2.0.0 || ^1.7.0",
"in-publish": "^2.0.0",
"react": ">= 0.13.0",
"safe-publish-latest": "^1.1.4",
Expand All @@ -79,7 +79,7 @@
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^1.7.0"
"eslint-plugin-react-hooks": "^2.0.0 || ^1.7.0"
},
"engines": {
"node": ">= 6"
Expand Down
29 changes: 29 additions & 0 deletions packages/eslint-config-airbnb/rules/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,35 @@ module.exports = {
// Enforce that props are read-only
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
'react/prefer-read-only-props': 'off',

// Prevent usage of `javascript:` URLs
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
// TODO: enable, semver-major
'react/jsx-no-script-url': ['off', [
{
name: 'Link',
props: ['to'],
},
]],

// Disallow unnecessary fragments
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
// TODO: enable, semver-major
'react/jsx-no-useless-fragment': 'off',

// Prevent adjacent inline elements not separated by whitespace
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md
// TODO: enable? semver-major
'react/no-adjacent-inline-elements': 'off',

// Enforce a specific function type for function components
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
// TODO: enable! semver-minor, but do it in a major to be safe
// TODO: investigate if setting namedComponents to expression vs declaration is problematic
'react/function-component-definition': ['off', {
namedComponents: 'function-expression',
unnamedComponents: 'function-expression',
}],
},

settings: {
Expand Down
1 change: 1 addition & 0 deletions react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ This style guide is mostly based on the standards that are currently prevalent i
// good
import Footer from './Footer';
```

- **Higher-order Component Naming**: Use a composite of the higher-order component’s name and the passed-in component’s name as the `displayName` on the generated component. For example, the higher-order component `withFoo()`, when passed a component `Bar` should produce a component with a `displayName` of `withFoo(Bar)`.

> Why? A component’s `displayName` may be used by developer tools or in error messages, and having a value that clearly expresses this relationship helps people understand what is happening.
Expand Down