ESLint complains my code format I don't understand why - react-native

My react native code is like this:
When I save, I always get ESLint complaining :
Is it something about the tab character? Should I do some settings for the Visual Studio Code? I can't figure out how to get rid of this error. Could someone please give a suggestion?
My Visual Studio Code used to be able to auto-format my code when save. Now it completely not working when saving.
==== UPDATE ====
I tried also manually format the code:
But I get the ESLint error:
Is it some settings of tab key should be modified in Visual Studio Code settings?

I believe those characters are newlines. Try this:
remove the extra newline character after your imports
put each JSX tag on its on line. Something like this:
return (
<View>
<Text>Hello</Text>
</View>
);
The documentation explains how to set up eslint to automatically fix problems with your code. In Visual Studio Code, open File > Preferences > Settings and search for "code actions on save". Click Edit in settings.json and enable auto-fixing:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": false
}

Related

Code block structure highlighting extension

Does anyone know an extension for Visual Studio Code that highlight code blocks as in the image ?
It is built-in to vscode. Enable the setting
Editor > Guides: Bracket Pairs

how can i fix the problem with format on save in vs code?

Well "format on save" (in Vs Code) doesn't work, also tried Prettier but it doesn't work for React to.
Someone help!
format on save and Prettier in Vs code dont work!!!
Is the Default Formatter option set to Preitter?
File > Preferences > Settings and then search for the Default Formatter option and select Prettier from the dropdown menu.
If this doesn't work, uninstall and reinstall the Prettier extension.
last, of all is enable format on save enabled?

Formmating ejs in visual studio code

Hi, I need to indent my ejs code in visual studio, but I get this message:
"Sorry, but there is no formatter for 'ejs'-files installed"
I already installed EJS Language Support but it just colored the code, not indent.
Does anyone know how to do this in Visual studio code?
thanks.
Step 1
Click File >> Preferences >> Settings
You will get something like this
Step 2
The Textbox "search settings" type in settings.json
Click Edit in settings.json
add this in the settings.json just below
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
//Add this below
"files.assocations": {
"*.ejs": "html"
},
Reload the Visual Code Editor and you are good
try the following link:
FORMATTING “.EJS” FILE IN VS CODE (VISUAL STUDIO CODE)
In short, you may need to add this to your settings (ctrl/cmd + ,):
"files.associations": {
"*.ejs": "html"
},
Formatting EJS like HTML not work.
Ok, no longer displays an error, but generate a bad formatting.
Examples:
Other post:
Wrong indentation on EJS files with VSCode
simple code:
https://github.com/microsoft/vscode/issues/24013
see last image, form parameters:
https://www.sung.codes/blog/2018/formatting-ejs-file-vs-code-visual-studio-code
We need a plugin. "EJS Language Support" plugin it also doesn't work on formatting.

How to format curly braces for autoformat in intellij

Whenever I hit alt-cmd-l to autoformat my code, it formats my imports and arrays from:
import { CommonModule } from '#angular/common';
let arr = [ myStringVar ]; // simple example, just go with it
to
import {CommonModule} from '#angular/common';
let arr = [myStringVar];
How do I tell IntelliJ to put a space after the opening brace and before the close brace when auto-formatting? (Specifically for javascript, typescript)
I've looked around for the answer and could not find one or asked the question badly. So I apologize if this is duplicate.
I'm on Intellij 2016.3.3
Go to preference, select Editor > Code Style > Javascript and choose Spaces, check the checkboxes in Within section "ES6 import/export brances", and if you want spaces in object literal braces, check "Object literal braces" and as well.
Go to settings and search for ES6 import/export braces. It should take you to Editor -> Code Style -> Javascript (or TypeScript). Just hit that checkbox on the spaces tab and it should add the spaces back.
As you are using Angular, I believe you need to edit the settings for the Typescript and NOT for JavaScript. As I am using IntelliJ IDEA 2021, I will give you the fix for the same. You can do so by going through the following path:
Go to File > Settings... > Editor > Code Style > Typescript
Click on the Spaces tab.
In the Within collapsible, tick the checkbox that says "ES6 import/export braces".
Click on Apply button and then click on Ok button.
If you now go to the Typescript file and hit the combo: Ctrl + Alt + L, it should now format the file correctly.
CAVEAT:
You have to be careful to ensure that you are making the changes for the Scheme that is applicable for your project. For example, maybe you have customized your Editor in some way previously and saved your customizations under a new name, such as MyCustomSettings. Once you do this, you will notice that there is an additional Scheme called the Default scheme. But MyCustomSettings will be your Scheme for your project and you have to make sure that you make the changes for the MyCustomSettings Scheme and not for the Default scheme. You can refer to the Schemes via the following path:
File > Settings... > Editor > Code Style > Typescript, there is a dropdown referred as Scheme. Choose the appropriate one for your Project and make sure you make the above edits in that Scheme.

