1.1.1 • Published 10 days ago

@abrahamsaanchez/eslint-config v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 days ago

@abrahamsaanchez/eslint-config

A configuration factory for ESLint, heavily inspired from @antfu/eslint-config but allowing Prettier.

  • Single quotes, no semi.
  • Indent to 4 spaces by default (in YAML files we use 2 spaces to avoid errors).
  • Designed to work with TypeScript and JSX out-of-box.
  • Lints also for json, markdown and yaml.
  • Sorted imports, dangling commas.
  • Reasonable defaults, best practices, only one-line of config
  • Respects .gitignore by default
  • ESLint Flat config, compose easily!

!IMPORTANT This config is written in the new ESLint Flat config.

Usage

Install

# Using NPM
npm i -D eslint @abrahamsaanchez/eslint-config

Create config file

With "type": "module" in package.json (recommended):

// eslint.config.js
import { EslintConfigurationFactory } from '@abrahamsaanchez/eslint-config';

export default EslintConfigurationFactory.create();

Using CommonJS:

// eslint.config.js
const {
    EslintConfigurationFactory
} = require('@abrahamsaanchez/eslint-config');

module.export = EslintConfigurationFactory.create();

Note that .eslintignore no longer works in Flat config.

Add script for package.json

For example:

{
    "scripts": {
        "lint": "eslint .",
        "lint:fix": "eslint . --fix"
    }
}

VS Code support

Install VS Code ESLint extension

Add the following settings to your .vscode/settings.json:

{
    // Code Actions for the editor on save
    "editor.codeActionsOnSave": {
        // Fix all the rules with eslint
        "source.fixAll.eslint": true
    },

    // Ensure the files are formatted on save
    "editor.formatOnSave": true,

    // Enable the ESlint flat config support
    "eslint.experimental.useFlatConfig": true,

    // Enable eslint for all supported languages
    "eslint.validate": [
        "html",
        "javascript",
        "javascriptreact",
        "json",
        "jsonc",
        "markdown",
        "typescript",
        "typescriptreact",
        "vue",
        "yaml"
    ]
}

License

MIT License © 2023-PRESENT Abraham Sánchez