From 54fce804080c41e83b9723ea406a4264bb64f8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Nevyho=C5=A1t=C4=9Bn=C3=BD?= Date: Thu, 27 Sep 2018 13:04:59 +0200 Subject: [PATCH] feat: Bump versions of babel-eslint, eslint and eslint-config-canonical --- package.json | 6 +- src/rules/defineFlowType.js | 5 +- src/rules/genericSpacing.js | 8 +-- src/rules/newlineAfterFlowAnnotation.js | 6 +- src/rules/noDupeKeys.js | 2 +- src/rules/noPrimitiveConstructorTypes.js | 4 +- src/rules/noWeakTypes.js | 6 +- src/rules/objectTypeDelimiter.js | 4 +- src/rules/requireParameterType.js | 8 +-- src/rules/requireValidFileAnnotation.js | 6 +- src/rules/requireVariableType.js | 6 +- src/rules/semi.js | 3 +- src/rules/sortKeys.js | 2 +- src/rules/spaceBeforeGenericBracket.js | 6 +- src/rules/typeColonSpacing/reporter.js | 3 +- src/rules/typeImportStyle.js | 5 +- src/rules/validSyntax.js | 8 +-- src/utilities/fuzzyStringMatch.js | 27 ++++---- src/utilities/index.js | 8 +-- src/utilities/isFlowFile.js | 2 +- tests/rules/assertions/defineFlowType.js | 23 ++----- tests/rules/assertions/genericSpacing.js | 36 +++++------ tests/rules/assertions/noWeakTypes.js | 14 ++--- tests/rules/assertions/requireExactType.js | 9 ++- .../assertions/unionIntersectionSpacing.js | 40 ++++++------ tests/rules/assertions/useFlowType.js | 63 +------------------ tests/rules/index.js | 2 +- 27 files changed, 120 insertions(+), 192 deletions(-) diff --git a/package.json b/package.json index 13cf1f9b..390b50a5 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/rules/defineFlowType.js b/src/rules/defineFlowType.js index 555f78e2..764641c8 100644 --- a/src/rules/defineFlowType.js +++ b/src/rules/defineFlowType.js @@ -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); diff --git a/src/rules/genericSpacing.js b/src/rules/genericSpacing.js index dcee2275..c0a6e483 100644 --- a/src/rules/genericSpacing.js +++ b/src/rules/genericSpacing.js @@ -1,4 +1,4 @@ -import {spacingFixers} from './../utilities'; +import {spacingFixers} from '../utilities'; const schema = [ { @@ -16,9 +16,9 @@ const create = (context) => { GenericTypeAnnotation (node) { const types = node.typeParameters; - // Promise - // ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters) - // ^^^ GenericTypeAnnotation (without typeParameters) + // Promise + // ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters) + // ^^^ GenericTypeAnnotation (without typeParameters) if (!types) { return; } diff --git a/src/rules/newlineAfterFlowAnnotation.js b/src/rules/newlineAfterFlowAnnotation.js index 35329e04..a67ea725 100644 --- a/src/rules/newlineAfterFlowAnnotation.js +++ b/src/rules/newlineAfterFlowAnnotation.js @@ -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 diff --git a/src/rules/noDupeKeys.js b/src/rules/noDupeKeys.js index f322f05c..9ea2d34d 100644 --- a/src/rules/noDupeKeys.js +++ b/src/rules/noDupeKeys.js @@ -1,7 +1,7 @@ import _ from 'lodash/'; import { getParameterName -} from './../utilities'; +} from '../utilities'; const schema = []; diff --git a/src/rules/noPrimitiveConstructorTypes.js b/src/rules/noPrimitiveConstructorTypes.js index 6cdb2220..10dfbf1f 100644 --- a/src/rules/noPrimitiveConstructorTypes.js +++ b/src/rules/noPrimitiveConstructorTypes.js @@ -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 diff --git a/src/rules/noWeakTypes.js b/src/rules/noWeakTypes.js index 18ca85a8..33941872 100644 --- a/src/rules/noWeakTypes.js +++ b/src/rules/noWeakTypes.js @@ -4,13 +4,13 @@ const schema = [ { additionalProperties: false, properties: { - Function: { + any: { type: 'boolean' }, - Object: { + Function: { type: 'boolean' }, - any: { + Object: { type: 'boolean' } }, diff --git a/src/rules/objectTypeDelimiter.js b/src/rules/objectTypeDelimiter.js index 9ebd430d..d82fe93c 100644 --- a/src/rules/objectTypeDelimiter.js +++ b/src/rules/objectTypeDelimiter.js @@ -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: ';', diff --git a/src/rules/requireParameterType.js b/src/rules/requireParameterType.js index 9f2678db..a0864fe2 100644 --- a/src/rules/requireParameterType.js +++ b/src/rules/requireParameterType.js @@ -1,9 +1,9 @@ import _ from 'lodash'; import { - getParameterName, - iterateFunctionNodes, - quoteName -} from './../utilities'; + getParameterName, + iterateFunctionNodes, + quoteName +} from '../utilities'; const schema = [ { diff --git a/src/rules/requireValidFileAnnotation.js b/src/rules/requireValidFileAnnotation.js index 4ffabd7b..7d5df780 100644 --- a/src/rules/requireValidFileAnnotation.js +++ b/src/rules/requireValidFileAnnotation.js @@ -1,8 +1,8 @@ import _ from 'lodash'; import { - isFlowFileAnnotation, - fuzzyStringMatch -} from './../utilities'; + isFlowFileAnnotation, + fuzzyStringMatch +} from '../utilities'; const defaults = { annotationStyle: 'none' diff --git a/src/rules/requireVariableType.js b/src/rules/requireVariableType.js index d5c5cdb5..600ae519 100644 --- a/src/rules/requireVariableType.js +++ b/src/rules/requireVariableType.js @@ -1,8 +1,8 @@ import _ from 'lodash'; import { - isFlowFile, - quoteName -} from './../utilities'; + isFlowFile, + quoteName +} from '../utilities'; const schema = [ { diff --git a/src/rules/semi.js b/src/rules/semi.js index 887a5f87..09f807f7 100644 --- a/src/rules/semi.js +++ b/src/rules/semi.js @@ -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) { diff --git a/src/rules/sortKeys.js b/src/rules/sortKeys.js index f4ff75d2..b17dbac5 100644 --- a/src/rules/sortKeys.js +++ b/src/rules/sortKeys.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import { getParameterName -} from './../utilities'; +} from '../utilities'; const defaults = { caseSensitive: true, diff --git a/src/rules/spaceBeforeGenericBracket.js b/src/rules/spaceBeforeGenericBracket.js index 71a0547c..e1592f65 100644 --- a/src/rules/spaceBeforeGenericBracket.js +++ b/src/rules/spaceBeforeGenericBracket.js @@ -14,9 +14,9 @@ const create = (context) => { GenericTypeAnnotation (node) { const types = node.typeParameters; - // Promise - // ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters) - // ^^^ GenericTypeAnnotation (without typeParameters) + // Promise + // ^^^^^^^^^^^^ GenericTypeAnnotation (with typeParameters) + // ^^^ GenericTypeAnnotation (without typeParameters) if (!types) { return; } diff --git a/src/rules/typeColonSpacing/reporter.js b/src/rules/typeColonSpacing/reporter.js index 465c43bb..93619d82 100644 --- a/src/rules/typeColonSpacing/reporter.js +++ b/src/rules/typeColonSpacing/reporter.js @@ -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 } diff --git a/src/rules/typeImportStyle.js b/src/rules/typeImportStyle.js index 4202429e..c92596bf 100644 --- a/src/rules/typeImportStyle.js +++ b/src/rules/typeImportStyle.js @@ -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 @@ -56,4 +54,3 @@ export default { create, schema }; - diff --git a/src/rules/validSyntax.js b/src/rules/validSyntax.js index 25333949..fd69cd9b 100644 --- a/src/rules/validSyntax.js +++ b/src/rules/validSyntax.js @@ -1,9 +1,9 @@ import _ from 'lodash'; import { - getParameterName, - iterateFunctionNodes, - quoteName -} from './../utilities'; + getParameterName, + iterateFunctionNodes, + quoteName +} from '../utilities'; const schema = []; diff --git a/src/utilities/fuzzyStringMatch.js b/src/utilities/fuzzyStringMatch.js index 4eb548be..02e00f4a 100644 --- a/src/utilities/fuzzyStringMatch.js +++ b/src/utilities/fuzzyStringMatch.js @@ -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 */ @@ -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; diff --git a/src/utilities/index.js b/src/utilities/index.js index ebf1c01e..d120e737 100644 --- a/src/utilities/index.js +++ b/src/utilities/index.js @@ -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 { diff --git a/src/utilities/isFlowFile.js b/src/utilities/isFlowFile.js index ca2d11f0..a729c828 100644 --- a/src/utilities/isFlowFile.js +++ b/src/utilities/isFlowFile.js @@ -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. diff --git a/tests/rules/assertions/defineFlowType.js b/tests/rules/assertions/defineFlowType.js index bccc254a..7025b4aa 100644 --- a/tests/rules/assertions/defineFlowType.js +++ b/tests/rules/assertions/defineFlowType.js @@ -1,5 +1,5 @@ import { - RuleTester + RuleTester } from 'eslint'; import noUndefRule from 'eslint/lib/rules/no-undef'; @@ -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.' ] @@ -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: [ @@ -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.' @@ -133,13 +127,6 @@ const VALID_WITH_DEFINE_FLOW_TYPE = [ '\'AType\' is not defined.', '\'BType\' is not defined.' ] - }, - { - code: 'interface AType {}', - errors: [ - '\'AType\' is not defined.', - '\'BType\' is not defined.' - ] } ]; @@ -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 }); diff --git a/tests/rules/assertions/genericSpacing.js b/tests/rules/assertions/genericSpacing.js index e67d68f3..3d01887d 100644 --- a/tests/rules/assertions/genericSpacing.js +++ b/tests/rules/assertions/genericSpacing.js @@ -1,6 +1,6 @@ export default { invalid: [ - // Never + // Never { code: 'type X = Promise< string>', @@ -21,21 +21,21 @@ export default { { code: 'type X = Promise< string >', errors: [ - {message: 'There must be no space at start of "Promise" generic type annotation'}, - {message: 'There must be no space at end of "Promise" generic type annotation'} + {message: 'There must be no space at start of "Promise" generic type annotation'}, + {message: 'There must be no space at end of "Promise" generic type annotation'} ], output: 'type X = Promise' }, { code: 'type X = Promise< (foo), bar, (((baz))) >', errors: [ - {message: 'There must be no space at start of "Promise" generic type annotation'}, - {message: 'There must be no space at end of "Promise" generic type annotation'} + {message: 'There must be no space at start of "Promise" generic type annotation'}, + {message: 'There must be no space at end of "Promise" generic type annotation'} ], output: 'type X = Promise<(foo), bar, (((baz)))>' }, - // Always (given no space) + // Always (given no space) { code: 'type X = Promise', @@ -52,8 +52,8 @@ export default { { code: 'type X = Promise', errors: [ - {message: 'There must be a space at start of "Promise" generic type annotation'}, - {message: 'There must be a space at end of "Promise" generic type annotation'} + {message: 'There must be a space at start of "Promise" generic type annotation'}, + {message: 'There must be a space at end of "Promise" generic type annotation'} ], options: ['always'], output: 'type X = Promise< string >' @@ -61,14 +61,14 @@ export default { { code: 'type X = Promise<(foo), bar, (((baz)))>', errors: [ - {message: 'There must be a space at start of "Promise" generic type annotation'}, - {message: 'There must be a space at end of "Promise" generic type annotation'} + {message: 'There must be a space at start of "Promise" generic type annotation'}, + {message: 'There must be a space at end of "Promise" generic type annotation'} ], options: ['always'], output: 'type X = Promise< (foo), bar, (((baz))) >' }, - // Always (given too many spaces) + // Always (given too many spaces) { code: 'type X = FooBar< string >', @@ -85,8 +85,8 @@ export default { { code: 'type X = Promise< (foo), bar, (((baz))) >', errors: [ - {message: 'There must be one space at start of "Promise" generic type annotation'}, - {message: 'There must be one space at end of "Promise" generic type annotation'} + {message: 'There must be one space at start of "Promise" generic type annotation'}, + {message: 'There must be one space at end of "Promise" generic type annotation'} ], options: ['always'], output: 'type X = Promise< (foo), bar, (((baz))) >' @@ -124,13 +124,13 @@ export default { } ], valid: [ - // Never + // Never - {code: 'type X = Promise'}, - {code: 'type X = Promise<(string)>'}, - {code: 'type X = Promise<(foo), bar, (((baz)))>'}, + {code: 'type X = Promise'}, + {code: 'type X = Promise<(string)>'}, + {code: 'type X = Promise<(foo), bar, (((baz)))>'}, - // Always + // Always { code: 'type X = Promise< string >', diff --git a/tests/rules/assertions/noWeakTypes.js b/tests/rules/assertions/noWeakTypes.js index 59e7cd22..9339399b 100644 --- a/tests/rules/assertions/noWeakTypes.js +++ b/tests/rules/assertions/noWeakTypes.js @@ -188,8 +188,8 @@ export default { code: 'type X = any; type Y = Function; type Z = Object', errors: [{message: 'Unexpected use of weak type "Function"'}], options: [{ - Object: false, - any: false + any: false, + Object: false }] } ], @@ -209,13 +209,13 @@ export default { parentSchema: { additionalProperties: false, properties: { - Function: { + any: { type: 'boolean' }, - Object: { + Function: { type: 'boolean' }, - any: { + Object: { type: 'boolean' } }, @@ -293,8 +293,8 @@ export default { { code: 'type X = any; type Y = Object', options: [{ - Object: false, - any: false + any: false, + Object: false }] }, { diff --git a/tests/rules/assertions/requireExactType.js b/tests/rules/assertions/requireExactType.js index 6d7e39f5..e079a531 100644 --- a/tests/rules/assertions/requireExactType.js +++ b/tests/rules/assertions/requireExactType.js @@ -1,7 +1,6 @@ export default { invalid: [ - - // Always + // Always { code: 'type foo = {};', @@ -38,7 +37,7 @@ export default { options: ['always'] }, - // Never + // Never { code: 'type foo = {| |};', @@ -61,7 +60,7 @@ export default { ], valid: [ - // Always + // Always { code: 'type foo = {| |};' @@ -88,7 +87,7 @@ export default { options: ['always'] }, - // Never + // Never { code: 'type foo = { };', diff --git a/tests/rules/assertions/unionIntersectionSpacing.js b/tests/rules/assertions/unionIntersectionSpacing.js index b57864f9..de9ea0b1 100644 --- a/tests/rules/assertions/unionIntersectionSpacing.js +++ b/tests/rules/assertions/unionIntersectionSpacing.js @@ -19,16 +19,16 @@ const UNION = { { code: 'type X = string|number;', errors: [ - {message: 'There must be a space before union type annotation separator'}, - {message: 'There must be a space after union type annotation separator'} + {message: 'There must be a space before union type annotation separator'}, + {message: 'There must be a space after union type annotation separator'} ], output: 'type X = string | number;' }, { code: 'type X = {x: string}|{y: number};', errors: [ - {message: 'There must be a space before union type annotation separator'}, - {message: 'There must be a space after union type annotation separator'} + {message: 'There must be a space before union type annotation separator'}, + {message: 'There must be a space after union type annotation separator'} ], output: 'type X = {x: string} | {y: number};' }, @@ -40,10 +40,10 @@ const UNION = { { code: 'type X = string|number|boolean;', errors: [ - {message: 'There must be a space before union type annotation separator'}, - {message: 'There must be a space after union type annotation separator'}, - {message: 'There must be a space before union type annotation separator'}, - {message: 'There must be a space after union type annotation separator'} + {message: 'There must be a space before union type annotation separator'}, + {message: 'There must be a space after union type annotation separator'}, + {message: 'There must be a space before union type annotation separator'}, + {message: 'There must be a space after union type annotation separator'} ], output: 'type X = string | number | boolean;' }, @@ -55,8 +55,8 @@ const UNION = { { code: 'type X = ((string))|(number | foo);', errors: [ - {message: 'There must be a space before union type annotation separator'}, - {message: 'There must be a space after union type annotation separator'} + {message: 'There must be a space before union type annotation separator'}, + {message: 'There must be a space after union type annotation separator'} ], output: 'type X = ((string)) | (number | foo);' }, @@ -126,16 +126,16 @@ const INTERSECTION = { { code: 'type X = {x: string}&{y: number};', errors: [ - {message: 'There must be a space before intersection type annotation separator'}, - {message: 'There must be a space after intersection type annotation separator'} + {message: 'There must be a space before intersection type annotation separator'}, + {message: 'There must be a space after intersection type annotation separator'} ], output: 'type X = {x: string} & {y: number};' }, { code: 'type X = string&number;', errors: [ - {message: 'There must be a space before intersection type annotation separator'}, - {message: 'There must be a space after intersection type annotation separator'} + {message: 'There must be a space before intersection type annotation separator'}, + {message: 'There must be a space after intersection type annotation separator'} ], output: 'type X = string & number;' }, @@ -147,10 +147,10 @@ const INTERSECTION = { { code: 'type X = string&number&boolean;', errors: [ - {message: 'There must be a space before intersection type annotation separator'}, - {message: 'There must be a space after intersection type annotation separator'}, - {message: 'There must be a space before intersection type annotation separator'}, - {message: 'There must be a space after intersection type annotation separator'} + {message: 'There must be a space before intersection type annotation separator'}, + {message: 'There must be a space after intersection type annotation separator'}, + {message: 'There must be a space before intersection type annotation separator'}, + {message: 'There must be a space after intersection type annotation separator'} ], output: 'type X = string & number & boolean;' }, @@ -162,8 +162,8 @@ const INTERSECTION = { { code: 'type X = ((string))&(number & foo);', errors: [ - {message: 'There must be a space before intersection type annotation separator'}, - {message: 'There must be a space after intersection type annotation separator'} + {message: 'There must be a space before intersection type annotation separator'}, + {message: 'There must be a space after intersection type annotation separator'} ], output: 'type X = ((string)) & (number & foo);' }, diff --git a/tests/rules/assertions/useFlowType.js b/tests/rules/assertions/useFlowType.js index c6e0dd39..e4765aca 100644 --- a/tests/rules/assertions/useFlowType.js +++ b/tests/rules/assertions/useFlowType.js @@ -1,8 +1,8 @@ import { - RuleTester + RuleTester } from 'eslint'; import noUnusedVarsRule from 'eslint/lib/rules/no-unused-vars'; -import useFlowType from './../../../src/rules/useFlowType'; +import useFlowType from '../../../src/rules/useFlowType'; const VALID_WITH_USE_FLOW_TYPE = [ { @@ -34,64 +34,6 @@ const VALID_WITH_USE_FLOW_TYPE = [ errors: [ '\'A\' is defined but never used.' ] - }, - { - code: 'import type A from "a"; (function(): T {})', - errors: [ - '\'A\' is defined but never used.' - ] - }, - { - code: '(function(): T {}); import type A from "a"', - errors: [ - '\'A\' is defined but never used.' - ] - }, - { - code: 'import type {A} from "a"; (function(): T {})', - errors: [ - '\'A\' is defined but never used.' - ] - }, - { - code: '(function(): T {}); import type {A} from "a"', - errors: [ - '\'A\' is defined but never used.' - ] - }, - { - code: '(function(): T {}); import type {a as A} from "a"', - errors: [ - '\'A\' is defined but never used.' - ] - }, - { - code: 'type A = {}; function x(i: Y) { i }; x()', - errors: [ - '\'A\' is defined but never used.' - ] - }, - { - code: 'function x(i: Y) { i }; type A = {}; x()', - errors: [ - '\'A\' is defined but never used.' - ] - }, - { - code: 'type A = {}; function x(i: Y) { i }; x()', - - // QualifiedTypeIdentifier -------^ - errors: [ - '\'A\' is defined but never used.' - ] - }, - { - code: 'function x(i: Y) { i }; type A = {}; x()', - - // ^- QualifiedTypeIdentifier - errors: [ - '\'A\' is defined but never used.' - ] } ]; @@ -189,4 +131,3 @@ export default { }) ] }; - diff --git a/tests/rules/index.js b/tests/rules/index.js index 6ca1a03d..7677c5b5 100644 --- a/tests/rules/index.js +++ b/tests/rules/index.js @@ -6,7 +6,7 @@ import Ajv from 'ajv'; import { RuleTester } from 'eslint'; -import plugin from './../../src'; +import plugin from '../../src'; const ruleTester = new RuleTester();