Skip to content

Commit afaf45b

Browse files
committed
chore: Update eslint to v6
1 parent 3ee35ec commit afaf45b

File tree

6 files changed

+219
-420
lines changed

6 files changed

+219
-420
lines changed

.babelrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@
1111
],
1212
"@babel/preset-flow"
1313
],
14-
"plugins": [
15-
"@babel/plugin-transform-runtime"
16-
]
14+
"plugins": ["@babel/plugin-transform-runtime"]
1715
}

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ module.exports = {
22
parser: 'babel-eslint',
33
extends: ['eslint:recommended', 'prettier'],
44
plugins: ['prettier'],
5+
parserOptions: {
6+
ecmaVersion: 2020,
7+
sourceType: "module"
8+
},
59
rules: {
610
strict: ['error', 'never'],
711
'no-shadow': 'error',

benchmark/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable */
21
const fs = require('fs');
32
const path = require('path');
43
const Table = require('cli-table');

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
"benchmark": "^2.1.4",
6161
"cli-table": "^0.3.1",
6262
"cross-spawn": "^6.0.4",
63-
"eslint": "^5.7.0",
64-
"eslint-config-prettier": "^4.0.0",
63+
"eslint": "^6.8.0",
64+
"eslint-config-prettier": "^6.9.0",
6565
"eslint-plugin-prettier": "^3.1.1",
6666
"flow-bin": "^0.98.0",
6767
"jest": "^24.9.0",

src/utils/getPropType.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ const simplePropTypes = [
186186
'elementType',
187187
];
188188

189-
const propTypes = {
190-
oneOf: getPropTypeOneOf,
191-
oneOfType: getPropTypeOneOfType,
192-
instanceOf: getPropTypeInstanceOf,
193-
arrayOf: getPropTypeArrayOf,
194-
objectOf: getPropTypeObjectOf,
195-
shape: getPropTypeShapish.bind(null, 'shape'),
196-
exact: getPropTypeShapish.bind(null, 'exact'),
197-
};
189+
const propTypes = new Map([
190+
['oneOf', getPropTypeOneOf],
191+
['oneOfType', getPropTypeOneOfType],
192+
['instanceOf', getPropTypeInstanceOf],
193+
['arrayOf', getPropTypeArrayOf],
194+
['objectOf', getPropTypeObjectOf],
195+
['shape', getPropTypeShapish.bind(null, 'shape')],
196+
['exact', getPropTypeShapish.bind(null, 'exact')],
197+
]);
198198

199199
/**
200200
* Tries to identify the prop type by inspecting the path for known
@@ -218,8 +218,8 @@ export default function getPropType(path: NodePath): PropTypeDescriptor {
218218
if (simplePropTypes.includes(name)) {
219219
descriptor = { name };
220220
return true;
221-
} else if (propTypes.hasOwnProperty(name) && member.argumentsPath) {
222-
descriptor = propTypes[name](member.argumentsPath.get(0));
221+
} else if (propTypes.has(name) && member.argumentsPath) {
222+
descriptor = propTypes.get(name)(member.argumentsPath.get(0));
223223
return true;
224224
}
225225
}
@@ -231,9 +231,9 @@ export default function getPropType(path: NodePath): PropTypeDescriptor {
231231
} else if (
232232
t.CallExpression.check(node) &&
233233
t.Identifier.check(node.callee) &&
234-
propTypes.hasOwnProperty(node.callee.name)
234+
propTypes.has(node.callee.name)
235235
) {
236-
descriptor = propTypes[node.callee.name](path.get('arguments', 0));
236+
descriptor = propTypes.get(node.callee.name)(path.get('arguments', 0));
237237
} else {
238238
descriptor = { name: 'custom', raw: printValue(path) };
239239
}

0 commit comments

Comments
 (0)