Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I allow whitespace in JavaScript files?

I'm trying to overwrite Prettier plugin rules without success. I want to allow whitespace in JavaScript files like this:

import React, { Component }  from 'react';
import { View }              from 'react-native';
import { Provider, connect } from 'react-redux';

The .eslint file I need to work on:

{
  "plugins": ["prettier"],
  "rules": {
    "prettier/prettier": [
      "error",
      {
        "singleQuote": true,
        "trailingComma": "all",
        "bracketSpacing": true,
        "tabWidth": 2,
        "printWidth": 130
      }
    ]
  },
  "env": {
    "browser": true,
    "es6": true
  },
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "extends": ["prettier"]
}

I already tried eslint key spacing rules but the lint is coming from prettier plugin. I don't find the rule for whitespace characters in the Prettier documentation.

like image 547
Nicolas De Tiesenhausen Avatar asked Mar 15 '26 18:03

Nicolas De Tiesenhausen


1 Answers

You won't find the whitespace rules in their documentation as there is no option to disable them. I checked on their forums as well. What you can do is to ignore .eslint files for prettier and prettier wont format these extension files.

As a temporary solution just add **/*.eslint to your .prettierignore file.

like image 78
Willy wonka Avatar answered Mar 17 '26 07:03

Willy wonka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!