Airbnb's ESLint config with TypeScript support
Installations
npm install eslint-config-airbnb-typescript
Developer
iamturns
Developer Guide
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
No
Node Version
17.2.0
NPM Version
6.14.18
Statistics
1,045 Stars
223 Commits
100 Forks
3 Watching
25 Branches
20 Contributors
Updated on 26 Nov 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
291,700,278
Last day
-4.9%
431,721
Compared to previous day
Last week
3.4%
2,283,638
Compared to previous week
Last month
14.4%
9,413,135
Compared to previous month
Last year
21.9%
105,773,559
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
3
eslint-config-airbnb-typescript
Enhances Airbnb's ESLint config with TypeScript support
[!IMPORTANT]
This repo has been archived
After six years and reaching 2 million weekly downloads, I can no longer give this project the attention it deserves.
Please fork this repo and carry it forward! I'll happily share links to forks here.
A huge thank you to all contributors along the way ❤️
Setup
1) Setup regular Airbnb config
Make sure you have the regular Airbnb config setup. If you are using React, use eslint-config-airbnb, or if you aren't using React, use eslint-config-airbnb-base.
2) Install dependencies (and peer dependencies)
1npm install eslint-config-airbnb-typescript \ 2 @typescript-eslint/eslint-plugin@^7.0.0 \ 3 @typescript-eslint/parser@^7.0.0 \ 4 --save-dev
3) Configure ESLint
Within your ESLint config file:
1extends: [ 2 'airbnb', 3+ 'airbnb-typescript' 4]
If you don't need React support:
1extends: [ 2 'airbnb-base', 3+ 'airbnb-typescript/base' 4]
4) Configure the ESLint TypeScript parser
This config requires knowledge of your TypeScript config.
In your ESLint config, set parserOptions.project to the path of your tsconfig.json
.
For example:
1{ 2 extends: ['airbnb', 'airbnb-typescript'], 3+ parserOptions: { 4+ project: './tsconfig.json' 5+ } 6}
5) Run ESLint
Open a terminal to the root of your project, and run the following command:
npx eslint . --ext .js,.jsx,.ts,.tsx
ESLint will lint all .js, .jsx, .ts, and .tsx files within the current folder, and output results to your terminal.
You can also get results in realtime inside most IDEs via a plugin.
FAQ
I get this error when running ESLint: "The file must be included in at least one of the projects provided"
This means you are attempting to lint a file that tsconfig.json
doesn't include.
A common fix is to create a tsconfig.eslint.json
file, which extends your tsconfig.json
file and includes all files you are linting.
1{ 2 "extends": "./tsconfig.json", 3 "include": ["src/**/*.ts", "src/**/*.js", "test/**/*.ts"] 4}
Update your ESLint config file:
1parserOptions: { 2- project: './tsconfig.json', 3+ project: './tsconfig.eslint.json', 4}
Why do I need the peer dependencies?
@typescript-eslint/eslint-plugin
is a peer dependency due to a limitation within ESLint. See issue, RFC, and progress.
@typescript-eslint/parser
is a peer dependency because the version number must match @typescript-eslint/eslint-plugin
.
I wish this config would support [...]
This config simply enhances the Airbnb with TypeScript support. It's not a single config to cater for all TypeScript linting requirements. For additional functionality, alter your ESLint config file. For example:
1module.exports = { 2 extends: [ 3 'airbnb', 4 'airbnb-typescript', 5 'airbnb/hooks', 6 'plugin:@typescript-eslint/recommended-type-checked', // @typescript-eslint @v6 7 'plugin:@typescript-eslint/stylistic-type-checked', // @typescript-eslint @v6 8 // 'plugin:@typescript-eslint/recommended', // @typescript-eslint @v5 9 // 'plugin:@typescript-eslint/recommended-requiring-type-checking', // @typescript-eslint @v5 10 ], 11};
My personal ESLint config file with support for Jest, Promises, and Prettier can be found in create-exposed-app.
Why is import/no-unresolved
disabled?
Two reasons:
- It requires additional configuration, which may be different for monorepo's, webpack usage, etc
- The rule offers little value in a TypeScript world, as the TypeScript compiler will catch these errors
If you would like to enable this rule, then:
- Enable the rule within your config:
'import/no-unresolved': 'error'
- Install and configure the TypeScript import resolver: eslint-import-resolver-typescript
Additional Documentation
Credits
Authored and maintained by Matt Turnbull (iamturns.com / @iamturns)
A big thank you to all contributors!
License
Open source licensed as MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
3 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
Reason
Found 4/9 approved changesets -- score normalized to 4
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 28 are checked with a SAST tool
Score
3.6
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to eslint-config-airbnb-typescript
eslint-config-airbnb-typescript-prettier
Airbnb's ESLint config with TypeScript and Prettier support
eslint-config-typescript-airbnb-prettier
An eslint configuration that integrates eslint-config-airbnb-base, eslint-config-airbnb-typescript-base, @typescript-eslint/eslint-plugin and eslint-config-prettier
@kesills/eslint-config-airbnb-typescript
Airbnb's ESLint config with TypeScript support
eslint-config-airbnb-base
Airbnb's base JS ESLint config, following our styleguide