Skip to content

test(eslint): Add eslint back to our test suite #766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,31 @@
"flowtype"
],
"rules": {
"space-in-parens": 2,
"space-before-blocks": 2,
"keyword-spacing": 2,
"space-unary-ops": 2,
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
"no-use-before-define": [2, "nofunc"],
"camelcase": 2,
"semi": 2,
"comma-style": 2,
"no-lonely-if": 2,
"max-len": [2, 120],
"no-else-return": 2,
"no-trailing-spaces": 2,
"new-cap": 2,
"no-empty": 2,
"consistent-return": 0,
"no-new": 2,
"key-spacing": 2,
"no-multi-spaces": 2,
"brace-style": 2,
"object-shorthand": ["error", "always", { "avoidQuotes": true }],
"no-throw-literal": 2,
"no-self-compare": 2,
"no-void": 2,
"no-unused-vars": 2,
"wrap-iife": 2,
"no-eq-null": 2,
"quotes": [2, "single"],
"indent": [2, 2],
"curly": 2,
"strict": [2, "global"],
"no-shadow": 0,
"no-undef": 2,
"flowtype/define-flow-type": 1,
"flowtype/use-flow-type": 1
},
"extends": "eslint:recommended",
"extends": [
"eslint:recommended",
"prettier"
],
"env": {
"node": true,
"es6": true
Expand Down
23 changes: 15 additions & 8 deletions lib/infer/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const generate = require('babel-generator').default;
const _ = require('lodash');
const findTarget = require('./finders').findTarget;
const flowDoctrine = require('../flow_doctrine');
const util = require('util');

/**
* Infers param tags by reading function parameter names
Expand Down Expand Up @@ -98,7 +97,8 @@ function paramToDoc(
const prefixedName = prefix + '.' + param.name;

switch (param.type) {
case 'AssignmentPattern': // (a = b)
case 'AssignmentPattern': {
// (a = b)
const newAssignmentParam = paramToDoc(param.left, '', i);

if (Array.isArray(newAssignmentParam)) {
Expand All @@ -111,8 +111,10 @@ function paramToDoc(
}).code,
type: newAssignmentParam.type
});
}
// ObjectPattern <AssignmentProperty | RestElement>
case 'ObjectPattern': // { a }
case 'ObjectPattern': {
// { a }
if (prefix === '') {
// If this is a root-level param, like f({ x }), then we need to name
// it, like $0 or $1, depending on its position.
Expand Down Expand Up @@ -151,8 +153,10 @@ function paramToDoc(
return _.flatMap(param.properties, prop => {
return paramToDoc(prop, prefix);
});
}
// ArrayPattern<Pattern | null>
case 'ArrayPattern': // ([a, b, { c }])
case 'ArrayPattern': {
// ([a, b, { c }])
if (prefix === '') {
return {
title: 'param',
Expand Down Expand Up @@ -182,12 +186,14 @@ function paramToDoc(
});
return paramToDoc(indexedElement, prefix);
});
case 'ObjectProperty':
}
case 'ObjectProperty': {
return _.assign(paramToDoc(param.value, prefix + '.' + param.key.name), {
name: prefix + '.' + param.key.name
});
}
case 'RestProperty': // (a, ...b)
case 'RestElement':
case 'RestElement': {
let type /*: DoctrineType */ = {
type: 'RestType'
};
Expand All @@ -196,12 +202,12 @@ function paramToDoc(
}
return {
title: 'param',
name: param.argument.name,
name: prefix ? `${prefix}.${param.argument.name}` : param.argument.name,
lineNumber: param.loc.start.line,
type
};
default:
}
default: {
// (a)
var newParam /*: CommentTag*/ = {
title: 'param',
Expand All @@ -215,6 +221,7 @@ function paramToDoc(
}

return newParam;
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions lib/inline_tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ var tokenizeTutorial = makeTokenizer(
* This does not handle the `[text]({@link url})` and `[text]({@tutorial url})` forms of these tags.
* That's a JSDoc misfeature; just use regular markdown syntax instead: `[text](url)`.
*
* @param {Object} options - for the plugin
* @returns {undefined}
*/
module.exports = function(options /*: Object*/) {
module.exports = function(/* options: Object*/) {
var proto = this.Parser.prototype;
proto.inlineTokenizers.tokenizeLink = tokenizeLink;
proto.inlineTokenizers.tokenizeTutorial = tokenizeTutorial;
Expand Down
46 changes: 23 additions & 23 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
access: function(result, tag) {
access(result, tag) {
// doctrine ensures that tag.access is valid
result.access = tag.access;
},
Expand All @@ -33,7 +33,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
augments: function(result, tag) {
augments(result, tag) {
// Google variation of augments/extends tag:
// uses type with brackets instead of name.
// https://github.com/google/closure-library/issues/746
Expand All @@ -55,7 +55,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
callback: function(result, tag) {
callback(result, tag) {
result.kind = 'typedef';

if (tag.description) {
Expand Down Expand Up @@ -92,7 +92,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
event: function(result, tag) {
event(result, tag) {
result.kind = 'event';

if (tag.description) {
Expand All @@ -106,7 +106,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
example: function(result, tag) {
example(result, tag) {
if (!tag.description) {
result.errors.push({
message: '@example without code',
Expand Down Expand Up @@ -135,7 +135,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
external: function(result, tag) {
external(result, tag) {
result.kind = 'external';

if (tag.description) {
Expand All @@ -149,7 +149,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
file: function(result, tag) {
file(result, tag) {
result.kind = 'file';

if (tag.description) {
Expand All @@ -166,7 +166,7 @@ var flatteners = {
* @param {Object} result target comment
* @returns {undefined} has side-effects
*/
global: function(result) {
global(result) {
result.scope = 'global';
},
host: synonym('external'),
Expand All @@ -179,7 +179,7 @@ var flatteners = {
* @param {Object} result target comment
* @returns {undefined} has side-effects
*/
inner: function(result) {
inner(result) {
result.scope = 'inner';
},
/**
Expand All @@ -188,7 +188,7 @@ var flatteners = {
* @param {Object} result target comment
* @returns {undefined} has side-effects
*/
instance: function(result) {
instance(result) {
result.scope = 'instance';
},
/**
Expand All @@ -198,7 +198,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
interface: function(result, tag) {
interface(result, tag) {
result.interface = true;
if (tag.description) {
result.name = tag.description;
Expand All @@ -211,7 +211,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
kind: function(result, tag) {
kind(result, tag) {
// doctrine ensures that tag.kind is valid
result.kind = tag.kind;
},
Expand All @@ -235,7 +235,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
param: function(result, tag) {
param(result, tag) {
var param /*: CommentTag */ = {
title: 'param',
name: tag.name,
Expand Down Expand Up @@ -265,7 +265,7 @@ var flatteners = {
* @param {Object} result target comment
* @returns {undefined} has side-effects
*/
private: function(result) {
private(result) {
result.access = 'private';
},
prop: synonym('property'),
Expand All @@ -276,7 +276,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
property: function(result, tag) {
property(result, tag) {
var property /*: CommentTag */ = {
title: 'property',
name: tag.name,
Expand All @@ -299,7 +299,7 @@ var flatteners = {
* @param {Object} result target comment
* @returns {undefined} has side-effects
*/
protected: function(result) {
protected(result) {
result.access = 'protected';
},
/**
Expand All @@ -308,7 +308,7 @@ var flatteners = {
* @param {Object} result target comment
* @returns {undefined} has side-effects
*/
public: function(result) {
public(result) {
result.access = 'public';
},
readonly: flattenBoolean,
Expand All @@ -321,7 +321,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
returns: function(result, tag) {
returns(result, tag) {
var returns /*: CommentTag */ = {
description: parseMarkdown(tag.description),
title: 'returns'
Expand All @@ -340,7 +340,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
see: function(result, tag) {
see(result, tag) {
result.sees.push(parseMarkdown(tag.description));
},
since: flattenDescription,
Expand All @@ -350,7 +350,7 @@ var flatteners = {
* @param {Object} result target comment
* @returns {undefined} has side-effects
*/
static: function(result) {
static(result) {
result.scope = 'static';
},
summary: flattenMarkdownDescription,
Expand All @@ -362,7 +362,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
throws: function(result, tag) {
throws(result, tag) {
var throws = {};

if (tag.description) {
Expand All @@ -382,7 +382,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
todo: function(result, tag) {
todo(result, tag) {
result.todos.push(parseMarkdown(tag.description));
},
tutorial: todo,
Expand All @@ -396,7 +396,7 @@ var flatteners = {
* @param {Object} tag the tag
* @returns {undefined} has side-effects
*/
variation: function(result, tag) {
variation(result, tag) {
result.variation = tag.variation;
},
version: flattenDescription,
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@
},
"devDependencies": {
"are-we-flow-yet": "^1.0.0",
"babel-eslint": "^7.2.3",
"chdir": "0.0.0",
"cz-conventional-changelog": "2.0.0",
"documentation-schema": "0.0.1",
"eslint": "^3.19.0",
"eslint-config-prettier": "^1.7.0",
"eslint-plugin-flowtype": "^2.32.1",
"flow-bin": "^0.44.0",
"fs-extra": "^3.0.0",
"husky": "^0.13.3",
Expand Down Expand Up @@ -93,7 +97,7 @@
"doc": "./bin/documentation.js build lib/index.js -f md --access=public > docs/NODE_API.md",
"changelog": "standard-changelog -i CHANGELOG.md -w",
"self-lint": "node ./bin/documentation.js lint",
"test": "are-we-flow-yet lib && flow check && npm run self-lint && npm run test-tap",
"test": "eslint lib && are-we-flow-yet lib && flow check && npm run self-lint && npm run test-tap",
"test-tap": "tap -t 120 --coverage --nyc-arg=--cache test/*.js test/lib test/streams"
},
"config": {
Expand Down
Loading