ESlint: Expected !== and instead saw != - visual-studio

i have already tried to find eslint rules or options in the project but i could not find these.
i am using angularjs with mvc5 template type of aspnet zero.
How to disable eqeqeq in visual studio for eslint in aspnet zero ?

The OP is asking how to disable this One Rule for the Entire Project.
The eqeqeq rule is explained here: https://eslint.org/docs/rules/eqeqeq
Disable One Rule at the Project Level:
To change one rule for the entire project, you should edit the .eslintrc file.
To find this file, you could look up the file path in Visual Studio 2017 using:
Tools -> Options -> TextEditor -> JavaScript/TypeScript -> Linting
It'll probably be somewhere like: C:\Users\<UserName>\.eslintrc
Editing the file you will see this near the top (around Line 20):
"rules": {
"eqeqeq": 2,
The following are synonymous: 0 = "off", 1 = "warn", and 2 = "error".
You may disable the rule by changing the 2nd line to this:
"eqeqeq": "off",
I based this off of the information found here:
https://eslint.org/docs/user-guide/configuring#configuring-rules
Disable One Rule at the File Level:
Add this line in your File:
/*eslint-disable eqeqeq*/
OR
/*eslint eqeqeq: "off"*/
It is important you add this near the top of your Javascript file before your scripts.
This is because it takes affect after the line you add this comment to.
How to do this is buried in this link under the section "Disabling Rules with Inline Comments":
https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
Smarter is Better Than Disabling
If you're interested in changing the equality-operator warnings so they are "smarter" and won't always throw warnings (when it is obvious they do not apply), then this may be the better option.
This way you still keep these warnings when it really matters.
At the Project Level, use this in the .eslintrc file:
"eqeqeq": ["error", "smart"],
OR
At the File Level, use this:
/*eslint eqeqeq: ["error", "smart"]*/
This "Smart" feature is further explained here:
https://eslint.org/docs/rules/eqeqeq#smart
Dislaimer: I have verified this works at the File Level, but have not tested at the Project Level.
The .eslintrc file appears to be in Json, and these proposed edits fit the expected format.
It also follows the examples I found in the links above.

Add the below line to the JavaScript code to disable checking.
/*eslint eqeqeq: ["error", "smart"]*/

Create this file ".eslintrc" in the project's root directory and add the below code.
{
"rules": {
"eqeqeq": "off"
}
}
Note: for more info go to this page: https://eslint.org/docs/latest/user-guide/configuring/rules#disabling-rules

Related

clang-format in VSCodium breaking when using some rules

I'm trying to define custom format rules, and for some reason clang-format reverts to the default rules, despite my file having no discernable mistakes.
More precisely, I'm trying to define use detailed rules for AlignConsecutiveDeclarations. This .clang-format file works :
AlignConsecutiveDeclarations: true
UseTab: "Always"
IndentWidth: 4
TabWidth: 4
And this one, which should give the exact same result, breaks and reverts to default format :
AlignConsecutiveDeclarations:
Enabled: true
UseTab: "Always"
IndentWidth: 4
TabWidth: 4
Am I doing something wrong ? Or is the extension broken ? My file seems completely valid to me, but I very well could be wrong. Also please note this is a deliberately reduced example, even when specifying more options, the rule still breaks the entire file.
I'm using VSCodium 1.75.0 on macOS 13.2.1, with the clangd extension version 0.1.23 ; as far as I have checked those are the latest versions of everything.
Looking at clangd's output in the console, this is what it says about the affected rule :
/Users/crysambrosia/Developer/Project/.clang-format:2:2: error: unknown enumerated scalar
Enabled: true
This changes to whatever the first variable is, no matter which one it is.
This option is available in clang-format 15. You seem to use the older clang-format. It's unclear from your question what clang-format do you uses. VSCode, macOS, clangd all their versions are unrelated to clang-format. Compare https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html and https://releases.llvm.org/15.0.0/tools/clang/docs/ClangFormatStyleOptions.html in two browser tabs. You will see the difference.

Syntax highlighting for .js.erb won't stay as JavaScript [duplicate]

Is there a way to make Sublime Text use a different syntax hilighting plugin for files inside a specific directory tree?
E.g. By default I want to use the default Javascript file type for .js files, but for files under ~/Unity/ folder I want to use Unity3d-Javascript file type.
Check out the ApplySyntax package. This is a very powerful plugin that allows you to apply arbitrary regexes to several different aspects of a file (file name, contents, first line, suffix, etc.) and then assign a syntax based on them. Once installed, open Preferences -> Package Settings -> ApplySyntax -> Settings-Default to read all the notes and see how the regexes are set up. Then, open ... -> Settings-User and add your custom regexes. I haven't tested this, but something along these lines should work:
{
"name": "Unity3D/UnityJavaScript",
"rules": [
{"file_name": ".*/Unity/.js$"}
]
}
Good luck!

How to create this sublime text syntax?

I am trying to create a simple sublime syntax where when the first word of a line is "DONE" the whole line turns to a different color.
For example:
- do this
DONE - do that // this line turns green
- but also do this
My two questions are:
- How does one go about creating a ST syntax
- How would I create the above simple syntax.
The most you could highlight is the region containing text. I don't know if that's what you are looking for. To do this would require defining a tmLanguage file and modifying you tmTheme file. The tmLanguage file describes a set of regular expressions for which a scope is applied to the text within ST. The tmTheme file takes the scopes applied, and applies some coloring. I'm not an expert on writing either of these files, so you may need to do some experimentation on your own.
For information on writing syntax files, see here and here. The theme files are much simpler, in terms of defining them. Those guides recommend using AAAPackageDev, which is not necessary (and not compatible with ST3 last I checked). The language files are all XML, which you can work with, but I find working in JSON or YAML easier. If you feel the same way, you can start with the below snippet and use SerializedDataConverter to convert between XML and PLIST/JSON.
{
"name": "Syntax Name",
"scopeName": "source.syntax_name",
"fileTypes": [""],
"patterns": [
],
"uuid": "ca03e751-04ef-4330-9a6b-9b99aae1c418"
}
I can't recall the location of any references, but I'm sure they're out there. Though, simply viewing some existing theme files may be enough for you. TO view these, you can use PackageResourceViewer. Isn't really necessary if you are working in ST2, but makes things much easier in ST3. To begin working on your own custom theme, I'd copy the contents of the theme file you are currently to a new file, and save it in your Packages/User directory. That way, you always have something to revert to, in case you mess something up.

Custom syntax highlighting in Geany

I am trying to create custom syntax highlighting for Kivy '.kv' files in the Geany editor. Although the specific filetype seems irrelavant to the issue I'm having, as any efforts I make at getting syntax highlighting to work for a custom filetype results in a completely non-highlighted file. I believe I have done my homework on this, and nothing seems to work.
I have added the following to ~/.config/geany/filetype_extensions.conf
Kivy=*.kv;
I also have a custom type definition file named 'filetypes.Kivy.conf' in ~/.config/geany/filedefs/. I have tried basing this file off several of the stock type definition files in /usr/share/geany/ and the file never gets any syntax highlighting applied in Geany. Right now, just for experimentation's sake, my 'filetypes.Kivy.conf' file looks like this:
# For complete documentation of this file, please see Geany's main documentation
[settings]
# default extension used when saving files
extension=kv
# single comments, like # in this file
comment_single=#
[keywords]
# all items must be in one line
primary=size canvas
secondary=pos size
[indentation]
width=4
# 0 is spaces, 1 is tabs, 2 is tab & spaces
type=0
This is very loosly based on the stock XML definition file, but like I said I've tried many other stock files. In many cases I only changed the 'extension=' value to kv and still no highlighting was applied, even though going to Document>Set Filetype in Geany and choosing virtually any random filetype (besides my custom entry) would yeild some sort of highlighting within my .kv file. This is even the case when using the unmodified contents of a stock definition which otherwise works fine on my .kv file when specifically selected in Geany!
Also, the Kivy filetype is listed and selected by default in Document>Set Filetype within Geany, so I must be doing something right here!
I realize this similar question has been asked, but the solutions seem irrelavent to my case, as I've tried every related topic on this and many other sites. My Geany version is 1.22 and I'm running Arch Linux. This is driving me nuts - any suggestions?
Thank you!
Set lexer_filetype= property in the [settings] section of your filetype file. Working highlighting requires that there is a lexer that could be used for highlighting the .kv-files.
For more info see http://www.geany.org/manual/#lexer-filetype
There are three important things to obey:
the configuration file should be placed in "~/.config/geany/filedefs"
the configuration file must have the extension ".conf" - otherwise it won't show up at all (the files in "/usr/share/geany/filesdefs", where I copied my base file from, do not have a ".conf" extension!)
you must set the "lexer_filetype" to an existing (presumably builtin) configuration; e.g. "lexer_filetype=Python"

Exclude a path from Textmate2's 'command T'

When pressing command+T (⌘T) to bring up the quick file browser, is there a way (using .tm_properties) to exclude a path from it?
We have a list of the settings on the wiki. The settings you want are excludeInFileChooser & includeInFileChooser.
Note that in r9309 it was changed so that the file must be matched by the include rule to be included.
Addendum: The file chooser and find window both have editable globs in their windows that default to including everything so the note about file having to be matched by an include rule isn't as relevant as it is for the sidebar or generic rules. (The glob in the window is treated as the last include rule applied.)
The wiki page has so-so documentation of this, as well as the syntax for the work is less than ideal when dealing with paths. Here are some snippets, with comments, as to what they are accomplishing.
Maybe this will help
# Exclude image files
exclude = "{$exclude,*.tiff,*.png,*.jpg,*.jpeg}"
# Project should use master as the parent dir
[ "/Volumes/broux/working/{/,**}*"]
projectDirectory = "/Volumes/broux/working/master"

Resources