Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test that external rules are ignored #251

Merged
merged 1 commit into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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