简体   繁体   English

如何禁用 '{'.eslintobject-curly-spacing in.eslintrc.js 之后应该没有空格

[英]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 给了我一个错误: 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.

相关问题 '{' 后不应有空格(babel/object-curly-spacing) - There should be no space after '{' (babel/object-curly-spacing) 如何在花括号前后添加空格? - How to add space after and before curly braces? VS Code 在符号后添加空格 = + 如何去掉空格 - VS Code add spacing after signs = + how to remove the space 当我按 Enter 键时,如何格式化 Visual Studio 代码以在 CSS 中的大括号之间添加缩进空格? - How can i format visual studio code to add an indented space between curly brackets in CSS when i hit enter? 如何在 vscode 中禁用自动删除行空间? - How can I disable auto-remove line space in vscode? 如何更改Visual Studio代码自动更正花括号的方式? - How do i change the way visual studio code auto corrects curly braces? 如何设置VSCode不将花括号放在新行上? - How do I set up VSCode to NOT put curly braces on a new line? 如何禁用:[js] 文件是 CommonJS 模块; 它可以转换为 ES6 模块 - How do I disable: [js] File is a CommonJS module; it may be converted to an ES6 module 我的 VScode 不允许我留下空格或线条。 我该如何解决? - My VScode doesnt allow me to leave a spacing or a line. How do i fix this? 如何设置 VSCode 以将大括号放在新行上? - How do I set up VSCode to put curly braces on a new line?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM