Skip to content

Commit

Permalink
[eslint] switch to @babel/eslint-parser, fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Nov 3, 2022
1 parent d39e496 commit 219cf8c
Show file tree
Hide file tree
Showing 47 changed files with 138 additions and 156 deletions.
49 changes: 0 additions & 49 deletions .eslintignore

This file was deleted.

46 changes: 29 additions & 17 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
"env": {
"node": true,
},
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"ignorePatterns": [
"/build",
"_book",
"packages/*/build/",
// Temporarily copied
"packages/*/LICENSE.md",
"packages/enzyme/README.md",
"packages/enzyme-adapter-react-*/README.md",
"packages/enzyme-adapter-utils*/README.md",
],
"rules": {
"id-length": 0,
"react/no-find-dom-node": 1,
Expand All @@ -23,43 +33,45 @@
"devDependencies": true,
}],
"comma-dangle": [2, {
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
functions: "ignore",
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore",
}],
"strict": [2, "safe"],
"prefer-destructuring": 0,
"prefer-template": 0,
},
"parserOptions": {
sourceType: "script",
"sourceType": "script",
},
},
{
"files": [
"*.md",
"**/*.md",
"**/*.md/**"
],
"plugins": [
"markdown"
],
"extends": ["plugin:markdown/recommended"],
"rules": {
"class-methods-use-this": 0,
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0,
"import/extensions": 0,
"import/no-extraneous-dependencies": 0,
"import/no-unresolved": 0,
"import/prefer-default-export": 0,
"max-len": 0,
"no-unused-vars": 0,
"no-console": 0,
"no-undef": 0,
"react/react-in-jsx-scope": 0,
"no-unused-vars": 0,
"react/jsx-filename-extension": 0,
"react/jsx-fragments": 0,
"react/jsx-no-undef": 0,
"react/no-multi-comp": 0,
"react/jsx-no-useless-fragment": 0,
"react/jsx-one-expression-per-line": 0,
"react/jsx-fragments": 0,
"react/no-multi-comp": 0,
"react/no-unknown-property": 0,
"react/no-unused-class-component-methods": 0,
"react/react-in-jsx-scope": 0,
},
},
],
Expand Down
1 change: 0 additions & 1 deletion docs/api/ReactWrapper/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This method is a reliable way of accessing the props of a node; `wrapper.instanc

#### Example
```jsx

import PropTypes from 'prop-types';

function MyComponent(props) {
Expand Down
24 changes: 13 additions & 11 deletions docs/api/ReactWrapper/renderProp.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@ Mouse.propTypes = {
```

```jsx
const App = () => (
<div style={{ height: '100%' }}>
<Mouse
render={(x = 0, y = 0) => (
<h1>
The mouse position is ({x}, {y})
</h1>
)}
/>
</div>
);
function App() {
return (
<div style={{ height: '100%' }}>
<Mouse
render={(x = 0, y = 0) => (
<h1>
The mouse position is ({x}, {y})
</h1>
)}
/>
</div>
);
}
```

##### Testing with no arguments
Expand Down
14 changes: 8 additions & 6 deletions docs/api/ReactWrapper/simulate.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ expect(wrapper.find('.clicks-1').length).to.equal(1);
#### Example `functional component`

```jsx
const Foo = ({ width, height, onChange }) => (
<div>
<input name="width" value={width} onChange={onChange} />
<input name="height" value={height} onChange={onChange} />
</div>
);
function Foo({ width, height, onChange }) {
return (
<div>
<input name="width" value={width} onChange={onChange} />
<input name="height" value={height} onChange={onChange} />
</div>
);
}
Foo.propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
Expand Down
2 changes: 0 additions & 2 deletions docs/api/ReactWrapper/simulateError.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,3 @@ expect(spy.args).to.deep.equal([
},
]);
```


1 change: 0 additions & 1 deletion docs/api/ShallowWrapper/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ This method is a reliable way of accessing the props of a node; `wrapper.instanc

#### Example
```jsx

import PropTypes from 'prop-types';

function MyComponent(props) {
Expand Down
24 changes: 13 additions & 11 deletions docs/api/ShallowWrapper/renderProp.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@ Mouse.propTypes = {
```

```jsx
const App = () => (
<div style={{ height: '100%' }}>
<Mouse
render={(x = 0, y = 0) => (
<h1>
The mouse position is ({x}, {y})
</h1>
)}
/>
</div>
);
function App() {
return (
<div style={{ height: '100%' }}>
<Mouse
render={(x = 0, y = 0) => (
<h1>
The mouse position is ({x}, {y})
</h1>
)}
/>
</div>
);
}
```

##### Testing with no arguments
Expand Down
14 changes: 8 additions & 6 deletions docs/api/ShallowWrapper/simulate.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ expect(wrapper.find('.clicks-1').length).to.equal(1);
#### Example `functional component`

```jsx
const Foo = ({ width, height, onChange }) => (
<div>
<input name="width" value={width} onChange={onChange} />
<input name="height" value={height} onChange={onChange} />
</div>
);
function Foo({ width, height, onChange }) {
return (
<div>
<input name="width" value={width} onChange={onChange} />
<input name="height" value={height} onChange={onChange} />
</div>
);
}
Foo.propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
Expand Down
4 changes: 1 addition & 3 deletions docs/api/ShallowWrapper/simulateError.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,4 @@ expect(spy.args).to.deep.equal([
in WrapperComponent`,
},
]);
```


```
1 change: 0 additions & 1 deletion docs/api/shallow.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('<MyComponent />', () => {
expect(onButtonClick).to.have.property('callCount', 1);
});
});

