Skip to content

Commit 68ed515

Browse files
pnevykgajus
authored andcommitted
fix: bump versions of babel-eslint, eslint and eslint-config-canonical (#359)
1 parent d2c2411 commit 68ed515

27 files changed

+120
-192
lines changed

Diff for: package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"devDependencies": {
1212
"ajv": "^6.5.0",
1313
"babel-cli": "^6.26.0",
14-
"babel-eslint": "^6.1.2",
14+
"babel-eslint": "^9.0.0",
1515
"babel-plugin-add-module-exports": "^0.2.1",
1616
"babel-plugin-transform-object-rest-spread": "^6.26.0",
1717
"babel-preset-env": "^1.7.0",
1818
"babel-register": "^6.26.0",
1919
"chai": "^4.1.2",
20-
"eslint": "^3.16.0",
21-
"eslint-config-canonical": "1.8.1",
20+
"eslint": "^5.6.0",
21+
"eslint-config-canonical": "^12.0.0",
2222
"gitdown": "^2.5.2",
2323
"glob": "^7.1.2",
2424
"husky": "^0.14.3",

Diff for: src/rules/defineFlowType.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ const create = (context) => {
5757
makeDefined(qid);
5858
}
5959
},
60-
InterfaceDeclaration (node) {
61-
makeDefined(node.id);
62-
},
60+
61+
// Can be removed once https://github.com/babel/babel-eslint/pull/696 is published
6362
OpaqueType (node) {
6463
if (node.id.type === 'Identifier') {
6564
makeDefined(node.id);

Diff for: src/rules/genericSpacing.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {spacingFixers} from './../utilities';
1+
import {spacingFixers} from '../utilities';
22

33
const schema = [
44
{
@@ -16,9 +16,9 @@ const create = (context) => {
1616
GenericTypeAnnotation (node) {
1717
const types = node.typeParameters;
1818

19-
// Promise<foo>
20-
// ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters)
21-
// ^^^ GenericTypeAnnotation (without typeParameters)
19+
// Promise<foo>
20+
// ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters)
21+
// ^^^ GenericTypeAnnotation (without typeParameters)
2222
if (!types) {
2323
return;
2424
}

Diff for: src/rules/newlineAfterFlowAnnotation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const create = (context) => {
3636
context.report({
3737
fix: (fixer) => {
3838
return fixer.insertTextAfter(
39-
potentialFlowFileAnnotation,
40-
newline
41-
);
39+
potentialFlowFileAnnotation,
40+
newline
41+
);
4242
},
4343
message: 'Expected newline after flow annotation',
4444
node

Diff for: src/rules/noDupeKeys.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash/';
22
import {
33
getParameterName
4-
} from './../utilities';
4+
} from '../utilities';
55

66
const schema = [];
77

Diff for: src/rules/noPrimitiveConstructorTypes.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import _ from 'lodash';
33
const schema = [];
44

55
const create = (context) => {
6+
const regex = /^(Boolean|Number|String)$/;
7+
68
return {
79
GenericTypeAnnotation: (node) => {
810
const name = _.get(node, 'id.name');
911

10-
if (RegExp(/^(Boolean|Number|String)$/).test(name)) {
12+
if (regex.test(name)) {
1113
context.report({
1214
data: {
1315
name

Diff for: src/rules/noWeakTypes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const schema = [
44
{
55
additionalProperties: false,
66
properties: {
7-
Function: {
7+
any: {
88
type: 'boolean'
99
},
10-
Object: {
10+
Function: {
1111
type: 'boolean'
1212
},
13-
any: {
13+
Object: {
1414
type: 'boolean'
1515
}
1616
},

Diff for: src/rules/objectTypeDelimiter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// ported from babel/flow-object-type; original author: Nat Mote
2-
// https://github.com/babel/eslint-plugin-babel/blob/c0a49d25a97feb12c1d07073a0b37317359a5fe5/rules/flow-object-type.js
1+
// ported from babel/flow-object-type; original author: Nat Mote
2+
// https://github.com/babel/eslint-plugin-babel/blob/c0a49d25a97feb12c1d07073a0b37317359a5fe5/rules/flow-object-type.js
33

44
const SEMICOLON = {
55
char: ';',

Diff for: src/rules/requireParameterType.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import _ from 'lodash';
22
import {
3-
getParameterName,
4-
iterateFunctionNodes,
5-
quoteName
6-
} from './../utilities';
3+
getParameterName,
4+
iterateFunctionNodes,
5+
quoteName
6+
} from '../utilities';
77

88
const schema = [
99
{

Diff for: src/rules/requireValidFileAnnotation.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import _ from 'lodash';
22
import {
3-
isFlowFileAnnotation,
4-
fuzzyStringMatch
5-
} from './../utilities';
3+
isFlowFileAnnotation,
4+
fuzzyStringMatch
5+
} from '../utilities';
66

77
const defaults = {
88
annotationStyle: 'none'

Diff for: src/rules/requireVariableType.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import _ from 'lodash';
22
import {
3-
isFlowFile,
4-
quoteName
5-
} from './../utilities';
3+
isFlowFile,
4+
quoteName
5+
} from '../utilities';
66

77
const schema = [
88
{

Diff for: src/rules/semi.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const create = (context) => {
1111

1212
const report = (node, missing) => {
1313
const lastToken = sourceCode.getLastToken(node);
14-
let fix, message;
14+
let fix;
15+
let message;
1516
let {loc} = lastToken;
1617

1718
if (missing) {

Diff for: src/rules/sortKeys.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash';
22
import {
33
getParameterName
4-
} from './../utilities';
4+
} from '../utilities';
55

66
const defaults = {
77
caseSensitive: true,

Diff for: src/rules/spaceBeforeGenericBracket.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const create = (context) => {
1414
GenericTypeAnnotation (node) {
1515
const types = node.typeParameters;
1616

17-
// Promise<foo>
18-
// ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters)
19-
// ^^^ GenericTypeAnnotation (without typeParameters)
17+
// Promise<foo>
18+
// ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters)
19+
// ^^^ GenericTypeAnnotation (without typeParameters)
2020
if (!types) {
2121
return;
2222
}

Diff for: src/rules/typeColonSpacing/reporter.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const getSpaces = (direction, colon, context) => {
2222

2323
export default (direction, context, {always, allowLineBreak}) => {
2424
return ({colon, node, name = '', type = 'type annotation'}) => {
25-
let lineBreak, spaces;
25+
let lineBreak;
26+
let spaces;
2627

2728
// Support optional names
2829
// type X = { [string]: a }

Diff for: src/rules/typeImportStyle.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ const create = (context) => {
3939
});
4040
const source = node.source.value;
4141

42-
return fixer.replaceText(node,
43-
'import {' + imports.join(', ') + '} from \'' + source + '\';'
44-
);
42+
return fixer.replaceText(node, 'import {' + imports.join(', ') + '} from \'' + source + '\';');
4543
},
4644
message: 'Unexpected "import type"',
4745
node
@@ -56,4 +54,3 @@ export default {
5654
create,
5755
schema
5856
};
59-

Diff for: src/rules/validSyntax.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import _ from 'lodash';
22
import {
3-
getParameterName,
4-
iterateFunctionNodes,
5-
quoteName
6-
} from './../utilities';
3+
getParameterName,
4+
iterateFunctionNodes,
5+
quoteName
6+
} from '../utilities';
77

88
const schema = [];
99

Diff for: src/utilities/fuzzyStringMatch.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import _ from 'lodash';
22

3-
/**
4-
* Creates an array of letter pairs from a given an array
5-
* https://github.com/d3/d3-array/blob/master/src/pairs.js
6-
*
7-
* @param {any} array
8-
* @returns array
9-
*/
10-
/* eslint-disable */
11-
function d3ArrayPairs (array) {
12-
var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
13-
while (i < n) pairs[i] = [p, p = array[++i]];
3+
// Creates an array of letter pairs from a given array
4+
// origin: https://github.com/d3/d3-array/blob/master/src/pairs.js
5+
const arrayPairs = (array) => {
6+
let ii = 0;
7+
const length = array.length - 1;
8+
let letter = array[0];
9+
const pairs = new Array(length < 0 ? 0 : length);
10+
11+
while (ii < length) {
12+
pairs[ii] = [letter, letter = array[++ii]];
13+
}
14+
1415
return pairs;
1516
};
1617
/* eslint-enable */
@@ -20,8 +21,8 @@ export default (needle, haystack, weight = 0.5) => {
2021

2122
const stringSimilarity = (str1, str2) => {
2223
if (str1.length > 0 && str2.length > 0) {
23-
const pairs1 = d3ArrayPairs(str1);
24-
const pairs2 = d3ArrayPairs(str2);
24+
const pairs1 = arrayPairs(str1);
25+
const pairs2 = arrayPairs(str2);
2526
const unionLen = pairs1.length + pairs2.length;
2627
let hitCount;
2728

Diff for: src/utilities/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import * as spacingFixers from './spacingFixers';
55

66
export {default as checkFlowFileAnnotation} from './checkFlowFileAnnotation';
77
export {default as fuzzyStringMatch} from './fuzzyStringMatch';
8-
export {default as getParameterName} from './getParameterName.js';
8+
export {default as getParameterName} from './getParameterName';
99
export {default as getTokenAfterParens} from './getTokenAfterParens';
1010
export {default as getTokenBeforeParens} from './getTokenBeforeParens';
11-
export {default as isFlowFile} from './isFlowFile.js';
12-
export {default as isFlowFileAnnotation} from './isFlowFileAnnotation.js';
13-
export {default as iterateFunctionNodes} from './iterateFunctionNodes.js';
11+
export {default as isFlowFile} from './isFlowFile';
12+
export {default as isFlowFileAnnotation} from './isFlowFileAnnotation';
13+
export {default as iterateFunctionNodes} from './iterateFunctionNodes';
1414
export {default as quoteName} from './quoteName';
1515

1616
export {

Diff for: src/utilities/isFlowFile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import isFlowFileAnnotation from './isFlowFileAnnotation.js';
1+
import isFlowFileAnnotation from './isFlowFileAnnotation';
22
/* eslint-disable flowtype/require-valid-file-annotation */
33
/**
44
* Checks whether a file has an @flow or @noflow annotation.

Diff for: tests/rules/assertions/defineFlowType.js

+5-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
RuleTester
2+
RuleTester
33
} from 'eslint';
44
import noUndefRule from 'eslint/lib/rules/no-undef';
55

@@ -45,7 +45,7 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [
4545
{
4646
code: 'opaque type A = AType',
4747
errors: [
48-
// Complaining about 'A' not being defined might be an upstream bug
48+
// Complaining about 'A' is fixed in https://github.com/babel/babel-eslint/pull/696
4949
'\'A\' is not defined.',
5050
'\'AType\' is not defined.'
5151
]
@@ -105,12 +105,6 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [
105105
'\'AType\' is not defined.'
106106
]
107107
},
108-
{
109-
code: 'interface AType {}',
110-
errors: [
111-
'\'AType\' is not defined.'
112-
]
113-
},
114108
{
115109
code: 'declare interface A {}',
116110
errors: [
@@ -120,8 +114,8 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [
120114
{
121115
code: '({ a: ({b() {}}: AType) })',
122116

123-
// `AType` appears twice in `globalScope.through` as distinct
124-
// references, this may be a babel-eslint bug.
117+
// `AType` appears twice in `globalScope.through` as distinct
118+
// references, this may be a babel-eslint bug.
125119
errors: [
126120
'\'AType\' is not defined.',
127121
'\'AType\' is not defined.'
@@ -133,13 +127,6 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [
133127
'\'AType\' is not defined.',
134128
'\'BType\' is not defined.'
135129
]
136-
},
137-
{
138-
code: 'interface AType<BType> {}',
139-
errors: [
140-
'\'AType\' is not defined.',
141-
'\'BType\' is not defined.'
142-
]
143130
}
144131
];
145132

@@ -196,7 +183,7 @@ const ALWAYS_VALID = [
196183
parser: 'babel-eslint'
197184
});
198185

199-
ruleTester.run('no-under must not trigger an error in these cases', noUndefRule, {
186+
ruleTester.run('no-undef must not trigger an error in these cases', noUndefRule, {
200187
invalid: [],
201188
valid: ALWAYS_VALID
202189
});

0 commit comments

Comments
 (0)