Shared eslint configuration for my personal TypeScript projects.
-
Install the dependencies:
$ npm install -DE @kayahr/eslint-config
-
Create an
eslint.config.js
(Oreslint.config.mjs
in CommonJS projects) configuration file with the following content (Modify environment if necessary):{ import kayahrConfigs from "@kayahr/eslint-config"; import globals from "globals"; export default [ { ignores: [ "doc", "lib" ] }, { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, { files: [ "**/*.js" ], languageOptions: { sourceType: "commonjs" } }, ...kayahrConfigs ]; }
The block with
sourceType: "commonjs"
is only needed for CommonJS projects. -
Add the following script line to
package.json
:"lint": "eslint --max-warnings 0"
-
Reference the
lint
script in thetest
script:"test": "npm run -s lint && npm run -s check"
-
Run eslint by typing
npm test
ornpm run lint
.