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
41 changes: 41 additions & 0 deletions eslint.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import tseslint from 'typescript-eslint';
import unicorn from 'eslint-plugin-unicorn';
import importX, { createNodeResolver } from 'eslint-plugin-import-x';
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
import vitest from '@vitest/eslint-plugin';
import globals from 'globals';

export default defineConfig(
Expand Down Expand Up @@ -128,5 +129,45 @@ export default defineConfig(
},
},

// Test rules.
{
files: ['**/*.@(test|spec).[tj]s?(x)'],
...vitest.configs.recommended,
rules: {
...vitest.configs.recommended.rules,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should also consider some of these "popular" ones:

  • vitest/no-focused-tests
  • vitest/no-disabled-tests
  • vitest/expect-expect
  • vitest/no-conditional-expect
  • vitest/no-standalone-expect

wdyt?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have them from the recommended preset
i just added more rules on top of it

'vitest/prefer-vi-mocked': 'error',
'vitest/prefer-hooks-on-top': 'error',
'vitest/no-duplicate-hooks': 'error',
'vitest/hoisted-apis-on-top': 'error',

'vitest/consistent-each-for': [
'error',
{
test: 'each',
it: 'each',
describe: 'each',
suite: 'each',
},
],

'vitest/consistent-test-filename': [
'error',
{
pattern: '\\.test\\.[tj]sx?$',
},
],

'vitest/consistent-test-it': [
'error',
{
fn: 'it',
withinDescribe: 'it',
},
],

'vitest/prefer-hooks-in-order': 'error',
},
},

globalIgnores(['**/dist', '**/.turbo']),
);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@eslint/core": "^1.1.0",
"@eslint/js": "^9.39.2",
"@types/node": "^25.2.2",
"@vitest/eslint-plugin": "^1.6.7",
"cspell": "^9.6.4",
"eslint": "^9.39.2",
"eslint-import-resolver-typescript": "^4.4.4",
Expand Down
6 changes: 4 additions & 2 deletions packages/design-system/tests/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ describe('Design System exports', () => {
const actualContent = fs.readFileSync('./src/index.ts', 'utf-8');
const actualLines = actualContent.split('\n').filter((line) => line.trim().length > 0);

expect(actualLines.length).toBe(expectedLines.length);

const tests = expectedLines.map((expectedLine, index) => {
return [actualLines[index], expectedLine];
});

it('should export all components', () => {
expect(actualLines.length).toBe(expectedLines.length);
});

// split expected by line and assert that each line is exported
it.each(tests)('"%s" is exported from the package', (actual, expected) => {
expect(actual).toBe(expected);
Expand Down
127 changes: 121 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.