Skip to content

Commit

Permalink
chore: make the typescript linter a bit more indulgent in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschungelabenteuer committed Aug 13, 2024
1 parent add83e7 commit 68574fb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .changeset/gorgeous-pots-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@yungezeit/eslint-typescript": patch
"@yungezeit/eslint-base": patch
"@yungezeit/eslint-cypress": patch
"@yungezeit/eslint-storybook": patch
"@yungezeit/eslint-vue": patch
---

Made linter a bit more indulgent in test files
6 changes: 3 additions & 3 deletions presets/base/features/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import js from '@eslint/js';
const config = {
rules: {
...js.configs.recommended.rules,
// Only allow console.info, console.warn, and console.error.
/** Only allow console.info, console.warn, and console.error. */
'no-console': ['error', { allow: ['info', 'warn', 'error'] }],
// Sparse arrays aren't that confusing and may simplify code.
/** Sparse arrays aren't that confusing and may simplify code. */
'no-sparse-arrays': 'off',
// Allow unused variables that start with an underscore for later use.
/** Allow unused variables that start with an underscore for later use. */
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
},
};
Expand Down
11 changes: 10 additions & 1 deletion presets/typescript/features/test-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
export const testFiles = {
files: ['**/*.test.ts'],
rules: {
// Be a bit more indulgent in test files.
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',

// The following rules may be annoying when testing.
'max-classes-per-file': 'off',
'no-new': 'off',
},
Expand Down
9 changes: 9 additions & 0 deletions presets/typescript/features/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ import tseslint from 'typescript-eslint';
*/
const config = {
rules: {
/** Forcing `import type { }` makes imports clearer and my relieve parsers. */
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
/**
* There are some legit cases where index access is necessary.
* But keep in mind that members visibilities are lost when using index access.
*/
'@typescript-eslint/dot-notation': 'off',
/** Sometimes we just have no choice. */
'@typescript-eslint/no-explicit-any': 'off',
/** Sometimes we just have no choice. */
'@typescript-eslint/no-non-null-assertion': 'off',
/** This rule may be a bit unstable. */
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
/** Allow unused variables that start with an underscore for later use. */
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
Expand Down

0 comments on commit 68574fb

Please sign in to comment.