我有這個帶有多行參數和單體返回的函數(因為它們很長)。這是一個普通的 JS 文件:const myFunction = ( looooooooongParam1, looooooooongParam2, looooooooongParam3, looooooooongParam4,) => ( looooooooongParam1 + looooooooongParam2 + looooooooongParam3 + looooooooongParam4 + looooooooongParam4);ESLint 格式化錯誤地將返回的行向右移動。然后它抱怨縮進是錯誤的(當然是?。何业?ESLint 規則是:module.exports = { env: { browser: true, es2020: true, }, extends: [ 'plugin:react/recommended', 'airbnb', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', ], parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 11, sourceType: 'module', }, plugins: [ 'react', '@typescript-eslint', ], rules: { 'react/jsx-filename-extension': [2, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }], 'react/jsx-indent': ['error', 4], indent: ['error', 4], 'import/extensions': [ 'error', 'ignorePackages', { js: 'never', jsx: 'never', ts: 'never', tsx: 'never', mjs: 'never', }, ], 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'error', }, settings: { 'import/resolver': { node: { extensions: [ '.js', '.jsx', '.ts', '.tsx', ], }, }, },};我在保存時使用 VSCode 并使用 eslint 格式化。VSCode相關設置:有什么想法可以讓 ESLint 將返回行保持在左側嗎?編輯 1:在 VSCode 中保存文件時,我看到代碼正確縮進了 0.2 秒,然后縮進不正確。編輯 2:如果我的參數較少,在一行中,縮進效果很好,所以只有在多行參數時才會發生這種情況;.
ESLint 錯誤地縮進多行參數 JavaScript 函數的單返回語句
慕萊塢森
2022-12-29 10:33:35