Skip to content

Commit f466c8c

Browse files
committed
Update ESLint configs and fix warnings/errors
1 parent 7a9170d commit f466c8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+436
-290
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/packages/*/cjs/*.js
2+
/packages/*/esm/*.js
3+
/packages/*/umd/*.js
4+
/website

.eslintrc

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
2-
"parser": "babel-eslint",
3-
"env": {
4-
"node": true
5-
},
6-
"extends": [
7-
"eslint:recommended"
8-
]
2+
extends: ["react-app"],
3+
rules: {
4+
"import/first": 0
5+
}
96
}

package.json

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"scripts": {
55
"build": "node ./scripts/build.js",
66
"clean": "git clean -e '!/website-deploy-key' -e '!/website-deploy-key.pub' -fdX .",
7+
"lint": "eslint .",
78
"start": "node ./scripts/start.js",
89
"test": "jest --projects ./packages/*/"
910
},
@@ -13,12 +14,18 @@
1314
"@babel/plugin-transform-runtime": "^7.5.5",
1415
"@babel/preset-env": "^7.5.5",
1516
"@babel/preset-react": "^7.0.0",
16-
"babel-eslint": "^10.0.3",
17+
"@typescript-eslint/eslint-plugin": "2.x",
18+
"@typescript-eslint/parser": "2.x",
19+
"babel-eslint": "10.x",
1720
"babel-jest": "^24.9.0",
1821
"babel-plugin-dev-expression": "^0.2.2",
19-
"eslint": "^6.3.0",
20-
"eslint-plugin-import": "^2.18.2",
21-
"eslint-plugin-react": "^7.14.3",
22+
"eslint": "6.x",
23+
"eslint-config-react-app": "^5.0.2",
24+
"eslint-plugin-flowtype": "3.x",
25+
"eslint-plugin-import": "2.x",
26+
"eslint-plugin-jsx-a11y": "6.x",
27+
"eslint-plugin-react": "7.x",
28+
"eslint-plugin-react-hooks": "1.x",
2229
"history": "^4.9.0",
2330
"jest": "^24.9.0",
2431
"jest-circus": "^24.9.0",
+5-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
{
2-
"parser": "babel-eslint",
3-
"env": {
4-
"browser": true,
5-
"node": true
2+
env: {
3+
browser: true,
4+
commonjs: true
65
},
7-
"plugins": ["import", "react"],
8-
"extends": [
9-
"eslint:recommended",
10-
"plugin:import/errors",
11-
"plugin:react/recommended"
12-
],
13-
"rules": {
14-
"prefer-arrow-callback": 2,
15-
"react/display-name": 0
16-
},
17-
"settings": {
18-
"react": {
19-
"version": "15"
20-
}
6+
rules: {
7+
strict: 0
218
}
229
}

packages/react-router-config/es/matchRoutes.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("matchRoutes");
53

packages/react-router-config/es/renderRoutes.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("renderRoutes");
53

packages/react-router-config/es/warnAboutDeprecatedESMImport.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"use strict";
2-
1+
/* eslint-disable prefer-arrow-callback, no-empty */
32
var printWarning = function() {};
43

54
if (process.env.NODE_ENV !== "production") {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
env: {
3+
commonjs: false
4+
},
5+
rules: {
6+
strict: 2
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
2-
"env": {
3-
"jest": true
2+
env: {
3+
jest: true
44
},
5-
"rules": {
6-
"import/no-unresolved": [2, { "ignore": ["react-router", "react-router-config"] }],
7-
"react/display-name": 0,
8-
"react/prop-types": 0
5+
rules: {
6+
"no-console": 0
97
}
108
}

packages/react-router-config/modules/__tests__/integration-test.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ describe("integration", () => {
88
it("generates the same matches in renderRoutes and matchRoutes", () => {
99
const rendered = [];
1010

11-
const Comp = ({ match, route: { routes } }) => (
12-
rendered.push(match), renderRoutes(routes)
13-
);
11+
function Comp({ match, route: { routes } }) {
12+
rendered.push(match);
13+
return renderRoutes(routes);
14+
}
1415

1516
const routes = [
1617
{
@@ -60,9 +61,10 @@ describe("integration", () => {
6061
it("generates the same matches in renderRoutes and matchRoutes with pathless routes", () => {
6162
const rendered = [];
6263

63-
const Comp = ({ match, route: { routes } }) => (
64-
rendered.push(match), renderRoutes(routes)
65-
);
64+
function Comp({ match, route: { routes } }) {
65+
rendered.push(match);
66+
return renderRoutes(routes);
67+
}
6668

6769
const routes = [
6870
{
@@ -110,9 +112,10 @@ describe("integration", () => {
110112
it("generates the same matches in renderRoutes and matchRoutes with routes using exact", () => {
111113
const rendered = [];
112114

113-
const Comp = ({ match, route: { routes } }) => (
114-
rendered.push(match), renderRoutes(routes)
115-
);
115+
function Comp({ match, route: { routes } }) {
116+
rendered.push(match);
117+
return renderRoutes(routes);
118+
}
116119

117120
const routes = [
118121
// should skip
@@ -144,9 +147,10 @@ describe("integration", () => {
144147
it("generates the same matches in renderRoutes and matchRoutes with routes using exact + strict", () => {
145148
const rendered = [];
146149

147-
const Comp = ({ match, route: { routes } }) => (
148-
rendered.push(match), renderRoutes(routes)
149-
);
150+
function Comp({ match, route: { routes } }) {
151+
rendered.push(match);
152+
return renderRoutes(routes);
153+
}
150154

151155
const routes = [
152156
// should match

packages/react-router-config/modules/__tests__/renderRoutes-test.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import renderToStringStrict from "./utils/renderToStringStrict.js";
99
describe("renderRoutes", () => {
1010
let renderedRoutes;
1111
let renderedExtraProps;
12-
const Comp = ({ route, route: { routes }, ...extraProps }) => (
13-
renderedRoutes.push(route),
14-
renderedExtraProps.push(extraProps),
15-
renderRoutes(routes)
16-
);
12+
13+
function Comp({ route, route: { routes }, ...extraProps }) {
14+
renderedRoutes.push(route);
15+
renderedExtraProps.push(extraProps);
16+
renderRoutes(routes);
17+
}
1718

1819
beforeEach(() => {
1920
renderedRoutes = [];

packages/react-router-config/warnAboutDeprecatedCJSRequire.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable prefer-arrow-callback, no-empty */
12
"use strict";
23

34
var printWarning = function() {};

packages/react-router-dom/.eslintrc

+7-22
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
{
2-
"parser": "babel-eslint",
3-
"env": {
4-
"browser": true,
5-
"node": true
2+
env: {
3+
browser: true,
4+
commonjs: true
65
},
7-
"plugins": ["import", "react"],
8-
"extends": [
9-
"eslint:recommended",
10-
"plugin:import/errors",
11-
"plugin:react/recommended"
12-
],
13-
"rules": {
14-
"prefer-arrow-callback": 2,
15-
"react/display-name": 0,
16-
"react/no-children-prop": 0,
17-
"react/prop-types": 0
6+
globals: {
7+
__DEV__: true
188
},
19-
"globals": {
20-
"__DEV__": true
21-
},
22-
"settings": {
23-
"react": {
24-
"version": "15"
25-
}
9+
rules: {
10+
strict: 0
2611
}
2712
}

packages/react-router-dom/es/BrowserRouter.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("BrowserRouter");
53

packages/react-router-dom/es/HashRouter.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("HashRouter");
53

packages/react-router-dom/es/Link.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("Link");
53

packages/react-router-dom/es/MemoryRouter.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("MemoryRouter");
53

packages/react-router-dom/es/NavLink.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("NavLink");
53

packages/react-router-dom/es/Prompt.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("Prompt");
53

packages/react-router-dom/es/Redirect.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("Redirect");
53

packages/react-router-dom/es/Route.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("Route");
53

packages/react-router-dom/es/Router.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("Router");
53

packages/react-router-dom/es/StaticRouter.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("StaticRouter");
53

packages/react-router-dom/es/Switch.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("Switch");
53

packages/react-router-dom/es/generatePath.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("generatePath");
53

packages/react-router-dom/es/matchPath.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("matchPath");
53

packages/react-router-dom/es/warnAboutDeprecatedESMImport.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"use strict";
2-
1+
/* eslint-disable prefer-arrow-callback, no-empty */
32
var printWarning = function() {};
43

54
if (process.env.NODE_ENV !== "production") {

packages/react-router-dom/es/withRouter.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"use strict";
2-
31
import warnAboutDeprecatedESMImport from "./warnAboutDeprecatedESMImport.js";
42
warnAboutDeprecatedESMImport("withRouter");
53

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
env: {
3+
commonjs: false
4+
},
5+
rules: {
6+
strict: 2
7+
}
8+
}

packages/react-router-dom/modules/Link.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const LinkAnchor = forwardRef(
5959
props.ref = innerRef;
6060
}
6161

62+
/* eslint-disable-next-line jsx-a11y/anchor-has-content */
6263
return <a {...props} />;
6364
}
6465
);
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
2-
"env": {
3-
"jest": true
2+
env: {
3+
jest: true
44
},
5-
"rules": {
6-
"import/no-unresolved": [2, { "ignore": ["react-router-dom"] }],
7-
"no-console": 0,
8-
"react/display-name": 0,
9-
"react/prop-types": 0
5+
rules: {
6+
"no-console": 0
107
}
118
}

packages/react-router-dom/warnAboutDeprecatedCJSRequire.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable prefer-arrow-callback, no-empty */
12
"use strict";
23

34
var printWarning = function() {};
+2-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
{
2-
plugins: ["react"],
3-
extends: ["plugin:react/recommended"],
4-
rules: {
5-
"no-unused-vars": [1, { ignoreRestSiblings: true }],
6-
"react/display-name": 0,
7-
"react/no-children-prop": 0,
8-
"react/no-unescaped-entities": 0,
9-
"react/prop-types": 0
10-
},
11-
settings: {
12-
react: {
13-
version: "16"
14-
}
2+
globals: {
3+
__DEV__: true
154
}
165
}

packages/react-router-native/Link.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
44

55
import { __RouterContext as RouterContext } from "react-router";
66

7-
class Link extends React.Component {
7+
export default class Link extends React.Component {
88
static defaultProps = {
99
component: TouchableHighlight,
1010
replace: false
@@ -50,5 +50,3 @@ if (__DEV__) {
5050
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
5151
};
5252
}
53-
54-
export default Link;

0 commit comments

Comments
 (0)