Skip to content

Commit ad2e672

Browse files
committed
add tests to lint deprecations
1 parent 1cf387a commit ad2e672

File tree

4 files changed

+482
-15
lines changed

4 files changed

+482
-15
lines changed

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,19 @@ module.exports = {
5454
files: ['tests/**/*-test.{js,ts}'],
5555
extends: ['plugin:qunit/recommended'],
5656
},
57+
{
58+
// mocha tests
59+
files: ['node-tests/**/*.mjs'],
60+
env: {
61+
browser: false,
62+
node: true,
63+
mocha: true,
64+
},
65+
plugins: ['node'],
66+
extends: ['plugin:node/recommended'],
67+
rules: {
68+
'node/no-unpublished-import': 'off',
69+
},
70+
},
5771
],
5872
};

node-tests/index.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { readFileSync } from 'fs';
2+
import walkSync from 'walk-sync';
3+
import { join, basename } from 'path';
4+
import yamlFront from 'yaml-front-matter';
5+
6+
const markdownFilenames = walkSync('content', { globs: ['**/*.md'] });
7+
8+
console.log(markdownFilenames);
9+
10+
describe('Json Tests', function () {
11+
markdownFilenames.forEach((file) => {
12+
it(`${file} is ok`, function () {
13+
let contents = readFileSync(join('content', file), 'utf8');
14+
contents = yamlFront.loadFront(contents);
15+
16+
if (contents.id) {
17+
throw new Error(
18+
`You can't define an ID for a deprecation. If you need an ID that is different from the file name then use displayId`
19+
);
20+
}
21+
22+
if (contents.displayId && contents.displayId === basename(file, '.md')) {
23+
throw new Error(
24+
`You don't need to define a displayId if it's the same as the file name`
25+
);
26+
}
27+
});
28+
});
29+
});

0 commit comments

Comments
 (0)