Skip to content

Commit d97f3ea

Browse files
Update ESLint (#187)
* Minor eslint cleanup * Add import sorting
1 parent 4c4ec06 commit d97f3ea

File tree

55 files changed

+432
-122
lines changed

Some content is hidden

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

55 files changed

+432
-122
lines changed

.eslintrc.js

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,86 @@
11
module.exports = {
2-
parser: '@babel/eslint-parser',
32
env: {
43
browser: true,
54
es6: true,
65
node: true,
76
},
87
extends: [
98
'eslint:recommended',
9+
'plugin:import/recommended',
1010
'plugin:react/recommended',
1111
'plugin:prettier/recommended',
1212
],
13+
globals: {
14+
// enable webpack require
15+
require: 'readonly',
16+
// fix for eslint-plugin-flowtype/384 not supporting wildcard
17+
_: 'readonly',
18+
},
19+
parser: '@babel/eslint-parser',
1320
parserOptions: {
1421
ecmaFeatures: {
1522
jsx: true,
1623
},
1724
ecmaVersion: 2018,
1825
sourceType: 'module',
1926
},
20-
settings: {
21-
react: {
22-
version: 'detect',
23-
},
24-
},
25-
globals: {
26-
// enable webpack require
27-
require: 'readonly',
28-
// fix for eslint-plugin-flowtype/384 not supporting wildcard
29-
_: 'readonly',
30-
},
3127
plugins: ['react', 'react-hooks', 'import'],
3228
rules: {
33-
'no-shadow': ['error'],
34-
indent: ['off'],
35-
'linebreak-style': ['off'],
36-
quotes: ['off'],
37-
semi: ['off'],
38-
'newline-before-return': ['error'],
39-
'prettier/prettier': ['warn'],
40-
'react/no-direct-mutation-state': ['off'],
41-
'react/display-name': ['off'],
42-
'react-hooks/rules-of-hooks': ['error'],
43-
'react-hooks/exhaustive-deps': ['warn'],
44-
'react/prop-types': ['off'],
29+
'import/order': [
30+
'error',
31+
{
32+
alphabetize: {
33+
order: 'asc',
34+
},
35+
'newlines-between': 'always',
36+
},
37+
],
38+
indent: 'off',
39+
'linebreak-style': 'off',
40+
'newline-before-return': 'error',
41+
'no-shadow': 'error',
42+
'prettier/prettier': 'warn',
43+
quotes: 'off',
44+
'react/display-name': 'off',
45+
'react/no-direct-mutation-state': 'off',
46+
'react/prop-types': 'off',
47+
'react-hooks/exhaustive-deps': 'warn',
48+
'react-hooks/rules-of-hooks': 'error',
49+
semi: 'off',
4550
},
4651
overrides: [
4752
{
4853
// Flow specific rules
49-
files: [
50-
'src/index.js.flow',
51-
'src/server/index.js.flow',
52-
'*/*flow.js',
53-
'examples/*-flow/*/*.js',
54-
],
5554
extends: ['plugin:flowtype/recommended'],
55+
files: ['*.flow'],
5656
plugins: ['flowtype'],
5757
rules: {
58-
'flowtype/generic-spacing': ['off'],
58+
'flowtype/generic-spacing': 'off',
5959
},
6060
},
6161
{
6262
// TypeScript specific rules
6363
files: ['*.{ts,tsx}'],
64-
extends: ['plugin:@typescript-eslint/recommended'],
64+
extends: [
65+
'plugin:@typescript-eslint/recommended',
66+
'plugin:import/typescript',
67+
],
6568
rules: {
66-
'@typescript-eslint/explicit-function-return-type': 'off',
67-
'@typescript-eslint/no-use-before-define': 'off',
68-
'@typescript-eslint/no-explicit-any': 'off',
69-
'@typescript-eslint/no-implicit-any': 'off',
70-
'@typescript-eslint/explicit-member-accessibility': 'off',
71-
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
72-
'@typescript-eslint/no-non-null-assertion': 'off',
73-
'@typescript-eslint/no-empty-interface': 'off',
7469
'@typescript-eslint/ban-ts-comment': 'off',
7570
'@typescript-eslint/no-empty-function': 'off',
71+
'@typescript-eslint/no-empty-interface': 'off',
72+
'@typescript-eslint/no-explicit-any': 'off',
73+
'@typescript-eslint/no-non-null-assertion': 'off',
7674
'@typescript-eslint/no-unused-vars': [
7775
'error',
7876
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
7977
],
78+
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
79+
},
80+
settings: {
81+
'import/resolver': {
82+
typescript: true,
83+
},
8084
},
8185
},
8286
{
@@ -87,4 +91,9 @@ module.exports = {
8791
},
8892
},
8993
],
94+
settings: {
95+
react: {
96+
version: 'detect',
97+
},
98+
},
9099
};

examples/basic-routing/about.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
23
import { Link } from 'react-resource-router';
34

45
export const About = () => (

examples/basic-routing/home.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
23
import { Link } from 'react-resource-router';
34

45
export const Home = () => (

examples/basic-routing/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import { render } from 'react-dom';
3+
4+
import { About } from './about';
5+
import { Home } from './home';
36

47
import {
58
Router,
69
RouteComponent,
710
createBrowserHistory,
811
} from 'react-resource-router';
912

10-
import { Home } from './home';
11-
import { About } from './about';
12-
1313
const myHistory = createBrowserHistory();
1414

1515
const appRoutes = [
@@ -37,4 +37,4 @@ const App = () => {
3737
);
3838
};
3939

40-
ReactDOM.render(<App />, document.getElementById('root'));
40+
render(<App />, document.getElementById('root'));

examples/hooks/home.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
23
import { Link } from 'react-resource-router';
34

45
const Home = () => {

examples/hooks/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import { render } from 'react-dom';
3+
4+
import Home from './home';
5+
import PathParamExample from './use-path-param';
6+
import QueryParamExample from './use-query-param';
37

48
import {
59
Router,
@@ -8,10 +12,6 @@ import {
812
createRouterSelector,
913
} from 'react-resource-router';
1014

11-
import Home from './home';
12-
import QueryParamExample from './use-query-param';
13-
import PathParamExample from './use-path-param';
14-
1515
const myHistory = createBrowserHistory();
1616
const useRouteName = createRouterSelector(s => s.route.name);
1717

@@ -54,4 +54,4 @@ const App = () => {
5454
);
5555
};
5656

57-
ReactDOM.render(<App />, document.getElementById('root'));
57+
render(<App />, document.getElementById('root'));

examples/hooks/use-path-param.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
23
import { Link, usePathParam } from 'react-resource-router';
34

45
const randomStr = (length: number) => {

examples/hooks/use-query-param.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
23
import { Link, useQueryParam } from 'react-resource-router';
34

45
const randomStr = (length: number) => {

examples/hydration/home.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
23
import { createResource, useResource } from 'react-resource-router';
34

45
export const homeResource = createResource({

examples/hydration/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
2+
import { render } from 'react-dom';
33
import { defaultRegistry } from 'react-sweet-state';
44

5+
import { homeRoute } from './routes';
6+
57
import {
68
Router,
79
RouteComponent,
810
createBrowserHistory,
911
StaticRouter,
1012
} from 'react-resource-router';
1113

12-
import { homeRoute } from './routes';
13-
1414
const myHistory = createBrowserHistory();
1515

1616
const appRoutes = [homeRoute];
@@ -45,7 +45,7 @@ const main = async () => {
4545
);
4646
};
4747

48-
ReactDOM.render(<App />, document.getElementById('root'));
48+
render(<App />, document.getElementById('root'));
4949
};
5050

5151
main();

0 commit comments

Comments
 (0)