* #708 apply strictier linting rules and fix simple eslint bugs * #708 fix eslint errors relate to promise * #708 fix eslint import/no-extraneous-dependencies * #708 fix eslint errors of react-hook * #708 enable eslint check for typescript --------- Co-authored-by: lethemanh <lethemanh@lethemanhs-MacBook-Pro.local>
This commit is contained in:
+65
-40
@@ -1,74 +1,99 @@
|
||||
import js from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
import react from "eslint-plugin-react";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
import jest from "eslint-plugin-jest";
|
||||
import prettier from "eslint-config-prettier";
|
||||
import js from '@eslint/js'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import tanstackQuery from '@tanstack/eslint-plugin-query'
|
||||
import cozyReact from 'eslint-config-cozy-app/react'
|
||||
|
||||
// Flatten cozyReact config (may be an object or array)
|
||||
const cozyReactConfigs = Array.isArray(cozyReact) ? cozyReact : [cozyReact]
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: ["dist", "build", "node_modules"],
|
||||
ignores: [
|
||||
'dist/',
|
||||
'build/',
|
||||
'node_modules/',
|
||||
'coverage/',
|
||||
'public/',
|
||||
'*.config.js',
|
||||
'*.config.ts',
|
||||
'fileTransformer.ts'
|
||||
]
|
||||
},
|
||||
|
||||
js.configs.recommended,
|
||||
|
||||
...tseslint.configs.recommended,
|
||||
|
||||
// TanStack Query recommended rules
|
||||
...tanstackQuery.configs['flat/recommended'],
|
||||
|
||||
// Cozy React recommended rules
|
||||
...cozyReactConfigs,
|
||||
|
||||
{
|
||||
files: ["**/*.{js,jsx,ts,tsx}"],
|
||||
files: ['**/*.{js,jsx,ts,tsx}'],
|
||||
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
parserOptions: {
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: { jsx: true },
|
||||
project: true,
|
||||
},
|
||||
},
|
||||
|
||||
plugins: {
|
||||
react,
|
||||
"react-hooks": reactHooks,
|
||||
import: importPlugin,
|
||||
jest,
|
||||
project: true
|
||||
}
|
||||
},
|
||||
|
||||
settings: {
|
||||
react: {
|
||||
version: "detect",
|
||||
},
|
||||
version: 'detect'
|
||||
}
|
||||
},
|
||||
|
||||
rules: {
|
||||
/* React */
|
||||
"react/react-in-jsx-scope": "off", // React 18+
|
||||
"react/prop-types": "off",
|
||||
'react/react-in-jsx-scope': 'off', // React 18+
|
||||
'react/prop-types': 'off',
|
||||
|
||||
/* Hooks */
|
||||
"react-hooks/rules-of-hooks": "error",
|
||||
"react-hooks/exhaustive-deps": "warn",
|
||||
'react-hooks/rules-of-hooks': 'error',
|
||||
'react-hooks/exhaustive-deps': 'warn',
|
||||
|
||||
/* Imports */
|
||||
"import/order": "off",
|
||||
'import/order': 'off',
|
||||
|
||||
/* TS */
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ argsIgnorePattern: "^_" },
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{ argsIgnorePattern: '^_' }
|
||||
],
|
||||
|
||||
/* Jest */
|
||||
"jest/no-disabled-tests": "warn",
|
||||
"jest/no-focused-tests": "error",
|
||||
// TO DO: Turn these back on warning
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
||||
'@typescript-eslint/no-unsafe-call': 'warn',
|
||||
'@typescript-eslint/explicit-function-return-type': 'warn',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
||||
'@typescript-eslint/no-unsafe-argument': 'warn',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
||||
'@typescript-eslint/no-unsafe-return': 'warn',
|
||||
'@typescript-eslint/no-base-to-string': 'warn',
|
||||
'@typescript-eslint/no-misused-promises': 'warn',
|
||||
'@typescript-eslint/no-dynamic-delete': 'warn',
|
||||
'@typescript-eslint/await-thenable': 'warn',
|
||||
'@typescript-eslint/no-floating-promises': 'warn',
|
||||
'@typescript-eslint/no-redundant-type-constituents': 'warn',
|
||||
'@typescript-eslint/require-await': 'warn',
|
||||
|
||||
/* Prettier compatibility */
|
||||
...prettier.rules,
|
||||
/* Jest */
|
||||
'jest/no-disabled-tests': 'warn',
|
||||
'jest/no-focused-tests': 'error',
|
||||
|
||||
/* Keep cozyReact prettier options but skip singleQuote/semi to avoid unnecessary changes */
|
||||
'prettier/prettier': 'error',
|
||||
|
||||
/* No noises */
|
||||
"no-debugger": "error",
|
||||
"no-console": ["warn", { allow: ["info", "warn", "error"] }],
|
||||
},
|
||||
},
|
||||
];
|
||||
'no-debugger': 'error',
|
||||
'no-console': ['warn', { allow: ['info', 'warn', 'error'] }]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user