Eslint google config typescript

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

ESLint shareable config for the Google JavaScript style guide

License

google/eslint-config-google

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

$ npm install --save-dev eslint eslint-config-google 

Once the eslint-config-google package is installed, you can use it by specifying google in the extends section of your ESLint configuration.

 "extends": "google", "rules":  // Additional, per-project rules. > >

Using the google config with eslint:recommended

There are several rules in the eslint:recommended ruleset that Google style is not opinionated about that you might want to enforce in your project.

To use Google style in conjunction with ESLint’s recommended rule set, extend them both, making sure to list google last:

 "extends": ["eslint:recommended", "google"], "rules":  // Additional, per-project rules. > >

To see how the google config compares with eslint:recommended , refer to the source code of index.js , which lists every ESLint rule along with whether (and how) it is enforced by the google config.

Источник

Configurations

ESLint shareable configurations exist to provide a comprehensive list of rules settings that you can start with. @typescript-eslint/eslint-plugin includes built-in configurations you can extend from to pull in the recommended starting rules.

With the exception of all , strict , and strict-type-checked , all configurations are considered «stable». Rule additions and removals are treated as breaking changes and will only be done in major version bumps.

Getting Started​

Projects Without Type Checking​

If your project does not enable typed linting, we suggest enabling the recommended and stylistic configurations to start:

module.exports =   extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/stylistic', ], >; 

If a majority of developers working on your project are comfortable with TypeScript and typescript-eslint, consider replacing recommended with strict .

Projects With Type Checking​

If your project enables typed linting, we suggest enabling the recommended-type-checked and stylistic-type-checked configurations to start:

module.exports =   extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended-type-checked', 'plugin:@typescript-eslint/stylistic-type-checked', ], >; 

If a majority of developers working on your project are comfortable with TypeScript and typescript-eslint, consider replacing recommended-type-checked with strict-type-checked .

We recommend that most projects should extend from one of:

  • recommended : Recommended rules for code correctness that you can drop in without additional configuration.
  • recommended-type-checked : Additional recommended rules that require type information.
  • strict : Additional strict rules that can also catch bugs but are more opinionated than recommended rules.
  • strict-type-checked : Additional strict rules require type information.

Additionally, we provide a stylistic config that enforces concise and consistent code. We recommend that most projects should extend from either:

  • stylistic : Stylistic rules you can drop in without additional configuration.
  • stylistic-type-checked : Additional stylistic rules that require type information.

These configurations are our recommended starting points, but you don’t need to use them as-is. ESLint allows configuring own rule settings on top of extended configurations. See ESLint’s Configuring Rules docs.

Recommended rules for code correctness that you can drop in without additional configuration. These rules are those whose reports are almost always for a bad practice and/or likely bug. recommended also disables core ESLint rules known to conflict with typescript-eslint rules or cause issues in TypeScript codebases.

module.exports =   extends: ['plugin:@typescript-eslint/recommended'], >; 

See configs/recommended.ts for the exact contents of this config.

Contains all of recommended along with additional recommended rules that require type information. Rules newly added in this configuration are similarly useful to those in recommended .

module.exports =   extends: ['plugin:@typescript-eslint/recommended-type-checked'], >; 

See configs/recommended-type-checked.ts for the exact contents of this config.

strict ​

Contains all of recommended , as well as additional strict rules that can also catch bugs. Rules added in strict are more opinionated than recommended rules and might not apply to all projects.

module.exports =   extends: ['plugin:@typescript-eslint/strict'], >; 

See configs/strict.ts for the exact contents of this config.

We recommend a TypeScript project extend from plugin:@typescript-eslint/strict only if a nontrivial percentage of its developers are highly proficient in TypeScript.

strict-type-checked ​

Contains all of recommended , recommended-type-checked , and strict , along with additional strict rules that require type information. Rules newly added in this configuration are similarly useful (and opinionated) to those in strict .

module.exports =   extends: ['plugin:@typescript-eslint/strict-type-checked'], >; 

See configs/strict-type-checked.ts for the exact contents of this config.

We recommend a TypeScript project extend from plugin:@typescript-eslint/strict-type-checked only if a nontrivial percentage of its developers are highly proficient in TypeScript.

stylistic ​

Rules considered to be best practice for modern TypeScript codebases, but that do not impact program logic. These rules are generally opinionated about enforcing simpler code patterns.

module.exports =   extends: ['plugin:@typescript-eslint/stylistic'], >; 

See configs/stylistic.ts for the exact contents of this config.

stylistic-type-checked ​

Contains all of stylistic , along with additional stylistic rules that require type information. Rules newly added in this configuration are similarly opinionated to those in stylistic .

module.exports =   extends: ['plugin:@typescript-eslint/stylistic-type-checked'], >; 

See configs/stylistic-type-checked.ts for the exact contents of this config.

Other Configurations​

typescript-eslint includes a few utility configurations.

all ​

Enables each the rules provided as a part of typescript-eslint. Note that many rules are not applicable in all codebases, or are meant to be configured.

See configs/all.ts for the exact contents of this config.

We do not recommend TypeScript projects extend from plugin:@typescript-eslint/all . Many rules conflict with each other and/or are intended to be configured per-project.

base ​

A minimal ruleset that sets only the required parser and plugin options needed to run typescript-eslint. We don’t recommend using this directly; instead, extend from an earlier recommended rule.

This config is automatically included if you use any of the recommended configurations.

See configs/base.ts for the exact contents of this config.

disable-type-checked ​

A utility ruleset that will disable type-aware linting and all type-aware rules available in our project. This config is useful if you’d like to have your base config concerned with type-aware linting, and then conditionally use overrides to disable type-aware linting on specific subsets of your codebase.

See configs/disable-type-checked.ts for the exact contents of this config.

If you use type-aware rules from other plugins, you will need to manually disable these rules or use a premade config they provide to disable them.

module.exports =   extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', ], overrides: [   files: ['*.js'], extends: ['plugin:@typescript-eslint/disable-type-checked'], >, ], >; 

This ruleset is meant to be used after extending eslint:recommended . It disables core ESLint rules that are already checked by the TypeScript compiler. Additionally, it enables rules that promote using the more modern constructs TypeScript allows for.

module.exports =   extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', ], >; 

This config is automatically included if you use any of the recommended configurations.

See configs/eslint-recommended.ts for the exact contents of this config.

Suggesting Configuration Changes​

If you feel strongly that a specific rule should (or should not) be one of these configurations, please file an issue along with a detailed argument explaining your reasoning.

Formatting​

None of the preset configs provided by typescript-eslint enable formatting rules (rules that only serve to enforce code whitespace and other trivia). We strongly recommend you use Prettier or an equivalent for formatting your code, not ESLint formatting rules. See What About Formatting? > Suggested Usage.

Источник

Читайте также:  Python get regex match
Оцените статью