Skip to content

Commit

Permalink
chore: update to eslint 7
Browse files Browse the repository at this point in the history
In process, also:
1. Adds `output` missing in various tests.
2. Fixes `require-example` indent
3. Updates `require-file-overview` to work with ESLint 7
4. Fixes `require-description-complete-sentence` to avoid capitalizing idential string found not at beginning of sentence
  • Loading branch information
brettz9 committed May 9, 2020
1 parent a516865 commit 30835cd
Show file tree
Hide file tree
Showing 13 changed files with 843 additions and 23 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ script:
- npm run build
env:
matrix:
- ESLINT=7
- ESLINT=6
matrix:
fast_finish: true
include:
- node_js: 'lts/*'
env: LINT=true
exclude:
- node_js: 8
env: ESLINT=7
after_success:
- export NODE_ENV=production
- npm run build
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"babel-plugin-istanbul": "^6.0.0",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"eslint": "6.8.0",
"eslint": "7.0.0",
"eslint-config-canonical": "^19.0.4",
"gitdown": "^3.1.3",
"glob": "^7.1.6",
Expand Down Expand Up @@ -55,7 +55,7 @@
"main": "./dist/index.js",
"name": "eslint-plugin-jsdoc",
"peerDependencies": {
"eslint": "^6.0.0"
"eslint": "^6.0.0 || ^7.0.0"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/rules/requireDescriptionCompleteSentence.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const validateDescription = (description, reportOrig, jsdocNode, abbreviationsRe
return $1 + capitalize(beginning);
});
} else {
text = text.replace(beginning, capitalize(beginning));
text = text.replace(new RegExp('((?:[.!?]|\\*|\\})\\s*)' + _.escapeRegExp(beginning), 'u'), '$1' + capitalize(beginning));
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/rules/requireExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import warnRemovedSettings from '../warnRemovedSettings';

export default iterateJsdoc(({
jsdoc,
node,
report,
utils,
context,
Expand Down Expand Up @@ -34,7 +35,7 @@ export default iterateJsdoc(({
tag: targetTagName,
type: '',
});
});
}, node);

return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rules/requireFileOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default iterateJsdoc(({
// from `undefined` to `false` so can detect next time
state.hasDuplicates[tagName] = false;
state.hasNonCommentBeforeTag[tagName] = state.hasNonComment &&
state.hasNonComment < jsdocNode.start;
state.hasNonComment < jsdocNode.range[0];
}
}
}, {
Expand Down Expand Up @@ -122,7 +122,7 @@ export default iterateJsdoc(({
},
nonComment ({state, node}) {
if (!state.hasNonComment) {
state.hasNonComment = node.start;
state.hasNonComment = node.range[0];
}
},
});
14 changes: 14 additions & 0 deletions test/rules/assertions/checkAlignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ function quux (foo) {
message: 'Expected JSDoc block to be aligned.',
},
],
output: `
/**
* A jsdoc not attached to any node.
*/
`,
},
{
code: `
Expand All @@ -221,6 +226,15 @@ function quux (foo) {
message: 'Expected JSDoc block to be aligned.',
},
],
output: `
class Foo {
/**
* Some method
* @param a
*/
quux(a) {}
}
`,
},
],
valid: [
Expand Down
39 changes: 39 additions & 0 deletions test/rules/assertions/checkPropertyNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export default {
message: 'Duplicate @property "employees[].name"',
},
],
output: `
/**
* Assign the project to a list of employees.
* @typedef (SomeType) SomeTypedef
* @property {string} employees[].name - The name of an employee.
*/
`,
},
{
code: `
Expand Down Expand Up @@ -106,6 +113,16 @@ export default {
message: 'Duplicate @property "cfg.foo"',
},
],
output: `
/**
* @typedef (SomeType) SomeTypedef
* @property cfg
* @property cfg.foo
*/
function quux ({foo, bar}) {
}
`,
},
{
code: `
Expand All @@ -126,6 +143,17 @@ export default {
message: 'Duplicate @property "cfg.foo"',
},
],
output: `
/**
* @typedef (SomeType) SomeTypedef
* @property cfg
* @property cfg.foo
* @property baz
*/
function quux ({foo, bar}, baz) {
}
`,
},
{
code: `
Expand All @@ -146,6 +174,17 @@ export default {
message: 'Duplicate @property "cfg.foo"',
},
],
output: `
/**
* @typedef (SomeType) SomeTypedef
* @property cfg
* @property cfg.foo
* @property baz
*/
function quux ({foo, bar}, baz) {
}
`,
},
{
code: `
Expand Down
56 changes: 56 additions & 0 deletions test/rules/assertions/checkTagNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ export default {
message: 'Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "param".',
},
],
output: `
/**
* @param foo
*/
function quux (foo) {
}
`,
},
{
code: `
Expand All @@ -88,6 +96,14 @@ export default {
message: 'Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "arg".',
},
],
output: `
/**
* @arg foo
*/
function quux (foo) {
}
`,
settings: {
jsdoc: {
tagNamePreference: {
Expand All @@ -111,6 +127,14 @@ export default {
message: 'Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "somethingDifferent".',
},
],
output: `
/**
* @somethingDifferent foo
*/
function quux (foo) {
}
`,
settings: {
jsdoc: {
tagNamePreference: {
Expand All @@ -134,6 +158,14 @@ export default {
message: 'Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "parameter".',
},
],
output: `
/**
* @parameter foo
*/
function quux (foo) {
}
`,
settings: {
jsdoc: {
tagNamePreference: {
Expand Down Expand Up @@ -257,6 +289,14 @@ export default {
message: 'Please use x-todo instead of todo',
},
],
output: `
/**
* @x-todo
*/
function quux () {
}
`,
settings: {
jsdoc: {
tagNamePreference: {
Expand All @@ -282,6 +322,14 @@ export default {
message: 'Please use x-todo instead of todo',
},
],
output: `
/**
* @x-todo
*/
function quux () {
}
`,
settings: {
jsdoc: {
tagNamePreference: {
Expand Down Expand Up @@ -311,6 +359,14 @@ export default {
message: 'Invalid JSDoc tag (preference). Replace "todo" JSDoc tag with "55".',
},
],
output: `
/**
* @55
*/
function quux () {
}
`,
settings: {
jsdoc: {
tagNamePreference: {
Expand Down
52 changes: 52 additions & 0 deletions test/rules/assertions/checkTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ export default {
message: 'Invalid JSDoc @throws type "Number"; prefer: "number".',
},
],
output: `
/**
* @returns {number} foo
* @throws {Number} foo
*/
function quux () {
}
`,
},
{
code: `
Expand Down Expand Up @@ -295,6 +304,15 @@ export default {
message: 'Invalid JSDoc @param "baz" type "object"; prefer: "Object".',
},
],
output: `
/**
* @param {Abc} foo
* @param {cde} bar
* @param {object} baz
*/
function qux(foo, bar, baz) {
}
`,
settings: {
jsdoc: {
preferredTypes: {
Expand Down Expand Up @@ -416,6 +434,14 @@ export default {
message: 'Invalid JSDoc @param "bar" type "Number"; prefer: "number".',
},
],
output: `
/**
* @param {Abc} foo
* @param {Number} bar
*/
function qux(foo, bar) {
}
`,
settings: {
jsdoc: {
preferredTypes: {
Expand Down Expand Up @@ -1714,6 +1740,12 @@ export default {
line: 3,
message: 'Invalid JSDoc @this type "array"; prefer: "Array".',
}],
output: `
/**
* @this {Array}
*/
function quux () {}
`,
settings: {
jsdoc: {
mode: 'closure',
Expand All @@ -1731,6 +1763,12 @@ export default {
line: 3,
message: 'Invalid JSDoc @export type "array"; prefer: "Array".',
}],
output: `
/**
* @export {Array}
*/
function quux () {}
`,
settings: {
jsdoc: {
mode: 'closure',
Expand Down Expand Up @@ -1758,6 +1796,12 @@ export default {
}],
},
],
output: `
/**
* @typedef {Object} foo
* @property {object} bar
*/
`,
settings: {
jsdoc: {
preferredTypes: {
Expand All @@ -1782,6 +1826,7 @@ export default {
}],
},
],
output: '/** @typedef {Object} foo */',
settings: {
jsdoc: {
preferredTypes: {
Expand Down Expand Up @@ -1811,6 +1856,12 @@ export default {
}],
},
],
output: `
/**
* @typedef {Object} foo
* @property {object} bar
*/
`,
settings: {
jsdoc: {
preferredTypes: {
Expand All @@ -1833,6 +1884,7 @@ export default {
}],
},
],
output: '/** @typedef {Object<string, string>} foo */',
settings: {
jsdoc: {
preferredTypes: {
Expand Down

0 comments on commit 30835cd

Please sign in to comment.