Skip to content

Commit d228937

Browse files
committedFeb 7, 2023
Update linting setup, fix
Correct missing dep
1 parent 793a593 commit d228937

18 files changed

+522
-99
lines changed
 

‎.eslintrc.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"plugins": [
3-
"node",
3+
"n",
44
"mocha",
55
"prettier"
66
],
77
"extends": [
88
"eslint:recommended",
9-
"plugin:node/recommended",
9+
"plugin:n/recommended",
1010
"plugin:mocha/recommended",
1111
"plugin:prettier/recommended"
1212
],
1313
"rules": {
14-
"prettier/prettier": "error",
15-
"node/no-unpublished-require": "off",
16-
"node/no-unpublished-import": "off"
14+
"prettier/prettier": "error"
1715
},
16+
"parser": "@babel/eslint-parser",
1817
"parserOptions": {
18+
"requireConfigFile": false,
1919
"ecmaVersion": 2020
2020
},
2121
"overrides": [

‎lib/frontmatter-linter.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export default class FrontmatterLinter {
155155
}
156156
return this.defaultSchema;
157157
}
158-
};
158+
}
159159

160160
function formatErrors(errors) {
161161
return errors.map((e) => {

‎lib/frontmatter-updater.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class FrontmatterUpdater {
1919

2020
return [frontmatterContent, content].join('\n');
2121
}
22-
};
22+
}
2323

2424
function unionMerge(target, source) {
2525
const combined = [...target, ...source];

‎lib/result-reporter.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ export default class ResultReporter {
2727
log(chalk.green(successMessage));
2828
}
2929
}
30-
};
30+
}

‎lib/title.mjs

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { toString } from 'mdast-util-to-string';
88
function topLevelHeaderText(tree) {
99
let heading;
1010

11-
visit(tree, 'heading', node => {
11+
visit(tree, 'heading', (node) => {
1212
if (node.depth !== 1) {
1313
return;
1414
}
@@ -18,11 +18,7 @@ function topLevelHeaderText(tree) {
1818
}
1919

2020
export function title(markdown) {
21-
const tree = unified()
22-
.use(remarkParse)
23-
.use(remarkGfm)
24-
.use(remarkFrontmatter)
25-
.parse(markdown)
21+
const tree = unified().use(remarkParse).use(remarkGfm).use(remarkFrontmatter).parse(markdown);
2622
const headingTree = topLevelHeaderText(tree);
2723
return toString(headingTree);
2824
}

‎package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
"author": "Katie Gengler",
1111
"license": "MIT",
1212
"devDependencies": {
13+
"@babel/core": "^7.20.12",
14+
"@babel/eslint-parser": "^7.19.1",
1315
"chai": "^4.3.7",
1416
"eslint": "^8.33.0",
1517
"eslint-config-prettier": "^8.6.0",
1618
"eslint-plugin-mocha": "^10.1.0",
17-
"eslint-plugin-node": "^11.1.0",
19+
"eslint-plugin-n": "^15.6.1",
1820
"eslint-plugin-prettier": "^4.2.1",
1921
"execa": "^6.1.0",
2022
"mocha": "^10.2.0",
@@ -24,10 +26,10 @@
2426
"@github-docs/frontmatter": "^1.3.1",
2527
"chalk": "^5.2.0",
2628
"deepmerge": "^4.3.0",
29+
"mdast-util-to-string": "^3.1.1",
2730
"remark-frontmatter": "^4.0.1",
2831
"remark-gfm": "^3.0.1",
2932
"remark-parse": "^10.0.1",
30-
"remark-stringify": "^10.0.2",
3133
"semver": "^7.3.8",
3234
"simple-git": "^3.16.0",
3335
"unified": "^10.1.2",

‎scripts/check-filename-matches-pr.mjs

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import yargs from 'yargs';
2-
import { hideBin } from 'yargs/helpers'
2+
import { hideBin } from 'yargs/helpers';
33
import ResultReporter from '../lib/result-reporter.mjs';
44

5-
const argv = yargs(hideBin(process.argv)).command('* prNumber path', 'run check on file names', (yargs) => {
6-
return yargs
7-
.positional('pr_number', {
8-
describe: 'The # of the current PR',
9-
type: 'number',
10-
})
11-
.positional('path', {
12-
describe: 'file path to run the lint on',
13-
type: 'string',
14-
})
15-
.demandOption(['path', 'prNumber']);
16-
}).argv;
5+
const argv = yargs(hideBin(process.argv)).command(
6+
'* prNumber path',
7+
'run check on file names',
8+
(yargs) => {
9+
return yargs
10+
.positional('pr_number', {
11+
describe: 'The # of the current PR',
12+
type: 'number',
13+
})
14+
.positional('path', {
15+
describe: 'file path to run the lint on',
16+
type: 'string',
17+
})
18+
.demandOption(['path', 'prNumber']);
19+
}
20+
).argv;
1721

1822
let results = [];
1923
let parts = argv.path.split('/');

‎scripts/find-next-stage.mjs

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import yargs from 'yargs';
2-
import { hideBin } from 'yargs/helpers'
2+
import { hideBin } from 'yargs/helpers';
33
import { readFileSync } from 'node:fs';
44
import { frontmatter } from '../lib/frontmatter.mjs';
55

6-
const argv = yargs(hideBin(process.argv)).command('* path', 'find the next stage for an RFC', (yargs) => {
7-
return yargs
8-
.positional('path', {
9-
describe: 'file path of the RFC to check',
10-
type: 'string',
11-
})
12-
.demandOption(['path']);
13-
}).argv;
6+
const argv = yargs(hideBin(process.argv)).command(
7+
'* path',
8+
'find the next stage for an RFC',
9+
(yargs) => {
10+
return yargs
11+
.positional('path', {
12+
describe: 'file path of the RFC to check',
13+
type: 'string',
14+
})
15+
.demandOption(['path']);
16+
}
17+
).argv;
1418

1519
function main() {
1620
const MergedStages = ['accepted', 'ready-for-release', 'released', 'recommended'];

‎scripts/has-stage-changed.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import yargs from 'yargs';
2-
import { hideBin } from 'yargs/helpers'
2+
import { hideBin } from 'yargs/helpers';
33
import simpleGit from 'simple-git';
44
import { readFileSync } from 'node:fs';
55
import { frontmatter } from '../lib/frontmatter.mjs';
@@ -24,7 +24,7 @@ const argv = yargs(hideBin(process.argv)).command(
2424
const currentMarkdown = readFileSync(argv.path, 'utf8');
2525
const { data: currentData } = frontmatter(currentMarkdown);
2626
try {
27-
const originalMarkdown = await simpleGit().show(`${argv.baseSha}:${argv.path}`)
27+
const originalMarkdown = await simpleGit().show(`${argv.baseSha}:${argv.path}`);
2828
const { data: originalData } = frontmatter(originalMarkdown);
2929
if (originalData.stage !== currentData.stage) {
3030
console.log(

‎scripts/lint-rfc-frontmatter.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import yargs from 'yargs';
2-
import { hideBin } from 'yargs/helpers'
2+
import { hideBin } from 'yargs/helpers';
33
import Linter from '../lib/frontmatter-linter.mjs';
44
import ResultReporter from '../lib/result-reporter.mjs';
55
import { readFileSync, readdirSync } from 'node:fs';
@@ -13,7 +13,6 @@ const argv = yargs(hideBin(process.argv)).command('* [paths..]', 'run lint on fi
1313
.demandOption('paths');
1414
}).argv;
1515

16-
1716
const stages = readdirSync('./stages').map((filename) => filename.replace(/\.md$/, ''));
1817
const teams = readdirSync('./teams').map((filename) => filename.replace(/\.md$/, ''));
1918

‎scripts/list-frontmatter.mjs

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import yargs from 'yargs';
2-
import { hideBin } from 'yargs/helpers'
2+
import { hideBin } from 'yargs/helpers';
33
import { readFileSync } from 'node:fs';
44
import { frontmatter } from '../lib/frontmatter.mjs';
55

6-
const argv = yargs(hideBin(process.argv)).command('* [paths..]', 'list frontmatter from files', (yargs) => {
7-
return yargs
8-
.positional('paths', {
9-
describe: 'file paths to list frontmatter from',
10-
type: 'array',
11-
})
12-
.demandOption('paths');
13-
}).argv;
6+
const argv = yargs(hideBin(process.argv)).command(
7+
'* [paths..]',
8+
'list frontmatter from files',
9+
(yargs) => {
10+
return yargs
11+
.positional('paths', {
12+
describe: 'file paths to list frontmatter from',
13+
type: 'array',
14+
})
15+
.demandOption('paths');
16+
}
17+
).argv;
1418

1519
let results = [];
1620
for (let path of argv.paths) {

‎scripts/rfc-frontmatter.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import yargs from 'yargs';
2-
import { hideBin } from 'yargs/helpers'
2+
import { hideBin } from 'yargs/helpers';
33
import { frontmatter } from '../lib/frontmatter.mjs';
44
import { readFileSync } from 'node:fs';
55

@@ -16,7 +16,6 @@ const argv = yargs(hideBin(process.argv)).command(
1616
}
1717
).argv;
1818

19-
2019
let markdown = readFileSync(argv.path, 'utf8');
2120
const { data, errors } = frontmatter(markdown);
2221

‎scripts/update-rfc-stage.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import yargs from 'yargs';
2-
import { hideBin } from 'yargs/helpers'
2+
import { hideBin } from 'yargs/helpers';
33
import { readFileSync, writeFileSync } from 'node:fs';
44
import Updater from '../lib/frontmatter-updater.mjs';
55

‎test/lib/title-test.mjs

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ My grand plans...
2323
## Another heading
2424
2525
some stuff we will do
26-
`
26+
`;
2727

2828
const RfcWithBlocksInHeader = `---
2929
stage: accepted
@@ -40,16 +40,15 @@ prs:
4040
4141
# Deprecate \`foo\` and \`bar\`; immediately
4242
## Another heading
43-
`
43+
`;
4444

45-
46-
describe('title', function() {
47-
it('returns the contents of the first top-level header in the doc', async function() {
45+
describe('title', function () {
46+
it('returns the contents of the first top-level header in the doc', async function () {
4847
let header = title(RFC);
4948
expect(header).to.equal('My New RFC');
5049
});
5150

52-
it('returns the text contents of the first top-level header in the doc when there are blocks', async function() {
51+
it('returns the text contents of the first top-level header in the doc when there are blocks', async function () {
5352
let header = title(RfcWithBlocksInHeader);
5453
expect(header).to.equal('Deprecate foo and bar; immediately');
5554
});
+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
describe('has-stage-changed', function () {
2+
// eslint-disable-next-line mocha/no-skipped-tests
23
it.skip('succeeds when the stage in the current version of the RFC is different than that of the version at the baseSha', async function () {});
34

5+
// eslint-disable-next-line mocha/no-skipped-tests
46
it.skip('fails when the stage in the current version of the RFC is the same as that in the baseSha', async function () {});
57

8+
// eslint-disable-next-line mocha/no-skipped-tests
69
it.skip('fails when the RFC does not exist in the baseSha', async function () {});
710
});

‎test/scripts/list-frontmatter-test.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('list-frontmatter', function () {
2121
prs: {
2222
accepted: null,
2323
},
24-
title: "My New RFC"
24+
title: 'My New RFC',
2525
},
2626
{
2727
name: 'test/fixtures/0923-already-recommended.md',
@@ -35,7 +35,7 @@ describe('list-frontmatter', function () {
3535
prs: {
3636
accepted: null,
3737
},
38-
title: "My Completely finished RFC"
38+
title: 'My Completely finished RFC',
3939
},
4040
]);
4141
});

‎test/scripts/rfc-frontmatter-test.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('rfc-frontmatter', function () {
1616
prs: {
1717
accepted: null,
1818
},
19-
title: "My New RFC"
19+
title: 'My New RFC',
2020
});
2121
});
2222

0 commit comments

Comments
 (0)