Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
OnlyFlyer opened this issue Jul 12, 2024 · 1 comment
Labels
info-needed Issue requires more information from poster

Comments

@OnlyFlyer
Copy link

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
Copy link
Member

@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.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants