Skip to content

Commit

Permalink
fix: bump versions of babel-eslint, eslint and eslint-config-canonical (
Browse files Browse the repository at this point in the history
  • Loading branch information
pnevyk authored and gajus committed Sep 27, 2018
1 parent d2c2411 commit 68ed515
Show file tree
Hide file tree
Showing 27 changed files with 120 additions and 192 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"devDependencies": {
"ajv": "^6.5.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^6.1.2",
"babel-eslint": "^9.0.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0",
"chai": "^4.1.2",
"eslint": "^3.16.0",
"eslint-config-canonical": "1.8.1",
"eslint": "^5.6.0",
"eslint-config-canonical": "^12.0.0",
"gitdown": "^2.5.2",
"glob": "^7.1.2",
"husky": "^0.14.3",
Expand Down
5 changes: 2 additions & 3 deletions src/rules/defineFlowType.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ const create = (context) => {
makeDefined(qid);
}
},
InterfaceDeclaration (node) {
makeDefined(node.id);
},

// Can be removed once https://github.com/babel/babel-eslint/pull/696 is published
OpaqueType (node) {
if (node.id.type === 'Identifier') {
makeDefined(node.id);
Expand Down
8 changes: 4 additions & 4 deletions src/rules/genericSpacing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {spacingFixers} from './../utilities';
import {spacingFixers} from '../utilities';

const schema = [
{
Expand All @@ -16,9 +16,9 @@ const create = (context) => {
GenericTypeAnnotation (node) {
const types = node.typeParameters;

// Promise<foo>
// ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters)
// ^^^ GenericTypeAnnotation (without typeParameters)
// Promise<foo>
// ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters)
// ^^^ GenericTypeAnnotation (without typeParameters)
if (!types) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/rules/newlineAfterFlowAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const create = (context) => {
context.report({
fix: (fixer) => {
return fixer.insertTextAfter(
potentialFlowFileAnnotation,
newline
);
potentialFlowFileAnnotation,
newline
);
},
message: 'Expected newline after flow annotation',
node
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noDupeKeys.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash/';
import {
getParameterName
} from './../utilities';
} from '../utilities';

const schema = [];

Expand Down
4 changes: 3 additions & 1 deletion src/rules/noPrimitiveConstructorTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import _ from 'lodash';
const schema = [];

const create = (context) => {
const regex = /^(Boolean|Number|String)$/;

return {
GenericTypeAnnotation: (node) => {
const name = _.get(node, 'id.name');

if (RegExp(/^(Boolean|Number|String)$/).test(name)) {
if (regex.test(name)) {
context.report({
data: {
name
Expand Down
6 changes: 3 additions & 3 deletions src/rules/noWeakTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const schema = [
{
additionalProperties: false,
properties: {
Function: {
any: {
type: 'boolean'
},
Object: {
Function: {
type: 'boolean'
},
any: {
Object: {
type: 'boolean'
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/rules/objectTypeDelimiter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ported from babel/flow-object-type; original author: Nat Mote
// https://github.com/babel/eslint-plugin-babel/blob/c0a49d25a97feb12c1d07073a0b37317359a5fe5/rules/flow-object-type.js
// ported from babel/flow-object-type; original author: Nat Mote
// https://github.com/babel/eslint-plugin-babel/blob/c0a49d25a97feb12c1d07073a0b37317359a5fe5/rules/flow-object-type.js

const SEMICOLON = {
char: ';',
Expand Down
8 changes: 4 additions & 4 deletions src/rules/requireParameterType.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import _ from 'lodash';
import {
getParameterName,
iterateFunctionNodes,
quoteName
} from './../utilities';
getParameterName,
iterateFunctionNodes,
quoteName
} from '../utilities';

const schema = [
{
Expand Down
6 changes: 3 additions & 3 deletions src/rules/requireValidFileAnnotation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _ from 'lodash';
import {
isFlowFileAnnotation,
fuzzyStringMatch
} from './../utilities';
isFlowFileAnnotation,
fuzzyStringMatch
} from '../utilities';

const defaults = {
annotationStyle: 'none'
Expand Down
6 changes: 3 additions & 3 deletions src/rules/requireVariableType.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _ from 'lodash';
import {
isFlowFile,
quoteName
} from './../utilities';
isFlowFile,
quoteName
} from '../utilities';

const schema = [
{
Expand Down
3 changes: 2 additions & 1 deletion src/rules/semi.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const create = (context) => {

const report = (node, missing) => {
const lastToken = sourceCode.getLastToken(node);
let fix, message;
let fix;
let message;
let {loc} = lastToken;

if (missing) {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/sortKeys.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import {
getParameterName
} from './../utilities';
} from '../utilities';

const defaults = {
caseSensitive: true,
Expand Down
6 changes: 3 additions & 3 deletions src/rules/spaceBeforeGenericBracket.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const create = (context) => {
GenericTypeAnnotation (node) {
const types = node.typeParameters;

// Promise<foo>
// ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters)
// ^^^ GenericTypeAnnotation (without typeParameters)
// Promise<foo>
// ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters)
// ^^^ GenericTypeAnnotation (without typeParameters)
if (!types) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/rules/typeColonSpacing/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const getSpaces = (direction, colon, context) => {

export default (direction, context, {always, allowLineBreak}) => {
return ({colon, node, name = '', type = 'type annotation'}) => {
let lineBreak, spaces;
let lineBreak;
let spaces;

// Support optional names
// type X = { [string]: a }
Expand Down
5 changes: 1 addition & 4 deletions src/rules/typeImportStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ const create = (context) => {
});
const source = node.source.value;

return fixer.replaceText(node,
'import {' + imports.join(', ') + '} from \'' + source + '\';'
);
return fixer.replaceText(node, 'import {' + imports.join(', ') + '} from \'' + source + '\';');
},
message: 'Unexpected "import type"',
node
Expand All @@ -56,4 +54,3 @@ export default {
create,
schema
};

8 changes: 4 additions & 4 deletions src/rules/validSyntax.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import _ from 'lodash';
import {
getParameterName,
iterateFunctionNodes,
quoteName
} from './../utilities';
getParameterName,
iterateFunctionNodes,
quoteName
} from '../utilities';

const schema = [];

Expand Down
27 changes: 14 additions & 13 deletions src/utilities/fuzzyStringMatch.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import _ from 'lodash';

/**
* Creates an array of letter pairs from a given an array
* https://github.com/d3/d3-array/blob/master/src/pairs.js
*
* @param {any} array
* @returns array
*/
/* eslint-disable */
function d3ArrayPairs (array) {
var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
while (i < n) pairs[i] = [p, p = array[++i]];
// Creates an array of letter pairs from a given array
// origin: https://github.com/d3/d3-array/blob/master/src/pairs.js
const arrayPairs = (array) => {
let ii = 0;
const length = array.length - 1;
let letter = array[0];
const pairs = new Array(length < 0 ? 0 : length);

while (ii < length) {
pairs[ii] = [letter, letter = array[++ii]];
}

return pairs;
};
/* eslint-enable */
Expand All @@ -20,8 +21,8 @@ export default (needle, haystack, weight = 0.5) => {

const stringSimilarity = (str1, str2) => {
if (str1.length > 0 && str2.length > 0) {
const pairs1 = d3ArrayPairs(str1);
const pairs2 = d3ArrayPairs(str2);
const pairs1 = arrayPairs(str1);
const pairs2 = arrayPairs(str2);
const unionLen = pairs1.length + pairs2.length;
let hitCount;

Expand Down
8 changes: 4 additions & 4 deletions src/utilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import * as spacingFixers from './spacingFixers';

export {default as checkFlowFileAnnotation} from './checkFlowFileAnnotation';
export {default as fuzzyStringMatch} from './fuzzyStringMatch';
export {default as getParameterName} from './getParameterName.js';
export {default as getParameterName} from './getParameterName';
export {default as getTokenAfterParens} from './getTokenAfterParens';
export {default as getTokenBeforeParens} from './getTokenBeforeParens';
export {default as isFlowFile} from './isFlowFile.js';
export {default as isFlowFileAnnotation} from './isFlowFileAnnotation.js';
export {default as iterateFunctionNodes} from './iterateFunctionNodes.js';
export {default as isFlowFile} from './isFlowFile';
export {default as isFlowFileAnnotation} from './isFlowFileAnnotation';
export {default as iterateFunctionNodes} from './iterateFunctionNodes';
export {default as quoteName} from './quoteName';

export {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/isFlowFile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isFlowFileAnnotation from './isFlowFileAnnotation.js';
import isFlowFileAnnotation from './isFlowFileAnnotation';
/* eslint-disable flowtype/require-valid-file-annotation */
/**
* Checks whether a file has an @flow or @noflow annotation.
Expand Down
23 changes: 5 additions & 18 deletions tests/rules/assertions/defineFlowType.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
RuleTester
RuleTester
} from 'eslint';
import noUndefRule from 'eslint/lib/rules/no-undef';

Expand Down Expand Up @@ -45,7 +45,7 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [
{
code: 'opaque type A = AType',
errors: [
// Complaining about 'A' not being defined might be an upstream bug
// Complaining about 'A' is fixed in https://github.com/babel/babel-eslint/pull/696
'\'A\' is not defined.',
'\'AType\' is not defined.'
]
Expand Down Expand Up @@ -105,12 +105,6 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [
'\'AType\' is not defined.'
]
},
{
code: 'interface AType {}',
errors: [
'\'AType\' is not defined.'
]
},
{
code: 'declare interface A {}',
errors: [
Expand All @@ -120,8 +114,8 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [
{
code: '({ a: ({b() {}}: AType) })',

// `AType` appears twice in `globalScope.through` as distinct
// references, this may be a babel-eslint bug.
// `AType` appears twice in `globalScope.through` as distinct
// references, this may be a babel-eslint bug.
errors: [
'\'AType\' is not defined.',
'\'AType\' is not defined.'
Expand All @@ -133,13 +127,6 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [
'\'AType\' is not defined.',
'\'BType\' is not defined.'
]
},
{
code: 'interface AType<BType> {}',
errors: [
'\'AType\' is not defined.',
'\'BType\' is not defined.'
]
}
];

Expand Down Expand Up @@ -196,7 +183,7 @@ const ALWAYS_VALID = [
parser: 'babel-eslint'
});

ruleTester.run('no-under must not trigger an error in these cases', noUndefRule, {
ruleTester.run('no-undef must not trigger an error in these cases', noUndefRule, {
invalid: [],
valid: ALWAYS_VALID
});
Expand Down

0 comments on commit 68ed515

Please sign in to comment.