Git Product home page Git Product logo

eslint-config's Introduction

@sxzz/eslint-config npm

Flat ESLint config for JavaScript, TypeScript, Vue 2, Vue 3, Prettier.

Legacy Version

Features

  • Format with Prettier.
  • Designed to work with TypeScript, Vue 2 and 3 out-of-box.
  • Support JSON(5), YAML, Markdown...
  • Sort imports, package.json, tsconfig.json...
  • ESLint Flat config, compose easily!
  • Reasonable defaults, best practices, only one-line of config
  • Reasonable strict, but with better code quality.

Install

npm i -D @sxzz/eslint-config

Require Node.js >= 18.18, and ESLint >= 8.56.0.

Usage

import { sxzz } from '@sxzz/eslint-config'
export default sxzz(
  [
    /* your custom config */
  ],
  // Features: it'll detect installed dependency and enable necessary features automatically
  {
    prettier: true,
    markdown: true,
    vue: true, // auto detection
    unocss: false, // auto detection
  },
)

Presets

// eslint.config.js
import {
  presetJavaScript, // Ignore common files and include javascript support
  presetJsonc, // Includes basic json(c) file support and sorting json keys
  presetLangsExtensions, // Includes markdown, yaml + `presetJsonc` support
  presetBasic, // Includes `presetJavaScript` and typescript support

  // Includes
  // - `presetBasic` (JS+TS) support
  // - `presetLangsExtensions` (markdown, yaml, jsonc) support
  // - Vue support
  // - UnoCSS support (`uno.config.ts` is required)
  // - Prettier support
  presetAll,
} from '@sxzz/eslint-config'

export default presetAll

See preset.ts for more details.

VSCode

{
  "eslint.experimental.useFlatConfig": true,
}

Most of the rules are the same, but there are some differences:

  • Use Prettier instead of ESLint Stylistic.
  • Support both Vue 2 and Vue 3.
  • Support Vue Reactivity Transform.
  • More stricter rules.

Sponsors

License

MIT License © 2021-PRESENT 三咲智子

eslint-config's People

Contributors

innei avatar lotwt avatar ocavue avatar oumarbarry avatar renovate[bot] avatar sxzz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

eslint-config's Issues

Optional markdown config

Hi!

Thanks a lot for the hardworking. I'm currently in the process of refactoring our company's shareable config to the new flat implementation and your repository has been really helpful.

While reading the code I noticed that in the src/presets.ts file, the markdown is imported and then spread inside the presetLangsExtensions array.

This array is itself spread into the basic array, but then you pass a param to your config as such markdown: enableMarkdown = true.

To my current understanding and knowledge, I believe this is currently having no impact since you're either using basic with the markdown or using basic with the markdown twice.

Enable usage with `@nuxt/eslint`

Clear and concise description of the problem

With the latest version of @nuxt/eslint, it would be great if we could also use this config inside the new withNuxt in eslint.config.mjs.

Basically, the idea would be to enable replacing antfu() with sxzz() in this example. When I do this now, it throws the following tsc error:

Argument of type 'FlatESLintConfigItem[]' is not assignable to parameter of type 'ResolvableFlatConfig'.
  Type 'FlatESLintConfigItem[]' is not assignable to type 'FlatConfig<RulesRecord>[]'.
    Type 'FlatESLintConfigItem' is not assignable to type 'FlatConfig<RulesRecord>'.
      Types of property 'languageOptions' are incompatible.

Suggested solution