```

## `shallow(node[, options]) => ShallowWrapper`
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/lab.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Code = require('code');
const Lab = require('lab');

const lab = Lab.script();
exports.lab = lab;
export { lab };

lab.suite('A suite', () => {
lab.test('calls componentDidMount', (done) => {
Expand Down
14 changes: 9 additions & 5 deletions docs/guides/migration-from-2-to-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ const ICONS = {
failure: <Icon name="exclamation-mark" />,
};

const StatusLabel = ({ id, label }) => <div>{ICONS[id]}{label}{ICONS[id]}</div>;
function StatusLabel({ id, label }) {
return <div>{ICONS[id]}{label}{ICONS[id]}</div>;
}
```

```js
Expand Down Expand Up @@ -504,11 +506,13 @@ Consider this example:
<!-- eslint react/prop-types: 0, react/prefer-stateless-function: 0, react/jsx-props-no-spreading: 0 -->

```js
const HelpLink = ({ text, ...rest }) => <a {...rest}>{text}</a>;
function HelpLink({ text, ...rest }) {
return <a {...rest}>{text}</a>;
}

const HelpLinkContainer = ({ text, ...rest }) => (
<HelpLink text={text} {...rest} />
);
function HelpLinkContainer({ text, ...rest }) {
return <HelpLink text={text} {...rest} />;
}

const wrapper = mount(<HelpLinkContainer aria-expanded="true" text="foo" />);
```
Expand Down
3 changes: 1 addition & 2 deletions docs/guides/mocha.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ describe('<Foo />', () => {
expect(Foo.prototype.componentDidMount).to.have.property('callCount', 1);
});
});

```
```
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"clean": "lerna run clean",
"prelint": "npm run lint:root",
"lint": "lerna exec --parallel 'npm run lint -- --quiet'",
"lint:root": "eslint . --ext=js,md,jsx --ignore-pattern=packages/ --ignore-path .eslintignore",
"lint:root": "eslint . --ext=js,md,jsx --ignore-pattern=packages/",
"check": "lerna run lint && npm run test:all",
"prebuild": "npm run clean",
"build": "lerna run build",
Expand Down Expand Up @@ -62,20 +62,20 @@
"devDependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"@babel/eslint-parser": "^7.19.1",
"@babel/node": "^7.19.1",
"@babel/register": "^7.18.9",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"chai": "^4.3.4",
"eslint": "^8.24.0",
"eslint": "^8.26.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react": "^7.31.10",
"eslint-plugin-react-hooks": "^4.6.0",
"gitbook-cli": "^1.0.1",
"gitbook-plugin-anchors": "^0.7.1",
Expand Down
5 changes: 3 additions & 2 deletions packages/enzyme-adapter-react-13/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "airbnb",
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"root": true,
"ignorePatterns": ["build/"],
"rules": {
"max-classes-per-file": 0,
"max-classes-per-file": 0,
"max-len": 0,
"react/no-find-dom-node": 0,
"react/no-multi-comp": 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme-adapter-react-13/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"devDependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"@babel/eslint-parser": "^7.19.1",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/enzyme-adapter-react-14/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "airbnb",
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"root": true,
"ignorePatterns": ["build/"],
"rules": {
"max-len": 0,
"react/no-find-dom-node": 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme-adapter-react-14/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"devDependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"babel-eslint": "^10.1.0",
"@babel/eslint-parser": "^7.19.1",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
Expand Down

0 comments on commit 219cf8c

Please sign in to comment.