sxzz/eslint-config

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

Closed this issue · 8 comments

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.
sxzz commented

Run ESLint via CLI,

pnpm eslint .

And show the output.

CleanShot 2023-12-04 at 19 01 39@2x

I mean eslint extension does not catch up and show a warning like this
CleanShot 2023-12-04 at 19 03 57@2x

but 'no-console': 'error'

CleanShot 2023-12-04 at 19 05 14@2x
sxzz commented

It looks like it works well with ESLint, and could be caused by your IDE settings. Maybe you can provide a reproduction repo and I'll check it in my machine.

repo: https://github.com/hungify/nuxt-utils-auto-import-issue
sandbox: https://stackblitz.com/github/hungify/nuxt-utils-auto-import-issue?file=README.md

Also, I updated .vscode/settings.json for support ESlint flat config

{
  "editor.formatOnSave": true,
  "eslint.experimental.useFlatConfig": true
}
sxzz commented

The warning is displayed on my machine without any changes to your repo.
image

Maybe you can reset your environment (check global your VSCode settings, re-clone your repo & node_modules).

My bad !
It is caused by "eslint.quiet": true config
Thank you very much for helping me to find the stuck.

Sorry but my overriding your rules like this caused an error.

import { sxzz } from '@sxzz/eslint-config'

export default sxzz(
  {
    rules: {
      '@typescript-eslint/no-unused-vars': 'error',
    },
  },
  {
    vue: true,
    prettier: true,
    markdown: true,
    unocss: true,
    sortKeys: true,
  },
)
CleanShot 2023-12-08 at 23 15 47@2x

I'm new to this approach.
Normally I need to install @typescript-eslint and put my rules to eslint.config.js but this way just import and use.

sxzz commented
import { sxzz, GLOB_TS, GLOB_TSX } from '@sxzz/eslint-config'
// ...
{
  files: [GLOB_TS, GLOB_TSX],
  rules: {
    '@typescript-eslint/no-unused-vars': 'error',
  },
},

typescript-eslint plugin is only applied for .ts and .tsx files.