Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-config-airbnb-ts-decorator

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-config-airbnb-ts-decorator

Adds typescript support to Airbnb's ESLint config

  • 14.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

eslint-config-airbnb-ts-decorator

Version Downloads Last commit License PRs Welcome Code of conduct

Add typescript support to Airbnb's ESLint config's. This library should typically not be used. Instead use eslint-config-airbnb-ts-base or eslint-config-airbnb-ts

This started as a fork from https://github.com/iamturns/eslint-config-airbnb-typescript

install eslint-config-airbnb-ts-decorator
npm install eslint-config-airbnb-ts-decorator --save-dev

2) Configure ESLint

Extend your current airbnb config with this one to add typescript support

Add "extends": ["airbnb", "airbnb-ts-decorator"] to your ESLint config file.

An example .eslintrc.js:

module.exports = {
  extends: ['airbnb', 'airbnb-ts-decorator', 'prettier'],
};

Also note that we're enabling @typescript-eslint/eslint-plugin's recommended rules by default You can turn them off if you want but since they're recommended they should probably be enabled.

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:

 module.exports = {
   extends: ['airbnb-ts'],
+  parserOptions: {
+    project: './tsconfig.json',
+ }
 };

4) 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

Does this work with JavaScript files too?

Yep! This config is just decorating eslint-config-airbnb with TypeScript support.

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.

{
  "extends": "./tsconfig.json",
  "include": ["src/**/*.ts", "src/**/*.js", "test/**/*.ts"]
}

Update your ESLint config file:

parserOptions: {
-  project: './tsconfig.json',
+  project: './tsconfig.eslint.json',
}

I wish this config would support [...]

The goal of eslint-config-airbnb-ts-decorator is to simply decorate eslint-config-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:

module.exports = {
  extends: [
    'airbnb',
    'airbnb-ts-decorator',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
    'prettier',
  ],
};

Credits

Authored by Matt Turnbull (iamturns.com / @iamturns)

Maintained by Anders Nilsson (nilssonanders79@gmail.com)

A big thank you to all contributors!

License

Open source licensed as MIT.

Keywords

FAQs

Package last updated on 17 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc