[英]How do I disable There should be no space after '{'.eslintobject-curly-spacing in .eslintrc.js
I am using prettier and I initialized my project with firebase init with the eslint option.我正在使用 prettier,并使用带有 eslint 选项的 firebase init 初始化了我的项目。 But when I save my files, the prettier extension adds spacing in the object curly braces like this:
但是当我保存文件时,更漂亮的扩展在 object 花括号中添加间距,如下所示:
export { basicHTTP } from './http';
which eslint gives me an error:哪个 eslint 给了我一个错误:
is there anyway to disable this?
反正有没有禁用这个?
This is my.eslintrc.js file that comes with firebase init:这是 firebase init 附带的 my.eslintrc.js 文件:
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'google',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.dev.json'],
tsconfigRootDir: __dirname,
sourceType: 'module',
},
ignorePatterns: [
'/lib/**/*', // Ignore built files.
],
plugins: ['@typescript-eslint', 'import'],
rules: {
quotes: ['error'],
},
};
Modify your rules
to look like this:将您的
rules
修改为如下所示:
rules: {
'object-curly-spacing': ['error', 'always'],
'quotes': ['error'],
},
After this change you probably have to fix all js files to use same syntax, but that's just a good practice.在此更改之后,您可能必须修复所有 js 文件以使用相同的语法,但这只是一个好习惯。
See: https://eslint.org/docs/rules/quotes请参阅: https://eslint.org/docs/rules/quotes
You can disable adding space in vscode
when formatting code.您可以在格式化代码时禁用在
vscode
中添加空格。
Open settings.json
and add the following line打开
settings.json
并添加以下行
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
This will fix it on both javascript and typescript这将在 javascript 和 typescript 上修复它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.