Questions tagged [prettier]
Prettier is an opinionated code formatter for JavaScript, CSS, HTML, Markdown, and other languages. If possible, please use Prettier's Playground to illustrate your question (use the "Copy link" and "Copy markdown" buttons at the bottom right corner of the Playground).
1,241
questions
0
votes
0
answers
8
views
Nuxt JS .vue pre-commit checks failed with prettier and vue/html-indent file errors
I am working on a project and with Nuxt JS and the .vue js have a pre-commit error.
I am on visual studio code and a mac machine.
The error is from prettier and vue/html-indent.
I receive this error ...
0
votes
1
answer
20
views
Prettier adding semicolon when semi: false
I have a react component with this jsx
{posts?.map((post) => {
<Post key={post.id} post={post} />
})}
When I save the file prettier automatically adds a semicolon infront of <Post ...
0
votes
1
answer
23
views
VS Code - Prettier is formatting differently for me than others
Prettier is behaving differently for me compared to my team mates.
We all have same version 9.5.0 of prettier installed on our VS Code.
We all have same configuration of prettier.
Still it is ...
-1
votes
1
answer
21
views
VSCode single or double quote to backticks automatice replace
I want to use only backticks.
I want that every time I click save, the formatter will change all my quotes type to backticks. I tried the built-in VSCode formatter for JS and prettier, and I didn't ...
-1
votes
0
answers
36
views
I constantly see this error in react with eslint and prettier
Cannot read config file: D:\WebCoder\React\myapp\node_modules\eslint-config-prettier\react.js
Error: "prettier/react" has been merged into "prettier" in eslint-config-prettier 8.0....
0
votes
0
answers
5
views
How to preserve new lines in html tags with VSC Prettier?
I want to preserve new-lines in something like:
<py-env>
- numpy
- matplotlib
</py-env>
but on save, prettier output comes like:
<py-env>- numpy - matplotlib</py-env>
I ...
-1
votes
0
answers
6
views
Prettier `printWidth:100` , how many strings are equivalent?
Visual Studio Code Extion Prettier
enter image description here
2
votes
1
answer
25
views
Prettier breaking functions in Vue script tag
I would like to keep a if function in one line without using ternary if but prettier format breaks it, I didn't find a option for that in prettier documentation
tag script inside .vue file
WANTED ...
0
votes
1
answer
8
views
Prettier adds multiple empty lines after JavaScript blocks wrongely
My prettier is adding extra empty lines after blocks in JavaScript. It is OK after first save and empty line is just one, but after second save it add another line, and after third save it add one ...
0
votes
1
answer
28
views
Can Prettier rules be applied using IntelliJ IDEA code style rules instead of the Prettier plugin?
I have a project that contains some TypeScript files which I would like to format using the Prettier format while editing in IntelliJ IDEA, so that my resulting code matches that of my colleagues. ...
0
votes
1
answer
37
views
Is eslint pre-commit hook in CRA bootstrapped application required?
My react application is bootstrapped using CRA(react-scripts v4.0.0) and I want to add a code formatter (prettier to be specific) that must format the code before committing the changes to my git repo....
3
votes
1
answer
614
views
aws cdk 2.0 init app fails to build with prettier issues, which is from jest-snapshot
node: v16.7.0
cdk: 2.0.0 (build 4b6ce31)
package.json:
"devDependencies": {
"@types/jest": "^26.0.10",
"@types/node": "10.17.27",
"...
-1
votes
1
answer
29
views
`npx mrm@2 lint-staged` throw err that `.git` can't be found husky custom directrory
xxx-MacBook-Pro:client xxx$ npx mrm@2 lint-staged
npx: installed 239 in 8.29s
Running lint-staged...
/Users/xxx/.npm/_npx/34378/lib/node_modules/mrm/bin/mrm.js:56
throw err;
^
Error: ...
0
votes
1
answer
37
views
prettier printWidth setting is not formatting correctly on save
This workspace has two linting plugins(eslint and prettier):
My lint settings:
I can indeed see the default format document is set to prettier:
(The Problem) The format on save is still the ...
0
votes
1
answer
11
views
Ability to tell autoformatter to respect how I multipline split html attributes in VS Code
I have a problem in VS Code using Prettier for autoformatting JS and Vue code.
For example, how to set it to save this:
<Todo
v-for="todo in todos"
:key="todo.id"
/>
...
0
votes
0
answers
35
views
React: Eslint fix remove prop name={name} from jsx
There's eslint errors when the linter auto fix errors it removes the {name} from name={name}
eslint error that trying to fix : Function component is not a function expressioneslintreact/function-...
0
votes
0
answers
27
views
options.editorconfig from prettier-cli
Is there a way to pass that options.editorconfig true flag using the cli without a configuration file. I can't get prettier to respect the .editorconfig file.
I don't way this isn't the default. An ....
0
votes
0
answers
8
views
Can Prettier handle negative file matches in the CLI?
I understand that Prettier uses https://github.com/mrmlnc/fast-glob#pattern-syntax for the file/dir/glob element of its CLI.
For my package.json I need a prettier 'one-liner' to examine files which ...
0
votes
0
answers
21
views
How to have Prettier format two JSX and JS separately within the same file in React
Is there any way to have Prettier format JavaScript differently than the JSX in React in the same file, mainly just making the tabWidth for JS 4 and for JSX 2?
Should I be changing the file extension ...
0
votes
0
answers
14
views
Prettier is not formatting files even though logs suggest otherwise
I'm on Windows mounting my working directory from a Mac using NFS. This works surprisingly fine with Visual Studio Code. However, prettier doesn't seem to be working with it.
The log reads as follows
...
0
votes
1
answer
15
views
is there a code formatting tool or keyboard short cut to automatically remove the trailing spaces within a quote especially in CSS styling?
I want to be able to automatically remove the space after and before the quotes in the inline styling. Especially for large codebase. is there a tool like Prettier or ESLint or VScode extension that ...
0
votes
0
answers
17
views
prettier formatting inside styled-component
In our code base we use styled-components, with a theme. To use the theme one must do something like this
const StyledComp = styled.div`
margin: ${theme.spacing.sm};
`
However, because our ...
-1
votes
1
answer
132
views
I need remove the semicolon error ESLint + Prettier
How can I remove the semicolon rule?
I've tried to remove the semi rules, but I'm not succeeding. When I save the file once it removes the semicolons and lint complains that it's missing, and when I ...
0
votes
1
answer
27
views
Conflict when i save my file(EsLint + Prittier formater)
I have that arrow function
I have this error in my file. To fix this error, I can return it like this => {return ...}, or just put parentheses around what is inside the arrow function
When I do ...
1
vote
1
answer
48
views
eslint: Unable to resolve path to module 'src/interfaces'
I'm having a very similar problem here and have tried every answer with no luck: Using eslint with typescript - Unable to resolve path to module
Here is a screenshot of the linting error:
tsconfig....
0
votes
1
answer
58
views
Eslint prettier error on new line incomprehensible
I have and error of eslint in my code that I cannot understand how turn off, these are some examples:
As you can see there is a eslint(prettier/prettier) rule that is incomprehensible and I can't ...
0
votes
0
answers
12
views
Incorrect prettier file pattern
I'm using prettier to format an angular project but I'm having a little trouble figuring out the correct file pattern.
Using prettier --check src/**/* includes *.pdf files which causes errors.
Using ...
1
vote
0
answers
56
views
Microservices monorepo w/ Prettier & linting
I have a project with 4 microservices in total, 3 in PHP and 1 in JS, in 1 monorepo. I love to use Prettier for both languages and I want to use ESLint for JS and CS Fixer for PHP to assure code ...
0
votes
1
answer
34
views
How do i configure eslint or prettier to ignore inline comment?
How can I get prettier or eslint to leave comments on same line with code. This is what I have:
/'use strict'; // code assumes ECMAScript 6
When I run prettier and eslint, I get this:
'use strict';
// ...
0
votes
1
answer
58
views
How to create the custom exception/rule in eslint and prettier for ignore 'of =>' and 'returns =>' in decorators of resolver?
Introduction
I using NestJS and @nestjs/graphql with default eslint and prettier settings.
When I create graphql resolver, I have some problem with eslint and prettier.
Problem
Prettier notify the ...
0
votes
0
answers
30
views
Why has my Prettier extension stopped working? [duplicate]
My Prettier extension has stopped working all of a sudden. I have always had it set to format on save, however, I now get the below error message:
"extension 'prettier - code formatter' is ...
0
votes
1
answer
39
views
Why is Prettier being inconsistent with JSX?
Pettier is formatting my code three different ways (React Native JSX).
I'm using the tailwind-rn package to use Tailwind in React Native. Prettier has formatted styling code three different ways:
1.
&...
0
votes
0
answers
36
views
How do I override a prettierrc.json file?
How do I override a .prettierrc.json file in my Prettier settings.json?
There are configs in that .prettierrc.json that I do not want locally and I am not bound by any authority to use them, more of a ...
0
votes
1
answer
73
views
How to correctly use Eslint rule newline-per-chained-call with Prettier in Angular
I added the rule:
"newline-per-chained-call": [
"error",
{
"ignoreChainWithDepth": 2
}
]
to my .eslintrc.json file.
I Also extended "plugin:...
0
votes
1
answer
44
views
How can i get prettier to format my code?
I'm trying to get prettier to work on vs code and I've tried setting it as default formatter, format on save, disable then enabling. But i opened json and it said i have an error on "C_Cpp....
0
votes
1
answer
60
views
How to prevent Prettier from removing semicolon and white spaces in { }
I have a javascript project formatted with Prettier and eslint. The issue is that when I save a code like this:
require('dotenv').config({ path: `${ PATH_CFG }/.env` }); process.env.APP_DATABASE = ...
0
votes
0
answers
16
views
How can I configure Prettier to produce same result as a js-beautify config?
How can I configure Prettier to produce this same result?
js-beautify -r -n -u -b collapse,preserve-inline "$@"
This is what I currently have in my .prettierrc
"bracketSpacing":...
0
votes
1
answer
76
views
Can I make Eslint format upon my formatting rules while linting upon extensions?
I want Eslint to format my codes not upon extensions(that I specified in extends property in .eslintrc) but my custom formatting rules, while it still lints and notifies me that there are some ...
1
vote
1
answer
52
views
how to rebase when prettier formatting was applied to whole project
Someone merged in prettier formatting changes across the whole codebase, and I am now trying to rebase against latest master/main/develop branch. How can I rebase most efficiently?
0
votes
0
answers
16
views
Line break is breaking API data set. Can I convert to safe character at once? | VS Code / Javascript
Can line-break break the code? If so, how can I solve it?
I have more than 100 javascript API data sets like the one below.
{
ID: 1,
post_title: "ABC PLACE",
subtitle: "&...
1
vote
2
answers
44
views
How i can fix js import auto-hide problem in vs code
Firstly, I imported something from another module in js:
import cloneDeep from './node_modules/lodash-es/cloneDeep.js'
But when I am not using this cloneDeep in my code and save my script file, then ...
1
vote
1
answer
115
views
Prettier same line bracket for self-closing tags
Is there any way to make prettier put the bracket of a self closing tag on the same line as the last attribute of a JSX element?
Here is what I mean:
I wanted to put it on the same line as the last ...
1
vote
0
answers
115
views
Visual Studio Code Prettier extension intermittently throws an error on formatting
I need to restart Visual Studio Code several times a day because the Prettier formatter extension (esbenp.prettier-vscode) throws errors. It is as if the extension gets confused after numerous ...
0
votes
0
answers
20
views
VS Code's Prettier extension not formatting well
I'm coding in typescript and I'm having a really annoying issue where this line of code:
<ul>
{this.state.tags.map(tag => (<li>{tag}</li>))}
</ul>
...
0
votes
1
answer
36
views
"Document contains trailing content not separated by a ... or --- line" syntax error when running prettier on yaml
I have this code in a YAML file.
# prettier-ignore
{% set data = load_setup_py_data(setup_file='./setup.py', from_recipe_dir=True) %}
package:
name: covalent
version: {{ data.get('version') }}...
0
votes
1
answer
68
views
Prettier warns me about a trailing comma but after I remove it, it adds it back when I save the save
Prettier warns me that I need to remove trailing commas, then after I remove it the error goes away but Prettier adds that commas again by itself immediately I save. Please help, it seems like a ...
0
votes
1
answer
72
views
How to format the code on Git Push and Pull
I am currently working on development projects with different languages (TS, TSX) with different developers.
Moreover we use Prettier/ESLint, but it's a detail.
And some developers are used to develop ...
0
votes
0
answers
22
views
How to describe path to files in package.json script for format it?
In some guide I get next:
"format": "prettier --write 'src/**/*.{ts,tsx,scss,css,json}'",
but when I use it, I get error:
[error] No files matching the pattern were found: "'...
-2
votes
3
answers
43
views
how to make stop some end tag from visual studio code
i want to save just <img scr="" alt="">
but my visual studio code save automatically <img scr="" alt="" />
I have prettier installed
No matter how ...
0
votes
0
answers
30
views
Prettier onSave makes linebreak and then puts everything back inline
I'm facint a prettier issue where when I save the file (angular template) prettier does its job and formats nicely the code but whenever it makes linebreaks it just puts back everything in one single ...