Skip to content

Commit

Permalink
use flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaskasky committed Jan 23, 2025
1 parent 99b065d commit e33c165
Show file tree
Hide file tree
Showing 7 changed files with 3,452 additions and 1,643 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

116 changes: 0 additions & 116 deletions .eslintrc.json

This file was deleted.

122 changes: 122 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import js from '@eslint/js'
import configPrettier from 'eslint-config-prettier'
import importPlugin from 'eslint-plugin-import'
import prettierPlugin from 'eslint-plugin-prettier'
import * as tseslint from 'typescript-eslint'

export default tseslint.config(
// ─────────────────────────────────────────────────────────────
// 1) Main config, merges "extends" equivalents + custom rules
// ─────────────────────────────────────────────────────────────
{
files: ['**/*.{js,jsx,ts,tsx,json}'],
},
{
plugins: {
prettier: prettierPlugin,
'@typescript-eslint': tseslint.plugin,
},
},
js.configs.recommended,
tseslint.configs.recommended,
configPrettier,
importPlugin.flatConfigs.recommended,
{
rules: {
curly: ['warn', 'multi-line', 'consistent'],
eqeqeq: 'error',
'no-console': 'off',
'no-inner-declarations': 'off',
'no-var': 'error',
'prefer-const': 'error',
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],
'import/no-unresolved': ['error', { commonjs: true, amd: true }],
'import/export': 'error',
'import/no-duplicates': ['error'],
'import/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: true },
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
],
'newlines-between': 'never',
pathGroups: [
{
pattern: 'react',
group: 'builtin',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'prettier/prettier': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/no-use-before-define': 'off',
},
settings: {
react: { version: 'detect' },
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
'import/parsers': {
'@typescript-eslint/parser': ['.js', '.jsx', '.ts', '.tsx'],
},
'import/resolver': {
typescript: true,
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
paths: ['src'],
},
},
},
},
{
ignores: ['dist/'],
},

// ─────────────────────────────────────────────────────────────
// 2) Overrides for "src" — specify TS project config
// ─────────────────────────────────────────────────────────────
{
files: ['src'],
languageOptions: {
parserOptions: {
project: './tsconfig.json',
},
},
},

// ─────────────────────────────────────────────────────────────
// 3) Overrides for test files (if needed)
// ─────────────────────────────────────────────────────────────
{
files: ['tests/**/*.tsx', 'tests/**/*'],
rules: {},
},

// ─────────────────────────────────────────────────────────────
// 4) Overrides for JS config files in root
// ─────────────────────────────────────────────────────────────
{
files: ['./*.js'],
rules: {},
}
)
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"src",
"dist"
],
"packageManager": "pnpm@9.15.0",
"packageManager": "pnpm@8.15.0",
"scripts": {
"compile": "rm -rf dist && pnpm run '/^compile:.*/'",
"compile:esm": "tsc -p tsconfig.esm.json",
"compile:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
"fix": "pnpm run '/^fix:.*/'",
"fix:format": "prettier --write .",
"fix:lint": "eslint . --fix",
"fix:lint": "eslint --config ./eslint.config.ts --fix .",
"test": "pnpm run \"/^test:.*/\"",
"test:format": "prettier --list-different .",
"test:types": "tsc --noEmit",
Expand All @@ -58,6 +58,7 @@
],
"license": "MIT",
"devDependencies": {
"@eslint/js": "^9.18.0",
"@testing-library/dom": "10.0.0",
"@testing-library/react": "^16.2.0",
"@testing-library/user-event": "^14.6.1",
Expand All @@ -66,23 +67,23 @@
"@types/react-dom": "^19.0.2",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"eslint": "8.57.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.7.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"happy-dom": "^15.11.7",
"jiti": "^2.4.2",
"jotai": "2.11.1",
"jotai-effect": "link:",
"prettier": "^3.4.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-error-boundary": "^4.0.11",
"typescript": "^5.7.2",
"vite": "^6.0.4",
"vitest": "^2.1.8"
"typescript-eslint": "^8.21.0",
"vite": "^6.0.11",
"vitest": "^3.0.3"
},
"peerDependencies": {
"jotai": ">=2.5.0"
Expand Down
Loading

0 comments on commit e33c165

Please sign in to comment.