It aims at providing a general eslint config for:
-
assisting developer to obtain better code quality
-
no opinion on coding styles, leave it to @foray1010/prettier-config
X for requiring newer eslint or node (breaking changes)
Y for stricter rules
Z for looser rules
-
yarn add -DE @foray1010/eslint-config eslint prettier
-
Create an
eslint.config.js
in the project root-
For general purpose or Node.js project (support TypeScript)
import { eslintIgnoresConfig, eslintNodeConfig, } from '@foray1010/eslint-config' const config = [...eslintIgnoresConfig, ...eslintNodeConfig] export default config
-
For general frontend projects (support TypeScript)
import { eslintIgnoresConfig, eslintBrowserConfig, } from '@foray1010/eslint-config' const config = [...eslintIgnoresConfig, ...eslintBrowserConfig] export default config
-
For frontend React projects (support TypeScript)
import { eslintIgnoresConfig, eslintReactConfig, } from '@foray1010/eslint-config' const config = [...eslintIgnoresConfig, ...eslintReactConfig] export default config
-
You can apply config per different directories
import { applyConfig, eslintIgnoresConfig, eslintNodeConfig, eslintReactConfig, } from '@foray1010/eslint-config' const config = [ ...eslintIgnoresConfig, ...applyConfig( { filePrefixes: '.', ignores: ['src/**'], }, eslintNodeConfig, ), ...applyConfig( { filePrefixes: ['src'], }, eslintReactConfig, ), ] export default config
-
-
If the project support ES Modules, you can directly use
eslint
command with the following setting inpackage.json
.{ "type": "module" }
-
If the project does not support ES Modules, you have to put the config in
eslint.config.mjs
instead, and use the following npm script inpackage.json
. Note that your editor may not support custom eslint config path and may not work properly.{ "scripts": { "eslint": "ESLINT_USE_FLAT_CONFIG=true eslint --config eslint.config.mjs" } }
then use
npm run eslint
oryarn eslint
to replaceeslint