Skip to content

Commit

Permalink
Add optional jestDomConfig() for eslint-plugin-jest-dom
Browse files Browse the repository at this point in the history
  • Loading branch information
amikheychik committed Dec 8, 2024
1 parent 6754650 commit 528407a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const perfectiveEslintConfig = require('./dist');

const { cypressConfig } = require('./dist/cypress');
const { jestDomConfig } = require('./dist/jest-dom');
const { rxjsConfig } = require('./dist/rxjs');
const { testingLibraryConfig } = require('./dist/testing-library');

module.exports = [
...perfectiveEslintConfig.default,
cypressConfig(),
jestDomConfig(),
rxjsConfig(),
testingLibraryConfig(),
];
4 changes: 4 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ exports.default = gulp.series(
require: './cypress.js',
types: './cypress.d.ts',
},
'./jest-dom': {
require: './jest-dom.js',
types: './jest-dom.d.ts',
},
'./rxjs': {
require: './rxjs.js',
types: './rxjs.d.ts',
Expand Down
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
jsImportNoExtraneousDependencies,
} from './rules/import/rules/no-extraneous-dependencies';
import { jestConfig } from './rules/jest';
import { jestDomConfig } from './rules/jest-dom';
import { jsdocConfig } from './rules/jsdoc';
import { nConfig } from './rules/n';
import { preferArrowConfig } from './rules/prefer-arrow';
Expand Down Expand Up @@ -168,11 +167,9 @@ export default [
files: ['**/*.@(spec|test).[jt]s?(x)'],
plugins: {
...jestConfig.plugins,
...hasEslintPlugin('jest-dom') ? jestDomConfig.plugins : {},
},
rules: {
...jestConfig.rules,
...hasEslintPlugin('jest-dom') ? jestDomConfig.rules : {},
'@typescript-eslint/ban-ts-comment': ['error', {
'ts-expect-error': 'allow-with-description',
'ts-ignore': true,
Expand Down
9 changes: 9 additions & 0 deletions src/jest-dom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { jestDomConfig as jestDomPluginConfig } from './rules/jest-dom';

export function jestDomConfig(files: string[] = ['**/*.@(spec|test).[jt]s?(x)']): Record<string, unknown> {
return {
files,
plugins: jestDomPluginConfig.plugins,
rules: jestDomPluginConfig.rules,
};
}

0 comments on commit 528407a

Please sign in to comment.