Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/eslint-config/src/configs/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default defineConfig(
},
{
name: 'code-pushup/typescript/disable-type-checked-for-javascript',
files: negatePatterns(TYPESCRIPT_EXTENDED_FILE_PATTERNS),
ignores: TYPESCRIPT_EXTENDED_FILE_PATTERNS,
...tseslint.configs.disableTypeChecked,
},
);
21 changes: 15 additions & 6 deletions packages/eslint-config/tests/configs/angular.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,53 @@ describe('angular config', () => {
const config = await loadConfig('src/app/app.component.ts');
expect(config.rules).toHaveProperty(
'@angular-eslint/prefer-on-push-component-change-detection',
[1],
);
});

it('should have explicitly added rule for HTML file', async () => {
const config = await loadConfig('src/app/app.component.html');
expect(config.rules).toHaveProperty('@angular-eslint/template/no-any');
expect(config.rules).toHaveProperty('@angular-eslint/template/no-any', [2]);
});

it('should have rule from extended typescript config', async () => {
const config = await loadConfig('src/app/app.component.ts');
expect(config.rules).toHaveProperty(
'@typescript-eslint/no-non-null-assertion',
[2],
);
});

it('should have rule from extended recommended angular config', async () => {
const config = await loadConfig('src/app/app.component.ts');
expect(config.rules).toHaveProperty('@angular-eslint/contextual-lifecycle');
expect(config.rules).toHaveProperty(
'@angular-eslint/contextual-lifecycle',
[2],
);
});

it('should have rule from extended recommended angular template config', async () => {
const config = await loadConfig('src/app/app.component.html');
expect(config.rules).toHaveProperty(
'@angular-eslint/template/banana-in-box',
[2],
);
});

it('should have rule from extended angular template accessibility config', async () => {
const config = await loadConfig('src/app/app.component.html');
expect(config.rules).toHaveProperty('@angular-eslint/template/alt-text');
expect(config.rules).toHaveProperty('@angular-eslint/template/alt-text', [
2,
]);
});

it('should have rule disabled if test file pattern matches', async () => {
const config = await loadConfig(
'src/app/components/accordion/accordion.component.stories.ts',
);
expect(
config.rules?.['@angular-eslint/component-max-inline-declarations'],
).toEqual([0]);
expect(config.rules).toHaveProperty(
'@angular-eslint/component-max-inline-declarations',
[0],
);
});
});
2 changes: 1 addition & 1 deletion packages/eslint-config/tests/configs/cypress.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ describe('cypress config', () => {

it('should have explicitly added rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('cypress/no-force');
expect(config.rules).toHaveProperty('cypress/no-force', [1]);
});
});
9 changes: 6 additions & 3 deletions packages/eslint-config/tests/configs/graphql.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ describe('graphql config', () => {

it('should have rule from extended schema config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('@graphql-eslint/naming-convention');
expect(config.rules).toHaveProperty('@graphql-eslint/naming-convention', [
2,
expect.any(Object),
]);
});

it('should have rule from extended relay config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty(
'@graphql-eslint/relay-connection-types',
[2],
);
});