unable to set breakpoint in intellij

I am trying to set breakpoints, nothing happens for couple of classes that I compiled recently with "mvn install". I am able to set breakpoints to classes which were already built by someone else.
Please let me know if anyone knows how to solve it.
Had the same issue while using IDEA CE 15:
Removing the Python CE plugin 5.0.143.103 fixed the issue... but no Python parsing! :(
File -> Invalidate Caches and Restart helped solve the problem. Thanks Tomasz Nurkiewicz for the directions
In my case, the issue was caused by PHP Plugin (https://plugins.jetbrains.com/plugin/?id=6610). Even after "Invalidate Caches and Restart", the issue persisted.
Uninstalling that PHP plugin, solved my problem.
By nothing happens do you mean that breakpoint isn't hit? Take a closer look at breakpoint icon. Especially see the difference between
and
icons. The latter indicates the code you run while debugging doesn't have any meaningful instruction on that line.
One of the reasons for such behaviour is when code you run is not the code you see. It can happen when application server can is still running old JAR or something similar. This seems to be the case since you say that breakpoints work in older code.
The solution to fixing breakpoints was adding the wildcard file extension "*.py" to the Python File Types in Python (it must have the wildcard symbol prefix, not just ".py") through taking these steps:
Go to:
IntelliJ IDE > Preferences (CMD+,) > Editor > File Types > Recognized
File Types
Under "Recognized File Types" heading:
Scroll down; Select "Python"
(associated Registered Patterns will be shown below)
Under "Registered Patterns" heading:
Click "+" icon; Enter "*.py", Click OK
(do whatever is necessary to achieve this, including removing/renaming others without the wildcard if necessary)
Add breakpoints by:
Select line(s) of code (not an empty line or comment); Going to: Run >
Toggle Line Breakpoint (CMD+F8)
Configure debugging with breakpoints by going to:
Run > Edit Configurations...; Click "+"; Select "Python"; Add a value
for the "Name" property; Select location of the ".py" file to debug
(in the "Script" property); Click OK
Debug using the breakpoints by going to:
Run > Debug... (Fn+CMD+F9); Wait until it stops at a breakpoint;
Inspect variable values shown in the file itself by hovering over
variable; Click variables and view the Frame and Variable details in
the Debug window by going to: View > Tool Windows > Debug (CMD+5)
Important Note: Initially I tried doing the following but after each one I was still unable to use breakpoints afterward:
Removing and reinstalling the Python plugin:
Entering CMD+,; In the dialog window going to Plugins > Install
Jetbrains Plugin.. > "Python" > Install
Updating IntelliJ Ultimate edition to the latest version v2016.3.4
Going to:
File > Invalidate Caches and Restart
Right click on the gutter (where you normally click to set breakpoint)
select "Configure Gutter Icons..." then enable the checkbox at the top that says
"Show gutter icons"
That fixed it for me
Simply closing and reopening file worked in setting gutter breakpoints
This is embarrassing but posting here in case this solution will help somebody else: A breakpoint will not show up if you attempt to place it between executable lines of code. The breakpoint must be located on an executable line of code to work. Make sure you click on the gutter next to an executable line or place your cursor on an executable line when you use the shortcut. Once I did this, the breakpoints worked.
"Click the gutter at the executable line of code where you want to set the breakpoint." https://www.jetbrains.com/help/idea/using-breakpoints.html#set-breakpoints