Skip to content

Commit

Permalink
test: add test that external rules are ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Nov 19, 2022
1 parent 20973d4 commit a6d33f5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
15 changes: 15 additions & 0 deletions test/lib/generate/__snapshots__/configs-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,18 @@ exports[`generate (configs) with config that does not have any rules uses recomm
<!-- end auto-generated rule header -->
"
`;

exports[`generate (configs) with external rules in config ignores external rules 1`] = `
"## Rules
<!-- begin auto-generated rules list -->
💼 Configurations enabled in.\\
✅ Set in the \`recommended\` configuration.
| Name | Description | 💼 |
| :----------------------------- | :---------------------- | :- |
| [no-foo](docs/rules/no-foo.md) | Description for no-foo. | ✅ |
<!-- end auto-generated rules list -->
"
`;
45 changes: 45 additions & 0 deletions test/lib/generate/configs-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,51 @@ describe('generate (configs)', function () {
});
});

describe('with external rules in config', function () {
beforeEach(function () {
mockFs({
'package.json': JSON.stringify({
name: 'eslint-plugin-test',
exports: 'index.js',
type: 'module',
}),

'index.js': `
export default {
rules: {
'no-foo': { meta: { docs: { description: 'Description for no-foo.'} }, create(context) {} },
},
configs: {
recommended: {
plugins: ['external', 'test'],
rules: {
'test/no-foo': 'error',
'external/no-bar': 'error',
}
},
}
};`,

'README.md': '## Rules\n',

'docs/rules/no-foo.md': '',

// Needed for some of the test infrastructure to work.
node_modules: mockFs.load(PATH_NODE_MODULES),
});
});

afterEach(function () {
mockFs.restore();
jest.resetModules();
});

it('ignores external rules', async function () {
await generate('.');
expect(readFileSync('README.md', 'utf8')).toMatchSnapshot();
});
});

describe('only a `recommended` config', function () {
beforeEach(function () {
mockFs({
Expand Down

0 comments on commit a6d33f5

Please sign in to comment.