it('should have customized rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('@graphql-eslint/description-style');
expect(config.rules?.['@graphql-eslint/description-style']).toEqual([
expect(config.rules).toHaveProperty('@graphql-eslint/description-style', [
1,
{ style: 'inline' },
]);
Expand Down
23 changes: 16 additions & 7 deletions packages/eslint-config/tests/configs/javascript.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ describe('javascript config', () => {

it('should have explicitly added rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('eqeqeq');
expect(config.rules).toHaveProperty('eqeqeq', [
2,
'always',
{ null: 'never' },
]);
});

it('should have implicitly extended rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('no-const-assign');
expect(config.rules).toHaveProperty('no-const-assign', [2]);
});

it('should not include any rule which requires type checking', async () => {
Expand All @@ -38,21 +42,26 @@ describe('javascript config', () => {

it('should have rule disabled if test file pattern matches', async () => {
const config = await loadConfig('utils.spec.js');
expect(config.rules?.['@typescript-eslint/no-non-null-assertion']).toEqual([
0,
]);
expect(config.rules).toHaveProperty(
'@typescript-eslint/no-non-null-assertion',
[0],
);
});

it('should have rule disabled if known config file pattern matches', async () => {
const config = await loadConfig('jest.config.ts');
expect(config.rules?.['import/no-anonymous-default-export']).toEqual([0]);
expect(config.rules).toHaveProperty('import/no-anonymous-default-export', [
0,
]);
});

it('should have rule disabled if generated file pattern matches', async () => {
const config = await loadConfig(
'src/graphql/generated/introspection-result.ts',
);
expect(config.rules?.['unicorn/no-abusive-eslint-disable']).toEqual([0]);
expect(config.rules).toHaveProperty('unicorn/no-abusive-eslint-disable', [
0,
]);
});

it('should not throw when linting project without tsconfig', async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config/tests/configs/jest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ describe('jest config', () => {

it('should have rule from extended recommended jest config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('jest/no-identical-title');
expect(config.rules).toHaveProperty('jest/no-identical-title', [2]);
});

it('should have explicitly added rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('jest/no-test-return-statement');
expect(config.rules).toHaveProperty('jest/no-test-return-statement', [1]);
});

it('should have customized severity level for rule from extended config', async () => {
const config = await loadConfig();
expect(config.rules?.['jest/no-mocks-import']).toEqual([1]);
expect(config.rules).toHaveProperty('jest/no-mocks-import', [1]);
});
});
5 changes: 3 additions & 2 deletions packages/eslint-config/tests/configs/ngrx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ describe('ngrx config', () => {

it('should have explicitly added rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('rxjs-x/no-unsafe-catch');
expect(config.rules).toHaveProperty('rxjs-x/no-unsafe-catch', [2]);
});

it('should have rule from extended angular config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty(
'@angular-eslint/prefer-on-push-component-change-detection',
[1],
);
});

it('should have rule from extended recommended ngrx config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('@ngrx/good-action-hygiene');
expect(config.rules).toHaveProperty('@ngrx/good-action-hygiene', [1]);
});
});
4 changes: 2 additions & 2 deletions packages/eslint-config/tests/configs/node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe('node config', () => {

it('should have explicitly added rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('n/prefer-promises/fs');
expect(config.rules).toHaveProperty('n/prefer-promises/fs', [1]);
});

it('should have rule from extended base config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('import/no-commonjs');
expect(config.rules).toHaveProperty('import/no-commonjs', [2]);
});

it('should not include any rule which requires type checking', async () => {
Expand Down
10 changes: 7 additions & 3 deletions packages/eslint-config/tests/configs/playwright.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ describe('playwright config', () => {

it('should have rule from extended recommended playwright config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('playwright/valid-expect');
expect(config.rules).toHaveProperty('playwright/valid-expect', [2]);
});

it('should have explicitly added rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('playwright/prefer-native-locators');
expect(config.rules).toHaveProperty('playwright/prefer-native-locators', [
1,
]);
});

it('should have customized severity level for rule from extended config', async () => {
const config = await loadConfig();
expect(config.rules?.['playwright/no-conditional-expect']).toEqual([1]);
expect(config.rules).toHaveProperty('playwright/no-conditional-expect', [
1,
]);
});
});
41 changes: 22 additions & 19 deletions packages/eslint-config/tests/configs/react-testing-library.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,42 @@ describe('react-testing-library config', () => {

it('should have rule from extended recommended react-testing-library config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('testing-library/await-async-events');
expect(config.rules).toHaveProperty('testing-library/await-async-queries', [
2,
]);
});

it('should have explicitly added rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('testing-library/prefer-user-event');
expect(config.rules).toHaveProperty('testing-library/prefer-user-event', [
1,
]);
});

it('should have customized severity level for rule from extended config', async () => {
const config = await loadConfig();
expect(config.rules?.['testing-library/no-await-sync-queries']).toEqual([
1,
]);
expect(config.rules).toHaveProperty(
'testing-library/no-await-sync-queries',
[1],
);
});

it('should have customized rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty(
'testing-library/prefer-query-matchers',
[
1,
{
validEntries: [
{ matcher: 'toBeVisible', query: 'get' },
{ matcher: 'toHaveTextContent', query: 'get' },
{ matcher: 'toBeEnabled', query: 'get' },
{ matcher: 'toBeDisabled', query: 'get' },
{ matcher: 'toBeChecked', query: 'get' },
],
},
],
);
expect(
config.rules?.['testing-library/prefer-query-matchers'],
).toStrictEqual([
1,
{
validEntries: [
{ matcher: 'toBeVisible', query: 'get' },
{ matcher: 'toHaveTextContent', query: 'get' },
{ matcher: 'toBeEnabled', query: 'get' },
{ matcher: 'toBeDisabled', query: 'get' },
{ matcher: 'toBeChecked', query: 'get' },
],
},
]);
});
});
10 changes: 6 additions & 4 deletions packages/eslint-config/tests/configs/react.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ describe('react config', () => {

it('should have rule from extended javascript config', async () => {
const config = await loadConfig('components/Button.tsx');
expect(config.rules).toHaveProperty('@typescript-eslint/no-unused-vars');
expect(config.rules).toHaveProperty('@typescript-eslint/no-explicit-any', [
2,
]);
});

it('should have rule from extended recommended react config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('react/jsx-key');
expect(config.rules).toHaveProperty('react/jsx-key', [2]);
});

it('should have explicitly added rule', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('react/no-array-index-key');
expect(config.rules).toHaveProperty('react/no-array-index-key', [2]);
});

it('should include react-hooks rule', async () => {
Expand All @@ -41,6 +43,6 @@ describe('react config', () => {

it('should have rule from extended recommended jsx-a11y config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('jsx-a11y/alt-text');
expect(config.rules).toHaveProperty('jsx-a11y/alt-text', [2]);
});
});
9 changes: 6 additions & 3 deletions packages/eslint-config/tests/configs/storybook.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ describe('storybook config', () => {

it('should include storybook rule for .storybook directory', async () => {
const config = await loadConfig('.storybook/main.js');
expect(config.rules).toHaveProperty('storybook/no-uninstalled-addons');
expect(config.rules).toHaveProperty(
'storybook/no-uninstalled-addons',
expect.arrayContaining([2]),
);
});

it('should have rule from extended recommended config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('storybook/story-exports');
expect(config.rules).toHaveProperty('storybook/story-exports', [2]);
});

it('should have rule from extended csf config', async () => {
const config = await loadConfig();
expect(config.rules).toHaveProperty('storybook/csf-component');
expect(config.rules).toHaveProperty('storybook/csf-component', [1]);
});
});
Loading
Loading