Aidenhsy
Aidenhsy

Reputation: 1601

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. But when I save my files, the prettier extension adds spacing in the object curly braces like this:

export { basicHTTP } from './http';

which eslint gives me an error: eslint error is there anyway to disable this?

This is my .eslintrc.js file that comes with firebase init:

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'],
  },
};

Upvotes: 12

Views: 16141

Answers (2)

Abraham
Abraham

Reputation: 15810

You can disable adding space in vscode when formatting code.

Open settings.json and add the following line

"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,

This will fix it on both javascript and typescript

Upvotes: 2

iqqmuT
iqqmuT

Reputation: 843

Modify your rules to look like this:

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.

See: https://eslint.org/docs/rules/quotes

Upvotes: 16

Related Questions