Skip to content

feat: support ESLint flat config #902

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: export config with plugins var
  • Loading branch information
Belco90 committed Apr 27, 2024
commit 4aa369055a6039ad36115f80081fa39003944ed0
1 change: 0 additions & 1 deletion lib/configs/angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
'error',
Expand Down
1 change: 0 additions & 1 deletion lib/configs/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
'error',
Expand Down
1 change: 0 additions & 1 deletion lib/configs/marko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
'error',
Expand Down
1 change: 0 additions & 1 deletion lib/configs/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
'error',
Expand Down
1 change: 0 additions & 1 deletion lib/configs/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
'error',
Expand Down
9 changes: 9 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ const plugin = {
rules,
};

// TODO: type this with TSESLint.Linter.RuleEntry when upgraded to ESLint v9
const pluginConfigs: Record<string, unknown> = {};
for (const [key, config] of Object.entries(configs)) {
pluginConfigs[key] = {
...config,
plugins: { 'testing-library': plugin },
};
}

export default plugin;
3 changes: 2 additions & 1 deletion tools/generate-configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const getRecommendedRulesForTestingFramework = (

SUPPORTED_TESTING_FRAMEWORKS.forEach((framework) => {
const specificFrameworkConfig: LinterConfig = {
plugins: ['testing-library'],
// "plugins" property must be assigned after defining the plugin variable in the "lib/index.ts"
// https://eslint.org/docs/latest/extend/plugin-migration-flat-config#migrating-configs-for-flat-config
rules: getRecommendedRulesForTestingFramework(framework),
};

Expand Down