Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stegripe/eslint-config
An ESLint shareable configuration that we used in our projects.
https://github.com/stegripe/eslint-config
eslint eslint-config lint tslint typescript typescript-eslint
Last synced: 4 days ago
JSON representation
An ESLint shareable configuration that we used in our projects.
- Host: GitHub
- URL: https://github.com/stegripe/eslint-config
- Owner: stegripe
- License: mit
- Created: 2022-05-08T09:37:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T18:37:58.000Z (5 days ago)
- Last Synced: 2024-11-11T19:36:18.911Z (5 days ago)
- Topics: eslint, eslint-config, lint, tslint, typescript, typescript-eslint
- Language: JavaScript
- Homepage:
- Size: 180 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-config
> A *forked* ESLint [shareable configuration](https://github.com/Hazmi35/eslint-config) that we used in our projects.## Install
```sh-session
npm install -D @stegripe/eslint-config # npm
pnpm add -D @stegripe/eslint-config # pnpm
yarn add -D @stegripe/eslint-config # yarn
```
This package has the required dependency installed automatically by peer dependencies by default on npm v7+, pnpm, or yarn. Install them manually if not.## Usage
This package requires ESLint Flat Configuration.Available configurations (most relevant):
- [common](./conf/common.js) - Common JavaScript rules.
- [typescript](./conf/typescript.js) - For usage with [TypeScript](https://www.typescriptlang.org).
- [modules](./conf/modules.js) - For usage with [ES Modules](https://nodejs.org/api/esm.html).
- [node](./conf/node.js) - For usage within a [Node.js](https://nodejs.org) or [Bun](https://bun.sh) environment.
- [prettier](./conf/prettier.js) - For code styling with [Prettier](https://prettier.io) (exclusive with ESLint Stylistic).
- [stylistic](./conf/stylistic.js) - For code styling with [ESLint Stylistic](https://eslint.style) (exclusive with Prettier).
- [browser](./conf/browser.js) - For usage within a browser environment (DOM and Web APIs).
- [edge](./conf/edge.js) - For usage within an edge/serverless environment. For example [Cloudflare Workers](https://workers.cloudflare.com/).
- [ignores](./conf/ignores.js) - To enable global ignores for ESLint. Needed for ESLint to ignore files that shouldn't be linted.### Configuration
Create an `eslint.config.js` file in the root of your project and add the following code:Node.js with CJS
```js
module.exports = (async () => {
const { common, node, stylistic, ignores } = await import("@stegripe/eslint-config");return [...common, ...node, ...stylistic, ...ignores];
})();
```Node.js with TypeScript
```js
import { common, modules, node, stylistic, typescript, ignores } from "@stegripe/eslint-config";export default [...common, ...modules, ...node, ...stylistic, ...typescript, ...ignores];
```Node.js with ESM
```js
import { common, modules, node, stylistic, ignores } from "@stegripe/eslint-config";export default [...common, ...modules, ...node, ...stylistic, ...ignores];
``````Usage with Prettier
```js
import { common, modules, node, prettier, ignores } from "@stegripe/eslint-config";// Prettier must not be used with stylistic config, because it will conflict with each other.
export default [...common, ...modules, ...node, ...prettier, ...ignores];
```Extending rules
Extending rules using the extend function is recommended.
```js
import { common, extend, modules, node, stylistic, typescript, ignores } from "./index.js";export default [...common, ...modules, ...node, ...stylistic, ...ignores, ...extend(typescript, [{
rule: "typescript/no-unnecessary-condition",
option: [
"warn",
{
allowConstantLoopConditions: false
}
]
// or
option: ["off"]
}])];
```