Skip to content

Commit 5e784ba

Browse files
committed
fix(require-jsdoc): with eslint 6, we can't use schema for defaults, so revert to old approach
chore(linting): update eslint devDep 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
1 parent f4d56b2 commit 5e784ba

File tree

6 files changed

+31
-13
lines changed

6 files changed

+31
-13
lines changed

package.json

Lines changed: 3 additions & 3 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",
@@ -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)