I am using eslint, prettier, vite for a React project.
I have set my VSCode workspace settings for "source.fixAll.eslint"
and "source.organizeImports"
to true
. But it keeps changing to "explicit"
automatically, for example when I open VSCode or when I'm coding.
What might be the cause?
// .vscode/settings.json (workspace settings)
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true, // keeps automatically changing to "explicit"
"source.organizeImports": true // keeps automatically changing to "explicit"
},
"editor.formatOnSave": true,
"editor.wordWrap": "on",
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
// package.json devDependencies
"devDependencies": {
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.6",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.0.2",
"msw": "^1.3.2",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-tsconfig-paths": "^4.2.1"
},
// .eslintrc.cjs
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh", "eslint-plugin-react", "prettier"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react/self-closing-comp": [
"error",
{
component: true,
html: true,
},
],
"prettier/prettier": "error",
"no-console": "error",
},
};
// .prettierrc.json
{
"singleQuote": false,
"quoteProps": "consistent",
"printWidth": 80,
"tabWidth": 2,
"bracketSameLine": true,
"bracketSpacing": true,
"arrowParens": "always",
"trailingComma": "es5",
"semi": true,
"endOfLine": "auto",
"eslintIntegration": false
}
Turns out, VSCode true
is set to "explicit"
since VSCode 1.85.0. It seems boolean values were supported until 1.84.0.
References
https://code.visualstudio.com/updates/v1_85#_code-actions-on-save-and-auto https://code.visualstudio.com/updates/v1_83#_code-actions-on-save-and-auto-save