Skip to content

Commit

Permalink
chore: 🔧 migrate eslint config to flat config file
Browse files Browse the repository at this point in the history
  • Loading branch information
djdembeck committed Aug 8, 2024
1 parent 622267f commit 2915ed8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 41 deletions.
41 changes: 0 additions & 41 deletions .eslintrc.json

This file was deleted.

71 changes: 71 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import jest from 'eslint-plugin-jest'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import globals from 'globals'
import tsParser from '@typescript-eslint/parser'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'
import { includeIgnoreFile } from '@eslint/compat'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
})
const gitignorePath = path.resolve(__dirname, '.gitignore')

export default [
...compat.extends('eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'),
includeIgnoreFile(gitignorePath),
{
ignores: ['dist/']
},
{
plugins: {
'@typescript-eslint': typescriptEslint,
jest,
'simple-import-sort': simpleImportSort
},

languageOptions: {
globals: {
...globals.node,
...jest.environments.globals.globals
},

parser: tsParser,
ecmaVersion: 2021,
sourceType: 'module'
}
},
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],

rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// Packages `react` related packages come first.
['^react', '^@?\\w'],
// Internal packages.
['^(@|components)(/.*|$)'],
// Side effect imports.
['^\\u0000'],
// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Style imports.
['^.+\\.?(css)$']
]
}
],
'simple-import-sort/exports': 'error'
}
}
]
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"zod": "^3.20.6"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.8.0",
"@jest/types": "29.6.3",
"@redocly/cli": "1.19.0",
"@types/html-to-text": "9.0.4",
Expand All @@ -64,6 +67,7 @@
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.6.0",
"eslint-plugin-simple-import-sort": "12.1.1",
"globals": "^15.9.0",
"jest": "29.7.0",
"nodemon": "3.1.4",
"prettier": "3.2.5",
Expand Down

0 comments on commit 2915ed8

Please sign in to comment.