1
1
mirror of https://github.com/theoludwig/eslint-config-conventions.git synced 2024-11-12 22:33:14 +01:00
ESLint shareable config to enforce strict conventions and good code quality. https://www.npmjs.com/package/eslint-config-conventions
Go to file
2024-11-11 20:46:20 +01:00
.github build(deps): update latest 2024-11-11 20:46:20 +01:00
test feat!: add support for ESLint v9 2024-10-07 17:28:54 +02:00
.editorconfig chore: initial commit 2022-02-19 16:05:21 +01:00
.gitattributes chore: initial commit 2022-02-19 16:05:21 +01:00
.gitignore chore: replace tape with tap 2022-03-19 14:28:00 +01:00
.npmrc chore: remove usage of git hooks (husky, lint-staged, commitlint) + usage of node --run 2024-07-25 14:00:05 +02:00
.prettierrc.json chore: better Prettier config for easier reviews 2023-10-23 23:00:22 +02:00
.releaserc.json chore: remove usage of git hooks (husky, lint-staged, commitlint) + usage of node --run 2024-07-25 14:00:05 +02:00
CODE_OF_CONDUCT.md fix: update author - Théo LUDWIG 2023-07-02 15:57:44 +02:00
CONTRIBUTING.md fix: update author - Théo LUDWIG 2023-07-02 15:57:44 +02:00
eslint.config.js fix: relax unicorn/consistent-destructuring 2024-11-11 20:42:08 +01:00
eslint.config.mjs chore: remove not needed @ts-check 2024-11-11 20:40:36 +01:00
index.d.ts style: fix Prettier 2024-10-07 17:35:13 +02:00
LICENSE docs(license): add email address 2024-01-30 01:28:25 +01:00
package-lock.json build(deps): update latest 2024-11-11 20:46:20 +01:00
package.json build(deps): update latest 2024-11-11 20:46:20 +01:00
README.md docs: eslint.config.js 2024-10-29 23:48:40 +01:00
tsconfig.json chore: remove usage of git hooks (husky, lint-staged, commitlint) + usage of node --run 2024-07-25 14:00:05 +02:00

eslint-config-conventions

ESLint shareable config to enforce strict conventions and good code quality.

CONTRIBUTING Licence MIT Contributor Covenant
lint action test action
Conventional Commits semantic-release npm version

📜 About

eslint-config-conventions is a ESLint configuration to enforce strict conventions and good code quality. It supports both JavaScript and TypeScript.

This configuration is mostly for catching bugs and code-quality so it is recommended to use it with Prettier for a consistent code style, it works with any .prettierrc.json configuration.

More information about formatting rules vs code-quality rules can be found on Prettier vs. Linters.

⚙️ Getting Started

Prerequisites

Node.js >= 20.11.0

Installation

npm install --save-dev \
  eslint@^9.12.0 \
  eslint-plugin-promise@^7.1.0 \
  eslint-plugin-unicorn@^56.0.0 \
  eslint-plugin-import-x@^4.3.1 \
  globals@^15.10.0 \
  typescript@~5.5.4 \
  typescript-eslint@^8.8.0 \
  eslint-config-conventions@latest

Dependencies are:

Configuration

eslint.config.js

import typescriptESLint from "typescript-eslint"
import configConventions from "eslint-config-conventions"

export default typescriptESLint.config(...configConventions, {
  files: ["**/*.ts", "**/*.tsx"],
  languageOptions: {
    parser: typescriptESLint.parser,
    parserOptions: {
      projectService: true,
      tsconfigRootDir: import.meta.dirname,
    },
  },
})
npm install --save-dev prettier

# Create an empty config file to let editors and other tools know you are using Prettier
# You can personalize it with your own rules
echo "{}" > .prettierrc.json

That's all! No need to update the eslint.config.js configuration.

We discourage usage of eslint-config-prettier and eslint-plugin-prettier, as eslint-config-conventions doesn't include any stylistic rules, and including these packages has several drawbacks (listed in Integrating with Linters) and brings no benefits for this configuration.

package.json

{
  "scripts": {
    "lint:eslint": "eslint . --max-warnings 0",
    "lint:prettier": "prettier . --check"
  }
}

Usage

node --run lint:eslint
# or to apply automatic fixes to code
node --run lint:eslint -- --fix

# Validate code formatting in all supported languages by Prettier
node --run lint:prettier

💡 Contributing

Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake.

The steps to contribute can be found in the CONTRIBUTING.md file.

📄 License

MIT