Skip to content

Commit

Permalink
fix: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed May 22, 2018
1 parent e39995d commit cac561f
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "canonical"
"extends": "canonical"
}
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ script:
- npm run lint
- npm run build
after_success:
- rm -fr ./dist && npm run build && semantic-release pre && npm publish && semantic-release post
- export NODE_ENV=production
- npm run build
- semantic-release
3 changes: 2 additions & 1 deletion bin/readmeAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const getAssertions = () => {
});

const assertionCodes = _.map(assertionFiles, (filePath) => {
const codes = require(filePath); // eslint-disable-line global-require
// eslint-disable-next-line global-require, import/no-dynamic-require
const codes = require(filePath);

return {
invalid: _.map(codes.invalid, formatCodeSnippet),
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
"url": "http://gajus.com"
},
"dependencies": {
"lodash": "^4.15.0"
"lodash": "^4.17.10"
},
"description": "Flowtype linting rules for ESLint.",
"devDependencies": {
"ajv": "^5.2.1",
"babel-cli": "^6.14.0",
"ajv": "^6.5.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^6.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.1.10",
"babel-register": "^6.14.0",
"chai": "^3.5.0",
"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",
"gitdown": "^2.5.0",
"gitdown": "^2.5.2",
"glob": "^7.1.2",
"husky": "^0.11.7",
"jsonlint": "^1.6.2",
"mocha": "^3.0.2",
"semantic-release": "^6.3.2"
"husky": "^0.14.3",
"jsonlint": "^1.6.3",
"mocha": "^5.2.0",
"semantic-release": "^15.5.0"
},
"engines": {
"node": ">=4"
Expand All @@ -45,7 +45,7 @@
"url": "https://github.com/gajus/eslint-plugin-flowtype"
},
"scripts": {
"build": "babel ./src --out-dir ./dist --copy-files",
"build": "rm -fr ./dist && babel ./src --out-dir ./dist --copy-files",
"documentation": "gitdown ./.README/README.md --output-file ./README.md; npm run documentation-add-assertions",
"documentation-add-assertions": "babel-node ./bin/readmeAssertions",
"format-json": "jsonlint --sort-keys --in-place --indent ' ' ./src/configs/recommended.json && echo '' >> ./src/configs/recommended.json",
Expand Down
1 change: 1 addition & 0 deletions src/rules/arrayStyle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default (defaultConfig, simpleType) => {
});
}
},

