https://github.com/dvsa/eslint-config-ts
Shared linter config
https://github.com/dvsa/eslint-config-ts
Last synced: 10 months ago
JSON representation
Shared linter config
- Host: GitHub
- URL: https://github.com/dvsa/eslint-config-ts
- Owner: dvsa
- License: mit
- Created: 2020-02-03T09:26:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-05T07:50:49.000Z (over 2 years ago)
- Last Synced: 2024-12-06T19:12:01.745Z (over 1 year ago)
- Language: JavaScript
- Size: 305 KB
- Stars: 1
- Watchers: 10
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-config-ts
Shareable ESLint config for use in Node/Typescript projects.
### Why?
Rather than having to copy linter config files across code repos of the same project/tech stack, can pull in a standard shared config and dependencies from a single place and manage any changes/updates centrally.
### Rules
This config uses:
- Airbnb style guide rules (adapted for Typescript): https://github.com/airbnb/javascript
- ESLint Typescript plugin recommended rules: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin
- ESLint security plugin rules: https://github.com/nodesecurity/eslint-plugin-security
A few of the default rules are switched off/customised as specified in the config in `index.js`.
### Developers
When making changes to this package you are unable to npm link to test the package locally due a bug in npm where peer dependencies are not installed. Github Issue - https://github.com/npm/cli/issues/2339
### Prerequisites
- \>= npm 7.x.x
If the following dependencies are not present in your package.json, this package will install them (see `peerDependencies` in `package.json`):
```
eslint
@typescript-eslint/eslint-plugin
@typescript-eslint/typescript-estree
eslint-config-airbnb-typescript
eslint-plugin-import
eslint-plugin-jsx-a11y
eslint-plugin-react
eslint-plugin-react-hooks
eslint-plugin-security
eslint-plugin-jest
```
### Usage
1. Install the config in your project.
`npm install --save-dev @dvsa/eslint-config-ts`
2. Add a `.eslintrc` to your project root extending the config:
```
{
"extends": "@dvsa/eslint-config-ts"
}
```
If you need to override the shared config in any way to suit your specific project, for example by customising certain rules, you can do so here. See the [ESLint documentation](https://eslint.org/docs/user-guide/configuring "ESLint documentation") for details.
3. Add a `.eslintignore` to specify any project directories/files to exclude from the linter. ESLint already ignores `node_modules` by default.
4. Run the linter:
`(npx) eslint --ext .js,.ts .`
The `--ext` option is required to tell ESLint to lint `.ts` files (lints only `.js` by default) and `.` specifies the files/directory to lint.
If you are using VSCode, you can add the ESLint extension to see lint issues as you type. You might also want to add a pre-push hook to your project such that the linter runs on pushing code and fails the push if there are unresolved issues.
------------
This shared config was originally made by the FTTS (Future Theory Test Service) team for use across our different project repos using a Node/Typescript/Jest stack. To suit your project you may need to configure the `env` property in your `.eslintrc` for your specific tech stack.