Skip to content

Commit

Permalink
chore: use eslint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jul 17, 2024
1 parent d66ad9e commit 46762de
Show file tree
Hide file tree
Showing 9 changed files with 290 additions and 929 deletions.
75 changes: 0 additions & 75 deletions .eslintrc.js

This file was deleted.

11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ node_modules/
*.pem
tsconfig.tsbuildinfo
.env
**/$*.ts

# debug
npm-debug.log*

# client
client/.next/
client/out/
client/api/*
**/*.css.d.ts*

# server
server/index.js*
server/coverage/
12 changes: 0 additions & 12 deletions client/.gitignore

This file was deleted.

9 changes: 2 additions & 7 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@
"dev:client": "next dev -p 3000",
"dev:hcm": "hcm '**/*.module.css' -w",
"dev:aspida": "aspida --watch",
"dev:path": "pathpida --ignorePath .gitignore -s -w",
"dev:path": "pathpida --ignorePath ../.gitignore -s -w",
"build": "npm run generate && next build",
"start": "sh -c \"next start -p $(($PORT + 1))\"",
"lint": "run-p lint:js lint:prettier lint:style",
"lint:js": "eslint --ext .ts,.tsx,.js --ignore-path .gitignore .",
"lint:prettier": "prettier --check \"./**/*.{ts,tsx,js}\" --ignore-path .gitignore",
"lint:style": "stylelint \"**/*.css\" --ignore-path .gitignore",
"lint:fix": "npm run lint:js -- --fix && prettier --write \"./**/*.{ts,tsx,js}\" --ignore-path .gitignore && npm run lint:style -- --fix",
"generate": "run-p generate:*",
"generate:aspida": "aspida",
"generate:path": "pathpida --ignorePath .gitignore -s",
"generate:path": "pathpida --ignorePath ../.gitignore -s",
"hcm": "hcm '**/*.module.css'",
"test": "vitest run",
"test:watch": "vitest",
Expand Down
76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import js from '@eslint/js';
import gitignore from 'eslint-config-flat-gitignore';
import prettierConfig from 'eslint-config-prettier';
import reactPlugin from 'eslint-plugin-react';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{ files: ['**/*.(ts,js,tsx)'] },
gitignore(),
js.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.es2020,
},
},
plugins: {
react: reactPlugin,
},
settings: {
react: {
version: 'detect',
},
},
rules: {
eqeqeq: 'error',
'no-param-reassign': 'error',
'object-shorthand': ['error', 'always'],
'prefer-template': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-explicit-any': 'error',
complexity: ['error', 5],
'max-depth': ['error', 2],
'max-nested-callbacks': ['error', 3],
'max-lines': ['error', 200],
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
},
],
},
},
{
files: ['*.tsx'],
rules: {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'react/self-closing-comp': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
},
},
{
files: ['server/**/*.ts'],
rules: { '@typescript-eslint/explicit-function-return-type': ['error'] },
},
{
files: ['server/api/**/controller.ts', 'server/api/**/hooks.ts'],
rules: { '@typescript-eslint/explicit-function-return-type': ['off'] },
},
{
files: ['**/*.js'],
rules: { '@typescript-eslint/no-var-requires': ['off'] },
},
prettierConfig,
);
Loading

0 comments on commit 46762de

Please sign in to comment.