// verbose
GenericTypeAnnotation (node) {
if (node.id.name === 'Array') {
Expand Down
24 changes: 13 additions & 11 deletions src/rules/defineFlowType.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@ const schema = [];
const create = (context) => {
let globalScope;

// do nearly the same thing that eslint does for config globals
// https://github.com/eslint/eslint/blob/v2.0.0/lib/eslint.js#L118-L194
// do nearly the same thing that eslint does for config globals
// https://github.com/eslint/eslint/blob/v2.0.0/lib/eslint.js#L118-L194
const makeDefined = (ident) => {
let ii;

// start from the right since we're going to remove items from the array
// start from the right since we're going to remove items from the array
for (ii = globalScope.through.length - 1; ii >= 0; ii--) {
const ref = globalScope.through[ii];

if (ref.identifier.name === ident.name) {
// use "__defineGeneric" since we don't have a reference to "escope.Variable"
globalScope.__defineGeneric( // eslint-disable-line no-underscore-dangle
ident.name,
globalScope.set,
globalScope.variables
);
// use "__defineGeneric" since we don't have a reference to "escope.Variable"
// eslint-disable-next-line no-underscore-dangle
globalScope.__defineGeneric(
ident.name,
globalScope.set,
globalScope.variables
);
const variable = globalScope.set.get(ident.name);

variable.writeable = false;
// "through" contains all references whose definition cannot be found
// so we need to update references and remove the ones that were added

// "through" contains all references whose definition cannot be found
// so we need to update references and remove the ones that were added
globalScope.through.splice(ii, 1);
ref.resolved = variable;
variable.references.push(ref);
Expand Down
2 changes: 0 additions & 2 deletions src/rules/delimiterDangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ const create = (context) => {

if (option === 'only-multiline' && isDangling && !isMultiLine) {
report.dangle();

return;
}
};

Expand Down
1 change: 1 addition & 0 deletions src/rules/noDupeKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const create = (context) => {

const checkForDuplicates = (node) => {
const haystack = [];

// filter out complex object types, like ObjectTypeSpreadProperty
const identifierNodes = _.filter(node.properties, {type: 'ObjectTypeProperty'});

Expand Down
4 changes: 3 additions & 1 deletion src/rules/noTypesMissingFileAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const create = (context) => {
reporter(node, 'imports');
}
if (node.importKind === 'value' &&
node.specifiers.some((specifier) => { return specifier.importKind === 'type'; })) {
node.specifiers.some((specifier) => {
return specifier.importKind === 'type';
})) {
reporter(node, 'imports');
}
},
Expand Down
19 changes: 15 additions & 4 deletions src/rules/requireTypesAtTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,27 @@ const create = (context) => {
// nodes representing type and import declarations
const ignoredNodes = [
// import ...
(node) => { return node.type === 'ImportDeclaration'; },
(node) => {
return node.type === 'ImportDeclaration';
},

// export type Foo = ...
// export opaque type Foo = ...
// export type Foo from ...
// export opaque type Foo from ...
(node) => { return node.type === 'ExportNamedDeclaration' && node.exportKind === 'type'; },
(node) => {
return node.type === 'ExportNamedDeclaration' && node.exportKind === 'type';
},

// type Foo = ...
(node) => { return node.type === 'TypeAlias'; },
(node) => {
return node.type === 'TypeAlias';
},

// opaque type Foo = ...
(node) => { return node.type === 'OpaqueType'; }
(node) => {
return node.type === 'OpaqueType';
}
];

const isIgnoredNode = (node) => {
Expand Down
7 changes: 5 additions & 2 deletions src/rules/sortKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ const generateOrderedList = (context, sort, properties) => {
if (property.type === 'ObjectTypeSpreadProperty') {
return ['...' + property.argument.id.name];
} else if (property.value.type === 'ObjectTypeAnnotation') {
value = generateFix(property.value, context, sort); // eslint-disable-line no-use-before-define
// eslint-disable-next-line no-use-before-define
value = generateFix(property.value, context, sort);
} else {
value = context.getSourceCode().getText(property.value);
}

return [(variances[property.variance] || '') + name + (property.optional ? '?' : ''), value];
})
.sort((first, second) => { return sort(first[0], second[0]) ? -1 : 1; })
.sort((first, second) => {
return sort(first[0], second[0]) ? -1 : 1;
})
.map((item) => {
if (item.length === 1) {
return item[0];
Expand Down
3 changes: 2 additions & 1 deletion src/rules/typeColonSpacing/evaluateObjectTypeProperty.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {getParameterName, quoteName} from '../../utilities';

const getColon = (context, objectTypeProperty) => {
let tokenIndex = 1; // eslint-disable-line init-declarations
// eslint-disable-next-line init-declarations
let tokenIndex = 1;

if (objectTypeProperty.optional) {
tokenIndex++;
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/fuzzyStringMatch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

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
Expand Down
4 changes: 3 additions & 1 deletion src/utilities/getParameterName.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export default (identifierNode, context) => {
}

if (identifierNode.type === 'ObjectTypeProperty') {
let tokenIndex = 0; // eslint-disable-line init-declarations
let tokenIndex;

tokenIndex = 0;

if (identifierNode.static) {
tokenIndex++;
Expand Down
2 changes: 2 additions & 0 deletions tests/rules/assertions/defineFlowType.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ 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.
errors: [
Expand Down Expand Up @@ -174,6 +175,7 @@ const ALWAYS_VALID = [
'var a: Array',
'var a: Array<string>',
'type A = Array',

// This complains about 'A' not being defined. It might be an upstream bug
// 'opaque type A = Array',
'function f(a: string) {}',
Expand Down
8 changes: 4 additions & 4 deletions tests/rules/assertions/requireReturnType.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export default {
'always',
{
annotateUndefined: 'always',
excludeMatching: [ 'constructor' ]
excludeMatching: ['constructor']
}
]
},
Expand All @@ -674,7 +674,7 @@ export default {
options: [
'always',
{
excludeMatching: [ 'foo' ]
excludeMatching: ['foo']
}
]
},
Expand All @@ -683,7 +683,7 @@ export default {
options: [
'always',
{
excludeMatching: [ 'foo' ]
excludeMatching: ['foo']
}
]
},
Expand All @@ -692,7 +692,7 @@ export default {
options: [
'always',
{
excludeMatching: [ 'foo' ]
excludeMatching: ['foo']
}
]
},
Expand Down
13 changes: 8 additions & 5 deletions tests/rules/assertions/spaceAfterTypeColon.js
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,6 @@ const OBJECT_TYPE_PROPERTIES = {
]
};


const OBJECT_TYPE_INDEXERS = {
invalid: [
// [id:key]: value
Expand Down Expand Up @@ -909,6 +908,7 @@ const OBJECT_TYPE_INDEXERS = {
options: ['always'],
output: 'type X = { +[a: b]: c }'
},

// [id:key]: value
// ^
{
Expand All @@ -929,6 +929,7 @@ const OBJECT_TYPE_INDEXERS = {
options: ['always'],
output: 'type X = { [a: b]: c }'
},

// [id:key]: value
// ^ ^
{
Expand Down Expand Up @@ -1005,7 +1006,6 @@ const OBJECT_TYPE_INDEXERS = {
]
};


const TYPE_CAST_EXPRESSIONS = {
invalid: [
{
Expand Down Expand Up @@ -1065,7 +1065,6 @@ const TYPE_CAST_EXPRESSIONS = {
]
};


const ALL = [
ARROW_FUNCTION_PARAMS,
ARROW_FUNCTION_RETURN,
Expand Down Expand Up @@ -1157,7 +1156,11 @@ const MISCONFIGURED = [
];

export default {
invalid: _.flatMap(ALL, (rules) => { return rules.invalid; }),
invalid: _.flatMap(ALL, (rules) => {
return rules.invalid;
}),
misconfigured: MISCONFIGURED,
valid: _.flatMap(ALL, (rules) => { return rules.valid; })
valid: _.flatMap(ALL, (rules) => {
return rules.valid;
})
};
10 changes: 8 additions & 2 deletions tests/rules/assertions/spaceBeforeTypeColon.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ const OBJECT_TYPE_INDEXERS = {
options: ['always'],
output: 'type X = { +[a : b] : c }'
},

// [id:key]: value
// ^
{
Expand All @@ -727,6 +728,7 @@ const OBJECT_TYPE_INDEXERS = {
options: ['always'],
output: 'type X = { [a : b] : c }'
},

// [id:key]: value
// ^ ^
{
Expand Down Expand Up @@ -915,7 +917,11 @@ const MISCONFIGURED = [
];

export default {
invalid: _.flatMap(ALL, (rules) => { return rules.invalid; }),
invalid: _.flatMap(ALL, (rules) => {
return rules.invalid;
}),
misconfigured: MISCONFIGURED,
valid: _.flatMap(ALL, (rules) => { return rules.valid; })
valid: _.flatMap(ALL, (rules) => {
return rules.valid;
})
};
1 change: 0 additions & 1 deletion tests/rules/assertions/typeImportStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ export default {
]
};


2 changes: 2 additions & 0 deletions tests/rules/assertions/useFlowType.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ const VALID_WITH_USE_FLOW_TYPE = [
},
{
code: 'type A = {}; function x<Y: A.B.C>(i: Y) { i }; x()',

// QualifiedTypeIdentifier -------^
errors: [
'\'A\' is defined but never used.'
]
},
{
code: 'function x<Y: A.B.C>(i: Y) { i }; type A = {}; x()',

// ^- QualifiedTypeIdentifier
errors: [
'\'A\' is defined but never used.'
Expand Down
1 change: 1 addition & 0 deletions tests/rules/assertions/validSyntax.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
invalid: [

// removed, as Babylon now prevents the invalid syntax
],
valid: [
Expand Down
Loading

0 comments on commit cac561f

Please sign in to comment.