1.0.2 • Published 9 months ago

@wangyjhh/eslint-config v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

@wangyjhh/eslint-config

This is a personal ESLint configuration preset inspired by antfu.

For more details go here

Usage

pnpm i -D eslint @wangyjhh/eslint-config

And create eslint.config.mjs in your project root:

// eslint.config.mjs
import wangyjhh from '@wangyjhh/eslint-config'

export default wangyjhh()

Add script for package.json

For example:

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

IDE Support (auto fix on save)

Install VS Code ESLint extension

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

{
    // Disable the default formatter, use eslint instead
    "prettier.enable": false,
    "editor.formatOnSave": false,

    // Auto fix
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": "explicit",
        "source.organizeImports": "never"
    },

    // Silent the stylistic rules in you IDE, but still auto fix them
    "eslint.rules.customizations": [
        { "rule": "style/*", "severity": "off", "fixable": true },
        { "rule": "format/*", "severity": "off", "fixable": true },
        { "rule": "*-indent", "severity": "off", "fixable": true },
        { "rule": "*-spacing", "severity": "off", "fixable": true },
        { "rule": "*-spaces", "severity": "off", "fixable": true },
        { "rule": "*-order", "severity": "off", "fixable": true },
        { "rule": "*-dangle", "severity": "off", "fixable": true },
        { "rule": "*-newline", "severity": "off", "fixable": true },
        { "rule": "*quotes", "severity": "off", "fixable": true },
        { "rule": "*semi", "severity": "off", "fixable": true }
    ],

    // Enable eslint for all supported languages
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact",
        "vue",
        "html",
        "markdown",
        "json",
        "jsonc",
        "yaml",
        "toml",
        "xml",
        "gql",
        "graphql",
        "astro",
        "svelte",
        "css",
        "less",
        "scss",
        "pcss",
        "postcss"
    ]
}

License

MIT License © 2023-PRESENT wangyjhh