Skip to content

Commit 7dc6b10

Browse files
authored
Merge pull request #287 from brettz9/eslint6
fix(require-jsdoc): broken with eslint 6, we can't use schema for option defaults, so revert to old approach testing: avoid timeout (not an issue anymore with eslint 6) testing(check-examples): use absolute paths with `matchingFileName` (used with `getConfigForFile`/`Linter`) per eslint 6 testing(check-examples): use a simple `matchingFileName` file which doesn't have problem with loading `babel-eslint` in eslint 6 as does our config testing(require-param): use absolute paths with `parser` per eslint 6 chore(linting): update eslint devDep chore: update `eslint` in `peerDependencies` to include `^6.0.0` as well as `^5.0.0` chore: add `.ncurc.js` to avoid `npm-check-updates` indicating `peerDependencies` (with `eslint`) having update available chore(travis): add test for eslint@5 and eslint@6; add Node versions 10 and 12 docs(contributing): note on merging
2 parents f4d56b2 + 20a681f commit 7dc6b10

File tree

10 files changed

+57
-17
lines changed

10 files changed

+57
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ package-lock.json
1111
!.npmignore
1212
!.README
1313
!.travis.yml
14+
!.ncurc.js

.ncurc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
// Whitelist all for checking besides `peer` which indicates
3+
// somewhat older versions of `eslint` we still support even
4+
// while our devDeps point to a more recent version
5+
"dep": "prod,dev,optional,bundle"
6+
};

.travis.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
language: node_js
22
node_js:
3-
- node
3+
- 12
4+
- 10
45
- 8
56
- 6
67
before_install:
78
- npm config set depth 0
9+
before_script:
10+
- 'if [ -n "${ESLINT-}" ]; then npm install --no-save "eslint@${ESLINT}" ; fi'
811
notifications:
912
email: false
1013
sudo: false
1114
script:
1215
- npm run test
13-
- npm run lint
16+
- 'if [ -n "${LINT-}" ]; then npm run lint; fi'
1417
- npm run build
18+
env:
19+
matrix:
20+
- ESLINT=6
21+
- ESLINT=5
22+
matrix:
23+
fast_finish: true
24+
include:
25+
- node_js: 'lts/*'
26+
env: LINT=true
27+
exclude:
28+
- node_js: 6
29+
env: ESLINT=6
1530
after_success:
1631
- export NODE_ENV=production
1732
- npm run build

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ function quux () {}
678678
function quux2 () {
679679

680680
}
681-
// Settings: {"jsdoc":{"matchingFileName":"test/jsdocUtils.js"}}
681+
// Settings: {"jsdoc":{"matchingFileName":"/Users/brett/eslint-plugin-jsdoc/test/rules/data/test.js"}}
682682
// Message: @example error (semi): Missing semicolon.
683683

684684
/**

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"babel-plugin-add-module-exports": "^1.0.2",
2424
"babel-plugin-istanbul": "^5.1.4",
2525
"chai": "^4.2.0",
26-
"eslint": "^5.14.1",
26+
"eslint": "^6.0.0",
2727
"eslint-config-canonical": "^17.1.1",
2828
"gitdown": "^2.5.8",
2929
"glob": "^7.1.4",
@@ -53,7 +53,7 @@
5353
"main": "./dist/index.js",
5454
"name": "eslint-plugin-jsdoc",
5555
"peerDependencies": {
56-
"eslint": ">=5.16.0"
56+
"eslint": "^5.0.0 || ^6.0.0"
5757
},
5858
"repository": {
5959
"type": "git",
@@ -64,8 +64,8 @@
6464
"build": "rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps",
6565
"create-readme": "gitdown ./.README/README.md --output-file ./README.md && npm run add-assertions",
6666
"lint": "eslint ./src ./test",
67-
"test-cov": "BABEL_ENV=test nyc mocha --recursive --require @babel/register --reporter progress --timeout 7000",
68-
"test": "BABEL_ENV=test nyc --reporter text-summary mocha --recursive --require @babel/register --reporter progress --timeout 7000"
67+
"test-cov": "BABEL_ENV=test nyc mocha --recursive --require @babel/register --reporter progress",
68+
"test": "BABEL_ENV=test nyc --reporter text-summary mocha --recursive --require @babel/register --reporter progress"
6969
},
7070
"nyc": {
7171
"require": [

src/rules/requireJsdoc.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@ const OPTIONS_SCHEMA = {
1818
default: {},
1919
properties: {
2020
ancestorsOnly: {
21-
default: false,
2221
type: 'boolean'
2322
},
2423
cjs: {
25-
default: true,
2624
type: 'boolean'
2725
},
2826
esm: {
29-
default: true,
3027
type: 'boolean'
3128
},
3229
window: {
33-
default: false,
3430
type: 'boolean'
3531
}
3632
},
@@ -142,10 +138,10 @@ export default iterateJsdoc(null, {
142138

143139
if (publicOnly) {
144140
const opt = {
145-
ancestorsOnly: publicOnly.ancestorsOnly,
146-
esm: publicOnly.esm,
147-
initModuleExports: publicOnly.cjs,
148-
initWindow: publicOnly.window
141+
ancestorsOnly: Boolean(_.get(publicOnly, 'ancestorsOnly', false)),
142+
esm: Boolean(_.get(publicOnly, 'esm', true)),
143+
initModuleExports: Boolean(_.get(publicOnly, 'cjs', true)),
144+
initWindow: Boolean(_.get(publicOnly, 'window', false))
149145
};
150146
const parseResult = exportParser.parse(sourceCode.ast, node, opt);
151147
const exported = exportParser.isExported(node, parseResult, opt);

test/rules/assertions/checkExamples.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
/* eslint-disable no-restricted-syntax */
22

3+
// After `importMeta` no longer experimental, we can use this ESM
4+
// approach over `__dirname`?
5+
// import {fileURLToPath} from 'url';
6+
// import {join, dirname} from 'path';
7+
// join(dirname(fileURLToPath(import.meta.url)), 'babel-eslint')
8+
import {join} from 'path';
9+
310
export default {
411
invalid: [
512
{
@@ -314,7 +321,7 @@ export default {
314321
],
315322
settings: {
316323
jsdoc: {
317-
matchingFileName: 'test/jsdocUtils.js'
324+
matchingFileName: join(__dirname, '../', 'data/test.js')
318325
}
319326
}
320327
},

test/rules/assertions/requireParam.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// After `importMeta` no longer experimental, we can use this ESM
2+
// approach over `__dirname`?
3+
// import {fileURLToPath} from 'url';
4+
// import {join, dirname} from 'path';
5+
// join(dirname(fileURLToPath(import.meta.url)), 'babel-eslint')
6+
import {join} from 'path';
7+
18
export default {
29
invalid: [
310
{
@@ -636,7 +643,7 @@ export default {
636643
/** @const {boolean} test */
637644
const test = something?.find(_ => _)
638645
`,
639-
parser: 'babel-eslint'
646+
parser: join(__dirname, '../../../node_modules', 'babel-eslint')
640647
},
641648
{
642649
code: `

test/rules/data/.eslintrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"root": true,
3+
"rules": {
4+
"semi": ["error", "always"]
5+
}
6+
}

test/rules/data/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Just a plain JavaScript file which can be targeted by a
2+
// test for ESLint rule matching

0 commit comments

Comments
 (0)