Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/configs/angular.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:configs
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/dom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:configs
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/react.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:configs
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/vue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:configs
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
Expand Down
2 changes: 2 additions & 0 deletions lib/create-testing-library-rule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export function createTestingLibraryRule<
...meta,
docs: {
...meta.docs,
// We're using our own recommendedConfig meta to tell our build tools
// if the rule is recommended on a config basis
recommended: false,
},
},
Expand Down
5 changes: 5 additions & 0 deletions lib/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ type TestingLibraryRuleMetaDocs<TOptions extends readonly unknown[]> = Omit<
TSESLint.RuleMetaDataDocs,
'recommended' | 'url'
> & {
/**
* The recommendation level for the rule on a framework basis.
* Used by the build tools to generate the framework config.
* Set to false to not include it the config
*/
recommendedConfig: Record<
SupportedTestingFramework,
RecommendedConfig<TOptions>
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should export configs that refer to actual rules 1`] = `
exports[`should have run 'generate:configs' script when changing config rules 1`] = `
Object {
"angular": Object {
"plugins": Array [
Expand Down
11 changes: 10 additions & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { exec } from 'child_process';
import { existsSync } from 'fs';
import { resolve } from 'path';

import plugin from '../lib';

const generateConfigs = () => exec(`npm run generate:configs`);

const numberOfRules = 24;
const ruleNames = Object.keys(plugin.rules);

Expand Down Expand Up @@ -43,10 +46,16 @@ it('should have the correct amount of rules', () => {
}
});

it("should have run 'generate:configs' script when changing config rules", async () => {
await generateConfigs();

const allConfigs = plugin.configs;
expect(allConfigs).toMatchSnapshot();
});

it('should export configs that refer to actual rules', () => {
const allConfigs = plugin.configs;

expect(allConfigs).toMatchSnapshot();
expect(Object.keys(allConfigs)).toEqual(['dom', 'angular', 'react', 'vue']);
const allConfigRules = Object.values(allConfigs)
.map((config) => Object.keys(config.rules))
Expand Down
2 changes: 1 addition & 1 deletion tools/generate-configs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const addAutoGeneratedComment = (code: string) =>
[
'// THIS CODE WAS AUTOMATICALLY GENERATED',
'// DO NOT EDIT THIS CODE BY HAND',
'// YOU CAN REGENERATE IT USING yarn generate:configs',
'// YOU CAN REGENERATE IT USING npm run generate:configs',
'',
code,
].join('\n');
Expand Down