2.0.0 • Published 1 month ago

@lcooper/eslint-config-typescript-react v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@lcooper/eslint-config-typescript-react

npm ci license

An ESlint shareable flat config for TypeScript React projects. An extension of the rules from @lcooper/eslint-config-react.

Installation

The peer dependency eslint must be installed alongside this package.

install with npm:

npm install -D eslint @lcooper/eslint-config-typescript-react

install with yarn:

yarn add -D eslint @lcooper/eslint-config-typescript-react

This config is meant to be used in addition to the base @lcooper/eslint-config-typescript config, so that should be installed as well.

Note: This project requires Eslint version >=8.56, NodeJS version ^18.18.0 || >=20.0.0, and Typescript version >=4.7.4.

Usage

Add an eslint.config.js config file to your project's root directory.

Note: this package exports a single flat config object, so no need for the ... spread syntax when using it.

import baseConfig from '@lcooper/eslint-config-typescript';
import reactConfig from '@lcooper/eslint-config-typescript-react';

export default [
    ...baseConfig,
    reactConfig,
];

If your project does not specify "type": "module" in its package.json file, then eslint.config.js must be in CommonJS format:

const baseConfig = require('@lcooper/eslint-config-typescript'),
    reactConfig = require('@lcooper/eslint-config-typescript-react');

module.exports = [
    ...baseConfig,
    reactConfig,
];

Check out the docs for @lcooper/eslint-config-typescript for more information on configuring eslint to lint with type information.

This project is no longer compatable with the legacy eslintrc format, and requires you use the flat config format. Check out this page for more details about migrating from the eslintrc format to the flat config format.

File Matching

By default, this config matches .js, .mjs, .jsx, .ts, .mts, and .tsx files using the glob **/*.{js,mjs,jsx,ts,mts,tsx}. More specificity can be achieved by overwriting the files option with your own globs, like in this example:

import baseConfig from '@lcooper/eslint-config-typescript';
import reactConfig from '@lcooper/eslint-config-typescript-react';

export default [
    ...baseConfig,
    {
        ...reactConfig,
        files: ['src/**/*.{js,mjs,jsx,ts,mts,tsx}'],
    },
];

Related

License

MIT

2.0.0

1 month ago

1.3.0

1 year ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago