microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.73k stars 333 forks source link

About eslint config,When user setting and workspace setting are conflict,how to override user settings config #1901

Open OnlyFlyer opened 1 month ago

OnlyFlyer commented 1 month ago

In my window,vscode has two setting,user and workspace,default is user setting。

{
// user setting.json
// other config
  "editor.mouseWheelZoom": true,
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "security.workspace.trust.untrustedFiles": "open",
  "editor.fontSize": 26,
  "workbench.iconTheme": "vscode-icons",
  "workbench.colorTheme": "One Dark Pro",
  "eslint.validate": ["javascript", "javascriptreact", "vue", "typescript"],
  "eslint.nodePath": "C:\\Users\\flyer\\AppData\\Roaming\\nvm\\v20.13.1\\node_modules\\@workplace\\cli\\node_modules",
  "eslint.options": {
    "configFile": "C:\\Users\\flyer\\AppData\\Roaming\\nvm\\v20.13.1\\node_modules\\@workplace\\cli\\node_modules\\@workplace\\eslint-config-wpconfig\\wp.js"
  },
}

// wp.js
module.exports = {
    extends: [
        'plugin:vue/recommended',
        'plugin:@typescript-eslint/eslint-recommended',
        'plugin:@typescript-eslint/recommended',
    ].filter(item => {
        return item;
    }),
    parser: 'vue-eslint-parser',
    plugins: ['mocha', '@workplace/xui', '@typescript-eslint'],
    parserOptions: {
        // https://github.com/mysticatea/vue-eslint-parser#-options
        parser: '@typescript-eslint/parser',
        tsconfigRootDir: tsConfigPath,
        project: isTsProject ? [tsConfigPath] : undefined,
        createDefaultProgram: isTsProject,
        extraFileExtensions: ['.vue'],
        ecmaVersion: 2018,
        sourceType: 'module',
        ecmaFeatures: {
            jsx: true
        }
    },
    globals: {
        uni: true,
        Jalor: true,
        Ext: true,
        ha: true
    },
    env: {
        mocha: true,
        jasmine: true,
        jest: true,
        node: true,
        phantomjs: true
    },
    rules: {
        // ... other rules
        'no-unused-vars': 'off',
        '@typescript-eslint/no-unused-vars': ['error', { args: 'after-used', argsIgnorePattern: '^_$', varsIgnorePattern: '^_' }],
        'vue/no-unused-vars': 'error',
    },
    overrides: [
        {
            // enable the rule specifically for TypeScript files
            files: ['*.ts', '*.tsx'],
            rules: {
                '@typescript-eslint/explicit-function-return-type': ['warn'],
                'no-undef': 'error'
            }
        }
    ]
};

// my project eslint config
const { defineConfig } = require('eslint-define-config');

module.exports = defineConfig({
  root: true,
  globals: {
  },
  rules: {
     'no-unused-vars': 'off'
     'no-extra-boolean-cast': 'off'
     '@typescript-eslint/no-unused-vars': 'off',
  },
  overrides: [
    {
      // enable the rule specifically for .vue files
      files: ['*.vue'],
      rules: {
        'no-unused-vars': 'off',
        '@typescript-eslint/no-unused-vars': ['off'],
        'vue/no-unused-vars': 'off',
      }
    }
  ]
});

i want to make rules no-unused-vars off,but it's not working,how to do?Hope to reply as soon as possible

dbaeumer commented 1 month ago

@OnlyFlyer does the validation happen correctly (no-unused-vars off) when you use eslint in the terminal. If this is the case can you please provide me with a GitHub repository with a minimal setup I can clone that demos what you are experiencing.