A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://typescript-eslint.io/getting-started/ below:

Getting Started | typescript-eslint

Getting Started Quickstart

This page is a quick-start for ESLint's new "flat" config format to go from zero to linting with our recommended rules on your TypeScript code as quickly as possible.

Step 1: Installation

First, install the required packages for ESLint, TypeScript, and our tooling:

npm install --save-dev eslint @eslint/js typescript typescript-eslint
yarn add --dev eslint @eslint/js typescript typescript-eslint
pnpm add --save-dev eslint @eslint/js typescript typescript-eslint
Step 2: Configuration

Next, create an eslint.config.mjs config file in the root of your project, and populate it with the following:

eslint.config.mjs



import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
);

This code will enable our recommended configuration for linting.

Details Aside on ESLint's defineConfig()

ESLint also provides a defineConfig() helper similar to tseslint.config(). However, there is a types incompatibility issue that causes type errors to incorrectly be reported when mixing typescript-eslint's configs and defineConfig(). For now we recommend using tseslint.config() for use with typescript-eslint's configs.

See typescript-eslint#10899 for more details.

Aside on file extensions

The .mjs extension makes the file use the ES modules (ESM) format. Node interprets .js files in the CommonJS (CJS) format by default, but if you have "type": "module" in your package.json, you can also use eslint.config.js.

Step 3: Running ESLint

Open a terminal to the root of your project and run the following command:

ESLint will lint all TypeScript compatible files within the current folder, and will output the results to your terminal.

Next Steps

If you're having problems getting this working, please have a look at our Troubleshooting & FAQs.

Additional Configs

We recommend you consider enabling the following two configs:

eslint.config.mjs

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.stylistic,
);

You can read more about these in our shared configurations docs.

Typed Linting

We also provide a plethora of powerful rules that utilize the power of TypeScript's type information. Visit the next page for a typed rules setup guide.

Documentation Resources

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4