Skip to content

Commit 30835cd

Browse files
committed
chore: update to eslint 7
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
1 parent a516865 commit 30835cd

13 files changed

+843
-23
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ script:
2424
- npm run build
2525
env:
2626
matrix:
27+
- ESLINT=7
2728
- ESLINT=6
2829
matrix:
2930
fast_finish: true
3031
include:
3132
- node_js: 'lts/*'
3233
env: LINT=true
34+
exclude:
35+
- node_js: 8
36+
env: ESLINT=7
3337
after_success:
3438
- export NODE_ENV=production
3539
- npm run build

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"babel-plugin-istanbul": "^6.0.0",
2828
"chai": "^4.2.0",
2929
"cross-env": "^7.0.2",
30-
"eslint": "6.8.0",
30+
"eslint": "7.0.0",
3131
"eslint-config-canonical": "^19.0.4",
3232
"gitdown": "^3.1.3",
3333
"glob": "^7.1.6",
@@ -55,7 +55,7 @@
5555
"main": "./dist/index.js",
5656
"name": "eslint-plugin-jsdoc",
5757
"peerDependencies": {
58-
"eslint": "^6.0.0"
58+
"eslint": "^6.0.0 || ^7.0.0"
5959
},
6060
"repository": {
6161
"type": "git",

src/rules/requireDescriptionCompleteSentence.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const validateDescription = (description, reportOrig, jsdocNode, abbreviationsRe
102102
return $1 + capitalize(beginning);
103103
});
104104
} else {
105-
text = text.replace(beginning, capitalize(beginning));
105+
text = text.replace(new RegExp('((?:[.!?]|\\*|\\})\\s*)' + _.escapeRegExp(beginning), 'u'), '$1' + capitalize(beginning));
106106
}
107107
}
108108

src/rules/requireExample.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import warnRemovedSettings from '../warnRemovedSettings';
44

55
export default iterateJsdoc(({
66
jsdoc,
7+
node,
78
report,
89
utils,
910
context,
@@ -34,7 +35,7 @@ export default iterateJsdoc(({
3435
tag: targetTagName,
3536
type: '',
3637
});
37-
});
38+
}, node);
3839

3940
return;
4041
}

src/rules/requireFileOverview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default iterateJsdoc(({
4747
// from `undefined` to `false` so can detect next time
4848
state.hasDuplicates[tagName] = false;
4949
state.hasNonCommentBeforeTag[tagName] = state.hasNonComment &&
50-
state.hasNonComment < jsdocNode.start;
50+
state.hasNonComment < jsdocNode.range[0];
5151
}
5252
}
5353
}, {
@@ -122,7 +122,7 @@ export default iterateJsdoc(({
122122
},
123123
nonComment ({state, node}) {
124124
if (!state.hasNonComment) {
125-
state.hasNonComment = node.start;
125+
state.hasNonComment = node.range[0];
126126
}
127127
},
128128
});

test/rules/assertions/checkAlignment.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ function quux (foo) {
204204
message: 'Expected JSDoc block to be aligned.',
205205
},
206206
],
207+
output: `
208+
/**
209+
* A jsdoc not attached to any node.
210+
*/
211+
`,
207212
},
208213
{
209214
code: `
@@ -221,6 +226,15 @@ function quux (foo) {
221226
message: 'Expected JSDoc block to be aligned.',
222227
},
223228
],
229+
output: `
230+
class Foo {
231+
/**
232+
* Some method
233+
* @param a
234+
*/
235+
quux(a) {}
236+
}
237+
`,
224238
},
225239
],
226240
valid: [

test/rules/assertions/checkPropertyNames.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ export default {
6666
message: 'Duplicate @property "employees[].name"',
6767
},
6868
],
69+
output: `
70+
/**
71+
* Assign the project to a list of employees.
72+
* @typedef (SomeType) SomeTypedef
73+
* @property {string} employees[].name - The name of an employee.
74+
*/
75+
`,
6976
},
7077
{
7178
code: `
@@ -106,6 +113,16 @@ export default {
106113
message: 'Duplicate @property "cfg.foo"',
107114
},
108115
],
116+
output: `
117+
/**
118+
* @typedef (SomeType) SomeTypedef
119+
* @property cfg
120+
* @property cfg.foo
121+
*/
122+
function quux ({foo, bar}) {
123+
124+
}
125+
`,
109126
},
110127
{
111128
code: `
@@ -126,6 +143,17 @@ export default {
126143
message: 'Duplicate @property "cfg.foo"',
127144
},
128145
],
146+
output: `
147+
/**
148+
* @typedef (SomeType) SomeTypedef
149+
* @property cfg
150+
* @property cfg.foo
151+
* @property baz
152+
*/
153+
function quux ({foo, bar}, baz) {
154+
155+
}
156+
`,
129157
},
130158
{
131159
code: `
@@ -146,6 +174,17 @@ export default {
146174
message: 'Duplicate @property "cfg.foo"',
147175
},
148176
],
177+
output: `
178+
/**
179+
* @typedef (SomeType) SomeTypedef
180+
* @property cfg
181+
* @property cfg.foo
182+
* @property baz
183+
*/
184+
function quux ({foo, bar}, baz) {
185+
186+
}
187+
`,
149188
},
150189
{
151190
code: `

test/rules/assertions/checkTagNames.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ export default {
7272
message: 'Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "param".',
7373
},
7474
],
75+
output: `
76+
/**
77+
* @param foo
78+
*/
79+
function quux (foo) {
80+
81+
}
82+
`,
7583
},
7684
{
7785
code: `
@@ -88,6 +96,14 @@ export default {
8896
message: 'Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "arg".',
8997
},
9098
],
99+
output: `
100+
/**
101+
* @arg foo
102+
*/
103+
function quux (foo) {
104+
105+
}
106+
`,
91107
settings: {
92108
jsdoc: {
93109
tagNamePreference: {
@@ -111,6 +127,14 @@ export default {
111127
message: 'Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "somethingDifferent".',
112128
},
113129
],
130+
output: `
131+
/**
132+
* @somethingDifferent foo
133+
*/
134+
function quux (foo) {
135+
136+
}
137+
`,
114138
settings: {
115139
jsdoc: {
116140
tagNamePreference: {
@@ -134,6 +158,14 @@ export default {
134158
message: 'Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "parameter".',
135159
},
136160
],
161+
output: `
162+
/**
163+
* @parameter foo
164+
*/
165+
function quux (foo) {
166+
167+
}
168+
`,
137169
settings: {
138170
jsdoc: {
139171
tagNamePreference: {
@@ -257,6 +289,14 @@ export default {
257289
message: 'Please use x-todo instead of todo',
258290
},
259291
],
292+
output: `
293+
/**
294+
* @x-todo
295+
*/
296+
function quux () {
297+
298+
}
299+
`,
260300
settings: {
261301
jsdoc: {
262302
tagNamePreference: {
@@ -282,6 +322,14 @@ export default {
282322
message: 'Please use x-todo instead of todo',
283323
},
284324
],
325+
output: `
326+
/**
327+
* @x-todo
328+
*/
329+
function quux () {
330+
331+
}
332+
`,
285333
settings: {
286334
jsdoc: {
287335
tagNamePreference: {
@@ -311,6 +359,14 @@ export default {
311359
message: 'Invalid JSDoc tag (preference). Replace "todo" JSDoc tag with "55".',
312360
},
313361
],
362+
output: `
363+
/**
364+
* @55
365+
*/
366+
function quux () {
367+
368+
}
369+
`,
314370
settings: {
315371
jsdoc: {
316372
tagNamePreference: {

test/rules/assertions/checkTypes.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ export default {
9191
message: 'Invalid JSDoc @throws type "Number"; prefer: "number".',
9292
},
9393
],
94+
output: `
95+
/**
96+
* @returns {number} foo
97+
* @throws {Number} foo
98+
*/
99+
function quux () {
100+
101+
}
102+
`,
94103
},
95104
{
96105
code: `
@@ -295,6 +304,15 @@ export default {
295304
message: 'Invalid JSDoc @param "baz" type "object"; prefer: "Object".',
296305
},
297306
],
307+
output: `
308+
/**
309+
* @param {Abc} foo
310+
* @param {cde} bar
311+
* @param {object} baz
312+
*/
313+
function qux(foo, bar, baz) {
314+
}
315+
`,
298316
settings: {
299317
jsdoc: {
300318
preferredTypes: {
@@ -416,6 +434,14 @@ export default {
416434
message: 'Invalid JSDoc @param "bar" type "Number"; prefer: "number".',
417435
},
418436
],
437+
output: `
438+
/**
439+
* @param {Abc} foo
440+
* @param {Number} bar
441+
*/
442+
function qux(foo, bar) {
443+
}
444+
`,
419445
settings: {
420446
jsdoc: {
421447
preferredTypes: {
@@ -1714,6 +1740,12 @@ export default {
17141740
line: 3,
17151741
message: 'Invalid JSDoc @this type "array"; prefer: "Array".',
17161742
}],
1743+
output: `
1744+
/**
1745+
* @this {Array}
1746+
*/
1747+
function quux () {}
1748+
`,
17171749
settings: {
17181750
jsdoc: {
17191751
mode: 'closure',
@@ -1731,6 +1763,12 @@ export default {
17311763
line: 3,
17321764
message: 'Invalid JSDoc @export type "array"; prefer: "Array".',
17331765
}],
1766+
output: `
1767+
/**
1768+
* @export {Array}
1769+
*/
1770+
function quux () {}
1771+
`,
17341772
settings: {
17351773
jsdoc: {
17361774
mode: 'closure',
@@ -1758,6 +1796,12 @@ export default {
17581796
}],
17591797
},
17601798
],
1799+
output: `
1800+
/**
1801+
* @typedef {Object} foo
1802+
* @property {object} bar
1803+
*/
1804+
`,
17611805
settings: {
17621806
jsdoc: {
17631807
preferredTypes: {
@@ -1782,6 +1826,7 @@ export default {
17821826
}],
17831827
},
17841828
],
1829+
output: '/** @typedef {Object} foo */',
17851830
settings: {
17861831
jsdoc: {
17871832
preferredTypes: {
@@ -1811,6 +1856,12 @@ export default {
18111856
}],
18121857
},
18131858
],
1859+
output: `
1860+
/**
1861+
* @typedef {Object} foo
1862+
* @property {object} bar
1863+
*/
1864+
`,
18141865
settings: {
18151866
jsdoc: {
18161867
preferredTypes: {
@@ -1833,6 +1884,7 @@ export default {
18331884
}],
18341885
},
18351886
],
1887+
output: '/** @typedef {Object<string, string>} foo */',
18361888
settings: {
18371889
jsdoc: {
18381890
preferredTypes: {

0 commit comments

Comments
 (0)