Skip to content

Commit

Permalink
feat(eslint-config): make all config parts type-checked
Browse files Browse the repository at this point in the history
  • Loading branch information
rozsival committed Oct 26, 2023
1 parent afc90ef commit b41badf
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"eslint-plugin-vitest": "^0.3.8"
},
"devDependencies": {
"@types/eslint": "^8.44.6",
"eslint": "^8.52.0",
"prettier": "^3.0.3",
"react": "^18.2.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/base/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Linter } from 'eslint';

import { overrides } from './overrides';
import { rules } from './rules';

Expand Down Expand Up @@ -42,4 +44,4 @@ export const config = {
'import/resolver': { typescript: {} },
},
overrides,
};
} satisfies Linter.Config;
4 changes: 3 additions & 1 deletion packages/eslint-config/src/base/overrides/javascript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const javascript = {
import type { Linter } from 'eslint';

export const javascript: Linter.ConfigOverride = {
files: '*.js',
rules: {
'@typescript-eslint/no-var-requires': 'off',
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/base/overrides/tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const tests = {
import type { Linter } from 'eslint';

export const tests: Linter.ConfigOverride = {
files: ['*.test.ts', '*.test.tsx'],
extends: ['plugin:vitest/recommended'],
rules: {
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/base/overrides/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const typescript = {
import type { Linter } from 'eslint';

export const typescript: Linter.ConfigOverride = {
files: ['*.ts', '*.tsx'],
extends: [
'plugin:@typescript-eslint/recommended-requiring-type-checking',
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/base/rules/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const common = {
import type { Linter } from 'eslint';

export const common: Linter.RulesRecord = {
'array-callback-return': [
'error',
{
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/base/rules/imports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const imports = {
import type { Linter } from 'eslint';

export const imports: Linter.RulesRecord = {
'import/extensions': [
'error',
'ignorePackages',
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/base/rules/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const typescript = {
import type { Linter } from 'eslint';

export const typescript: Linter.RulesRecord = {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'error',
};
4 changes: 3 additions & 1 deletion packages/eslint-config/src/base/rules/unicorn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const unicorn = {
import type { Linter } from 'eslint';

export const unicorn: Linter.RulesRecord = {
'unicorn/no-array-callback-reference': 'off',
'unicorn/prevent-abbreviations': [
'error',
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/react/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Linter } from 'eslint';

import { overrides } from './overrides';
import { rules } from './rules';

Expand All @@ -9,4 +11,4 @@ export const config = {
settings: {
react: { version: 'detect' },
},
};
} satisfies Linter.Config;
4 changes: 3 additions & 1 deletion packages/eslint-config/src/react/overrides.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const overrides = [
import type { Linter } from 'eslint';

export const overrides: Linter.ConfigOverride[] = [
{
files: '*.test.tsx',
extends: ['plugin:jest-dom/recommended', 'plugin:testing-library/react'],
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/react/rules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const rules = {
import type { Linter } from 'eslint';

export const rules: Linter.RulesRecord = {
'react/function-component-definition': [
'error',
{
Expand Down
18 changes: 15 additions & 3 deletions pnpm-lock.yaml

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

0 comments on commit b41badf

Please sign in to comment.