Browse code
Adjust lint rules and fix lint issues
Ed Langley authored on 14/05/2019 06:42:28
Showing 5 changed files
Showing 5 changed files
- package.json
- src/action-link.js
- src/action-router.js
- src/change-url-event.js
- src/tests/action-router.test.js
... | ... |
@@ -12,15 +12,17 @@ |
12 | 12 |
"main": "dist/index.js", |
13 | 13 |
"version": "1.0.2", |
14 | 14 |
"license": "MIT", |
15 |
- "dependencies": { |
|
16 |
- "node": "^10.15.3", |
|
17 |
- "ramda": "^0.25.0", |
|
15 |
+ "peerDependencies": { |
|
18 | 16 |
"redux": "^4.0.0" |
19 | 17 |
}, |
18 |
+ "dependencies": { |
|
19 |
+ "ramda": "^0.25.0" |
|
20 |
+ }, |
|
20 | 21 |
"optionalDependencies": { |
21 | 22 |
"prop-types": "^15.5.10" |
22 | 23 |
}, |
23 | 24 |
"devDependencies": { |
25 |
+ "node": "^10.15.3", |
|
24 | 26 |
"@babel/cli": "^7.0.0", |
25 | 27 |
"@babel/core": "7.2.2", |
26 | 28 |
"@babel/plugin-proposal-class-properties": "^7.0.0", |
... | ... |
@@ -30,11 +32,9 @@ |
30 | 32 |
"@babel/plugin-transform-react-jsx": "^7.0.0", |
31 | 33 |
"@babel/preset-env": "^7.0.0", |
32 | 34 |
"@babel/preset-flow": "^7.0.0", |
33 |
- "@svgr/webpack": "4.1.0", |
|
34 | 35 |
"babel-core": "7.0.0-bridge.0", |
35 | 36 |
"babel-eslint": "9.0.0", |
36 | 37 |
"babel-jest": "23.6.0", |
37 |
- "babel-loader": "8.0.5", |
|
38 | 38 |
"babel-plugin-named-asset-import": "^0.3.1", |
39 | 39 |
"babel-preset-react-app": "^7.0.2", |
40 | 40 |
"bfj": "6.1.1", |
... | ... |
@@ -46,18 +46,14 @@ |
46 | 46 |
"enzyme-to-json": "^3.3.4", |
47 | 47 |
"eslint": "5.12.0", |
48 | 48 |
"eslint-config-react-app": "^3.0.8", |
49 |
- "eslint-loader": "2.1.1", |
|
50 | 49 |
"eslint-plugin-flowtype": "2.50.1", |
51 | 50 |
"eslint-plugin-import": "2.14.0", |
52 | 51 |
"eslint-plugin-jsx-a11y": "6.1.2", |
53 | 52 |
"eslint-plugin-react": "7.12.4", |
54 |
- "file-loader": "2.0.0", |
|
55 | 53 |
"flow": "^0.2.3", |
56 | 54 |
"flow-bin": "^0.82.0", |
57 | 55 |
"flow-typed": "^2.5.1", |
58 | 56 |
"fs-extra": "7.0.1", |
59 |
- "html-webpack-plugin": "4.0.0-alpha.2", |
|
60 |
- "identity-obj-proxy": "3.0.0", |
|
61 | 57 |
"jest": "23.6.0", |
62 | 58 |
"jest-pnp-resolver": "1.0.2", |
63 | 59 |
"jest-resolve": "23.6.0", |
... | ... |
@@ -67,14 +63,16 @@ |
67 | 63 |
"react": "^16.5.2", |
68 | 64 |
"react-app-polyfill": "^1.0.1", |
69 | 65 |
"react-dom": "^16.5.2", |
70 |
- "react-test-renderer": "^16.5.2" |
|
66 |
+ "react-test-renderer": "^16.5.2", |
|
67 |
+ "redux": "^4.0.0" |
|
71 | 68 |
}, |
72 | 69 |
"scripts": { |
73 | 70 |
"build": "npx babel src -d dist", |
74 | 71 |
"watch": "npx babel -w src -d dist", |
75 | 72 |
"test": "node scripts/test.js --env=jsdom", |
76 | 73 |
"flow": "flow", |
77 |
- "buildPub": "yarn build && npm publish" |
|
74 |
+ "buildPub": "yarn build && npm publish", |
|
75 |
+ "lint": "eslint src" |
|
78 | 76 |
}, |
79 | 77 |
"npmFileMap": [{ |
80 | 78 |
"basePath": "/dist/", |
... | ... |
@@ -133,6 +131,30 @@ |
133 | 131 |
] |
134 | 132 |
}, |
135 | 133 |
"eslintConfig": { |
136 |
- "extends": "react-app" |
|
134 |
+ "extends": [ |
|
135 |
+ "eslint:recommended", |
|
136 |
+ "plugin:react/recommended" |
|
137 |
+ ], |
|
138 |
+ "env": { |
|
139 |
+ "browser": true, |
|
140 |
+ "node": true, |
|
141 |
+ "jest": true, |
|
142 |
+ "es6": true |
|
143 |
+ }, |
|
144 |
+ "parserOptions": { |
|
145 |
+ "ecmaVersion": 2018, |
|
146 |
+ "sourceType": "module" |
|
147 |
+ }, |
|
148 |
+ "settings": { |
|
149 |
+ "react": { |
|
150 |
+ "version": "16.0" |
|
151 |
+ } |
|
152 |
+ }, |
|
153 |
+ "rules": { |
|
154 |
+ "no-unused-vars": ["error", { |
|
155 |
+ "argsIgnorePattern": "(^[_][_]*$)|(^.$)", |
|
156 |
+ "varsIgnorePattern": "(^[_][_]*$)|(^R$)" |
|
157 |
+ }] |
|
158 |
+ } |
|
137 | 159 |
} |
138 | 160 |
} |
... | ... |
@@ -36,9 +36,15 @@ const ActionLink = ({ action, children, ...props }, { store }) => { |
36 | 36 |
try { |
37 | 37 |
React = require("react"); |
38 | 38 |
PropTypes = require("prop-types"); |
39 |
+ ActionLink.propTypes = { |
|
40 |
+ action: PropTypes.string, |
|
41 |
+ children: PropTypes.node |
|
42 |
+ }; |
|
39 | 43 |
ActionLink.contextTypes = { |
40 | 44 |
store: PropTypes.object |
41 | 45 |
}; |
42 |
-} catch (e) {} |
|
46 |
+} catch (e) { |
|
47 |
+ /* empty */ |
|
48 |
+} |
|
43 | 49 |
|
44 | 50 |
export default ActionLink; |
... | ... |
@@ -43,7 +43,7 @@ function matchRoute(loc, matchers) { |
43 | 43 |
Object.assign({ extractedParams }, route); |
44 | 44 |
|
45 | 45 |
return R.toPairs(matchers).reduce( |
46 |
- (match, [path, { type: matcherType, route }]) => { |
|
46 |
+ (match, [_, { type: matcherType, route }]) => { |
|
47 | 47 |
const pathMatcher = route.routeMatcher; |
48 | 48 |
const matchedParams = pathMatcher(inputPath); |
49 | 49 |
|
... | ... |
@@ -393,9 +393,11 @@ export default function installBrowserRouter(routesConfig, window) { |
393 | 393 |
const actionDispatcher = createActionDispatcher(routesConfig, window); |
394 | 394 |
|
395 | 395 |
const middleware = x => { |
396 |
+ //eslint-disable-next-line no-console |
|
396 | 397 |
console.warn( |
397 |
- "Using the routedux middleware directly is deprecated, the enhancer now applies it automatically" + |
|
398 |
- " and the middleware is now a no-op that will be removed in later versions." |
|
398 |
+ "Using the routedux middleware directly is deprecated, the enhancer now" + |
|
399 |
+ " applies it automatically and the middleware is now a no-op that" + |
|
400 |
+ " will be removed in later versions." |
|
399 | 401 |
); |
400 | 402 |
return y => y; |
401 | 403 |
}; |
... | ... |
@@ -16,7 +16,7 @@ export default function addChangeUrlEvent(window) { |
16 | 16 |
debounce(window, MISSING_CHANGE_URL, () => { |
17 | 17 |
const changeUrlEventCreator = { |
18 | 18 |
lastLocation: null, |
19 |
- handleEvent(ev) { |
|
19 |
+ handleEvent(_) { |
|
20 | 20 |
// interface for EventListener |
21 | 21 |
|
22 | 22 |
let { hash, host, hostname, origin, href, pathname, port, protocol } = |
... | ... |
@@ -4,7 +4,9 @@ import installBrowserRouter from "../action-router"; |
4 | 4 |
import addChangeUrlEvent from "../change-url-event.js"; |
5 | 5 |
import addMissingHistoryEvents from "../history-events.js"; |
6 | 6 |
|
7 |
+//eslint-disable-next-line no-console |
|
7 | 8 |
const console_log = console.log; |
9 |
+//eslint-disable-next-line no-console |
|
8 | 10 |
console.log = () => {}; |
9 | 11 |
// function with_console(cb) { |
10 | 12 |
// console.log = console_log; |
... | ... |
@@ -376,4 +378,5 @@ it("pathForAction should render a route", () => { |
376 | 378 |
expect(actual).toEqual("/something/hooray"); |
377 | 379 |
}); |
378 | 380 |
|
381 |
+//eslint-disable-next-line no-console |
|
379 | 382 |
console.log = console_log; |