antfu / eslint-config

Anthony's ESLint config preset
https://eslint-config.antfu.me/
MIT License
4.07k stars 450 forks source link

Invalid in nested scenarios #524

Closed zzfn closed 2 months ago

zzfn commented 4 months ago

Describe the bug

const eslint = require('@antfu/eslint-config').default
// 0 = off, 1 = warn, 2 = error
module.exports = eslint({
  javascript: {
    overrides: {
      'prefer-promise-reject-errors': 0,
      'prefer-template': 0,
      'object-shorthand': 0,
      'sort-imports': 0,
      'import/order': 0,
    },
  },
}, eslint(
  {
    formatters: {
      css: true,
      html: true,
      markdown: 'prettier',
    },
    lessOpinionated: true,
    typescript: {
      overrides: {
        'ts/consistent-type-imports': 0,
        'ts/consistent-type-definitions': 0,
      },
    },
    vue: {
      overrides: {
        'vue/block-order': 0,
        'vue/attributes-order': 0,
        'vue/padding-line-between-blocks': 0,
        'vue/v-on-event-hyphenation': 0,
      },
    },
    stylistic: {
      overrides: {
        'style/block-spacing': 0,
        'style/semi': 0,
        'style/comma-dangle': 0,
      },
    },
    imports: {
      overrides: {
        'import/order': 0,
      },
    },
    ignores: ['**/*.spec.ts', 'public/**'],
  },
  {
    files: ['**/*.json'],
    rules: {
      'jsonc/sort-keys': 0,
    },
  },
  {
    files: ['**/*.vue'],
    rules: {
      'antfu/top-level-function': 0,
    },
  },
  {
    files: ['**/*.tsx'],
    rules: {
      'antfu/top-level-function': 0,
    },
  },
  {
    files: ['**/*.ts'],
    rules: {
      'style/semi': 0,
      'style/member-delimiter-style': 0,
      'sort-imports': 0,
      'import/order': 0,
    },
  },
  {
    rules: {
      'no-console': 0,
    },
  },
))

Reproduction

when use this config,i can not lint the javascript rules

System Info

npx envinfo --system --binaries --browsers

  System:
    OS: macOS 13.4.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 124.55 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.2 - /opt/homebrew/opt/node@16/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.4 - /opt/homebrew/opt/node@16/bin/npm
    pnpm: 8.15.4 - /opt/homebrew/bin/pnpm
    bun: 1.1.5 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.127
    Chrome Canary: 128.0.6576.0
    Edge: 126.0.2592.87
    Safari: 16.5.1

Used Package Manager

npm

Validations

Contributions

pauliesnug commented 4 months ago

why would you want to do this? just move the javascript expression into the other eslint block

antfu commented 2 months ago

This config is not designed to be used multiple times. You might need to figure it out yourself.