Make sure languageOptions types are compatible between the two packages. This might just involve updating eslint-define-config (#49) since it is there that the Globals type mismatches.

Alternative

No response

Additional context

No response

Validations

[BUG] vue/html-self-closing eslint rule fix error

Describe the bug

eslint config as below:

// eslint.config.js
import { sxzz } from "@sxzz/eslint-config";
export default sxzz(
  [
    /* your custom config */
  ],
  { vue: true, prettier: true },
);

App.vue file:

<script setup lang="ts"></script>

<template>
  <div>
    <!-- OK -->
    <img />
    <!-- fix on save -->
    <img>
    <!-- it will become <img //> -->
  </div>
</template>

<style scoped></style>

Reproduction

https://github.com/Alkaidcc/eslint-config-repro

System Info

System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M2
    Memory: 2.14 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/Library/Caches/fnm_multishells/73841_1703430144978/bin/node
    Yarn: 1.22.19 - ~/Library/pnpm/yarn
    npm: 10.2.3 - ~/Library/Caches/fnm_multishells/73841_1703430144978/bin/npm
    pnpm: 8.12.0 - ~/Library/pnpm/pnpm
    bun: 1.0.0 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 120.0.6099.129
    Safari: 17.2.1

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

规则未生效

Describe the bug

请问 'unused-imports/no-unused-imports': isInEditor ? 'off' : 'error',这一条规则中,isInEditor 在什么情况下为 false ?在 import 了一个函数以后,并未使用它,鼠标焦点移入应用,vscode 失焦,规则并未生效,没有看到报错。

Reproduction

System Info

Windows11

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

和simple-git-hooks或者husky配合使用时,直接报错,导致代码无法提交。但是在编辑使用时没有问题

Describe the bug

lint-staged

[STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 10 files
[STARTED] .{js,jsx,ts,tsx} — 4 files
[STARTED] {!(package)
.json,*.code-snippets,.!(browserslist)*rc} — 0 files
[STARTED] package.json — 0 files
[STARTED] *.vue — 6 files
[STARTED] .{scss,less,html} — 0 files
[STARTED] .md — 0 files
[SKIPPED] {!(package)
.json,
.code-snippets,.!(browserslist)*rc} — no files
[SKIPPED] package.json — no files
[SKIPPED] *.{scss,less,html} — no files
[SKIPPED] *.md — no files
[STARTED] eslint
[STARTED] eslint
[FAILED] eslint [FAILED]
[FAILED] eslint [FAILED]
[FAILED] eslint [FAILED]
[STARTED] Applying modifications from tasks...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[FAILED] eslint [FAILED]
[FAILED] eslint [FAILED]
[SUCCESS] Reverting to original state because of errors...
[STARTED] Cleaning up temporary files...
[SUCCESS] Cleaning up temporary files...

✖ eslint:

Oops! Something went wrong! :(

ESLint: 8.48.0

D:\Code\an\portal\node_modules.pnpm\[email protected][email protected]\node_modules\eslint-plugin-unicorn\rules\utils\rule.js:77
listeners[selector] ??= [];
^^^

SyntaxError: Unexpected token '??='
at wrapSafe (internal/modules/cjs/loader.js:1029:16)
at Module._compile (internal/modules/cjs/loader.js:1078:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
at Module.require (internal/modules/cjs/loader.js:1003:19)
at require (internal/modules/cjs/helpers.js:107:18)
at Object. (D:\Code\an\portal\node_modules.pnpm\[email protected][email protected]\node_modules\eslint-plugin-unicorn\index.js:3:21)
at Module._compile (internal/modules/cjs/loader.js:1114:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)

Oops! Something went wrong! :(

ESLint: 8.48.0

Reproduction

System Info

Windows

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • fix(deps): update all non-major dependencies (eslint-plugin-command, eslint-plugin-n, tsx)

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • @unocss/eslint-plugin ^0.60.2
  • eslint-config-prettier ^9.1.0
  • eslint-define-config ^2.1.0
  • eslint-plugin-antfu ^2.2.0
  • eslint-plugin-command ^0.2.0
  • eslint-plugin-eslint-comments ^3.2.0
  • eslint-plugin-import-x ^0.5.0
  • eslint-plugin-jsonc ^2.15.1
  • eslint-plugin-markdown ^5.0.0
  • eslint-plugin-n ^17.6.0
  • eslint-plugin-perfectionist ^2.10.0
  • eslint-plugin-prettier ^5.1.3
  • eslint-plugin-unicorn ^53.0.0
  • eslint-plugin-unused-imports ^3.2.0
  • eslint-plugin-vue ^9.26.0
  • eslint-plugin-yml ^1.14.0
  • globals ^15.2.0
  • jsonc-eslint-parser ^2.4.0
  • local-pkg ^0.5.0
  • prettier ^3.2.5
  • typescript-eslint ^7.9.0
  • vue-eslint-parser ^9.4.2
  • yaml-eslint-parser ^1.2.2
  • @sxzz/prettier-config ^2.0.2
  • @types/node ^20.12.12
  • bumpp ^9.4.1
  • eslint ^9.2.0
  • tsup ^8.0.2
  • tsx ^4.10.2
  • typescript ^5.4.5
  • pnpm 9.1.1

  • Check this box to trigger a request for Renovate to run again on this repository

Unknown options: reportUnusedDisableDirectives

Describe the bug

Error: Invalid Options:

  • Unknown options: reportUnusedDisableDirectives
  • 'reportUnusedDisableDirectives' has been removed. Please use the 'overrideConfig.linterOptions.reportUnusedDisableDirectives' option instead.

Reproduction

Nothing

System Info

System:
    OS: macOS 14.3
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 2.67 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.17.1/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v18.17.1/bin/npm
    pnpm: 8.10.5 - ~/.nvm/versions/node/v18.17.1/bin/pnpm
    bun: 1.0.4 - ~/.bun/bin/bun
  Browsers:
    Safari: 17.3

Used Package Manager

yarn

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Prettier ignores html-element-content-newline

There's a rule that can be activated for VUE for singleline-html-element-content-newline. I love the rule, works great with the config, but I could not make it work at all with prettier

phpstorm64_22xOpzHzlk

While this is not a bug report per se, I was just wondering if you have any suggestions on how to solve this. It also adds a space before and after the content, but I guess this is less relevant right now.

Config example:

// eslint.config.js

import {sxzz} from "@sxzz/eslint-config";

export default sxzz(
    [
        {
            rules: {
                "vue/singleline-html-element-content-newline": [
                    "error",
                    {
                        ignoreWhenNoAttributes: true,
                        ignoreWhenEmpty: true,
                        ignores: ["pre", "textarea"]
                    }
                ]
            }
        }
    ],
    {vue: true, prettier: true, markdown: true, unocss: false}
);

How to override rules and config rule severity(warn) not working

Describe the bug

Hi author!

Here is my config for overriding your rules

export default sxzz(
  {
    rules: {
      'no-console': 'warn',
    },
  },
  {
    vue: true,
    prettier: true,
    markdown: true,
    unocss: true,
    sortKeys: true,
  },
)

I don't see any warning when I use, but rule severity(error) is fine

const a: any = 1
console.log(a)
CleanShot 2023-12-04 at 11 16 08@2x

Reproduction

Nothing

System Info

System:
    OS: macOS 13.6.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 151.86 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/Library/Caches/fnm_multishells/76365_1701660609649/bin/node
    npm: 10.1.0 - ~/Library/Caches/fnm_multishells/76365_1701660609649/bin/npm
    pnpm: 8.11.0 - ~/Library/pnpm/pnpm
    bun: 1.0.12 - ~/.bun/bin/bun
  Browsers:
    Safari: 16.6

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

安装后以后,一直报错,无法使用。

Describe the bug

image image image

package.json type设置为“module”也没用。

Reproduction

暂无

System Info

pnpm chrome vscode eslint

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

[BUG] Could not fix trailing comma in jsconfig.json file

Describe the bug

How to reproduce the bug:

  1. use pnpm create vite to create a vue+javascript project
  2. pnpm add -D @sxzz/eslint-config eslint
  3. add
{
  "eslint.experimental.useFlatConfig": true
}

to .vscode/settings.json file
4. when I press cmd + s to save and fix my code, eslint can't fix trailing comma in jsconfig.json file, besides, I found out that eslint cant't fix App.vue as well. However it's working for HelloWorld.vue. It's so weird!

I can't find out the reason 😢 If you need more help information, I'm glad to help debug.

Reproduction

https://github.com/Alkaidcc/js-repro

System Info

System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M2
    Memory: 58.58 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/Library/Caches/fnm_multishells/9789_1706523927230/bin/node
    Yarn: 1.22.19 - ~/Library/pnpm/yarn
    npm: 10.2.4 - ~/Library/Caches/fnm_multishells/9789_1706523927230/bin/npm
    pnpm: 8.14.0 - ~/Library/pnpm/pnpm
    bun: 1.0.25 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 121.0.6167.85
    Safari: 17.2.1

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.