I have an Expo React Native app that has a ton of unused imports in components. I have Prettier setup for code formatting, is it possible to configure Prettier to also remove any unused imports across the project? I can’t see anything in the docs and I don’t know if there is a way to add extra eslint plugins to
Tag: prettier
Prettier adding semicolon when semi: false
I have a react component with this jsx When I save the file prettier automatically adds a semicolon infront of <Post … />. This is causing the component to fail to render. I have the semi option set to false. Answer This is happening because currently your map function is not returning anything <Post key={post.id} post={post} /> needs to be
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. I know that eslint is a dependency of react-scripts and linting is done using ‘eslint-webpack-plugin'(default enabled) inside the webpack configuration. Snippet from CRA github | React Scripts
How i can fix js import auto-hide problem in vs code
Firstly, I imported something from another module in js: But when I am not using this cloneDeep in my code and save my script file, then VS Code automatically hides that line. Before Save After Save Answer vcode settings.json
Prevent Prettier formating arrow functions to multiple lines
When I write arrow functions in Vue.js using vscode i get an unexpected formating. I wish to change the settings for Prettier when auto formating arrow functions in vscode. Expected: Acceptable: Actual: Answer I did some research and found this feature has already been requested: https://github.com/prettier/prettier/issues/4125 Changes to prettier were made (https://github.com/prettier/prettier/pull/6685) and released in prettier 2.0 back in 2020.
React functional component props sort alphabetically. (At the definition side)
I know an eslint rule, to sort the component props at the usage side. Like <Cmp alpha={true} beta={true} /> (rule) But is there a rule, what sorts the props from the definition side? Like: const Cmp = ({ beta, alpha = false }) => null; should be const Cmp = ({ alpha = false, beta }) => null; Answer No
How to disable eslint(prettier/prettier) single quotes error
I have react-native code. I install ESLint. I use it but its show error. While I use single quotes it show me error Replace ‘react-native’ with “react-native” eslint(prettier/prettier) And when I use double qoutes it show me another error String must use singlequote. eslint(quotes) here is the screenshot: What i want is, how to remove error messages about using single
why vscode is not recognizing react code as react javascript instead it format it as vanilla javascript
I am using Prettier with format on save enabled but when I make any change in App.js and save it Prettier do destroy my code because it deals with it as plain javascript Answer I am using create-react-app so it produce the main component App.js I am using .JSX in the other components but the problem is when I make
How to add multiple lines between code blocks with Prettier?
I started using Prettier, but discovered that it doesn’t have an option to control the number of blank lines between code blocks, and defaults to one. I want 2 blank lines: But it defaults to 1 blank line: How can I achieve this with Prettier? (Or perhaps there is another way to do this. I was surprised how few configurable