What is the difference between nx affected:lint --fix and nx format:write?
Different articles does seem to mention that code should be formatted with nx format:write command, but it doesn't seem that it fully relies on ESLint rules.
After formatting I keep having ESLint errors.
Am I missing something?
Thanks
so nx format:write does the code formatting using the prettier config which is in the root of the project.
nx affected:lint --fix instead fixes linting problems.
Related
I am using Eslint and Prettier to style and format my code. I have already set up my eslint and prettier configuration and everything is working fine. However, I am facing a problem on the bitbucket deployment. When my code is deployed, the pipeline fails due to eslint/prettier linting errors. However, these errors were not present when I run my code locally. It seems that the pipeline is not linting correctly?
Some advice or help will be much appreciated.
I ran into this error because of a version issue with eslint. Once we incremented the version, deleted the node-modules and package.lock file, we were able to resolve the errors successfully by formatting the erroring files individually
i would like to use pylint. But when i applied it to my code, which uses pyspark, I got warning "drop_duplicates is not callable". if i change my code from "drop_duplicates" to "dropDuplicates", the warning disappears. How to fix it without changing whole code? I think drop_duplicates is more python-style. I tried to add pyspark-stubs, but it doenst help.
PySpark is a nightmare to deal with when it comes to linting (even with stubs) because of the JVM generated members.
If you plan to ignore those you have two options:
Add the following to .pylintrc file in your project root and make sure your linter is configured to pick it up:
extension-pkg-whitelist=pyspark
generated-members=pyspark.*
ignored-modules=pyspark.sql.functions
Whenever you run lint, run it with the following parameters:
pylint -j 0 --ignored-modules=pyspark.sql.functions --extension-pkg-whitelist=pyspark --generated-members=pyspark.*
Hope this helps.
I created a new project with the create-react-app scaffold, and then I wanted to use the optional-chaining plug-in of babel. I installed the package according to the document and configured it, but vscode prompted grammatical errors. What can help me? please.
this is my package.json.
this is the problem:
If you are using CRA there is probably no way instead of ejecting project and applying Babel presets manually (according to https://github.com/facebook/create-react-app/issues/4604).
However, if you are decided to use eject there should be able to add plugin to babel config which is described here https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining. Probably applying stage-0 preset of Babel (https://babeljs.io/docs/en/babel-preset-stage-0) can also be a solution.
Edit: see also Null-safe property access (and conditional assignment) in ES6/2015
The error you are seeing is from Visual Studio Code's built-in JavaScript and/or TypeScript validator. In order to circumvent this, add this to your vscode settings.json file:
"javascript.validate.enable": false
Additionally you can disable the built-in TypeScript validator like this:
"typescript.validate.enable": false
Once those are disabled, eslint will take over and show you the proper errors when applicable.
Why do I have the same suggestions while typing expression?
Example:
I had exactly the same problem. After a week or so, it get really annoying.
basically, as the comments hint to, there are probably multiple linting or intelisense tools. In my case (for python) i had the pylance extension added.
When i disabled this, the problem went away, but features were missing. So i added it back...
For some reason (i dont know why), this fixed the problem !!!
I can only hypothesise that in some way the extension was corrupted. Nevertheless, it worked.
EDIT:
I can also confirm that unchecking this setting appears to work:
Jupyter: Pylance Handles Notebooks
My current system is Windows 11, with python 3.10.
Final edit (8 Dec 2022):
This is resolved here:
Please could you install VS Code 1.74 and the latest Jupyter, PyLance and Python extension and confirm this still exists.
Visual Studio Code provides an API so third-party extensions and built-in modules can contribute suggestions for auto-completion pop-ups. The system is currently designed so suggestions are merely appended—there's no duplicate detection or removal (perhaps because extensions can also take care of sorting suggestions and such algorithm would get on the way). That means that if you have more than one extension or module for a given language you can easily get duplicate entries.
Having several extensions for PHP is not necessarily a bad idea since they can address different needs (for instance, PHP DocBlocker just creates annotations, it doesn't provide auto-completion suggestions) but you have at least two extensions (PHP Intelephense and PHP Intellisense) that do exactly the same things. That's likely to hurt performance (all your workspace files will be scanned several times) and just adds noise.
I suggest you read the extension descriptions carefully to learn what they do exactly and then figure out which ones you need. Remember that extensions can be enabled/disabled in a per-workspace basis.
The following is just my own totally subjective opinion. Among the PHP extensions that provide code intelligence only two of them seem mature enough:
PHP Intelephense
PHP Intellisense
I've tried both. PHP Intelephense works best for me than PHP Intellisense so that's the one I've kept. I've also disabled php.suggest.basic following the installation instructions because basic suggestions didn't add any value to me (they were blind string matching):
Turn off the php.suggest.basic setting for best results.
... as well as taming builtin Emmet support, which was providing really dumb suggestions:
"emmet.showExpandedAbbreviation": "inMarkupAndStylesheetFilesOnly"
YMMV.
TLDR; Installing pre-release version of Jupyter solves (v2022.11...)
Ok, so after some more extensive experimentation I think I found what's causing this in my case. After looking at the processes I noticed that there were two Pylance processes running, and consistently this would only be a problem if I was working in a session with a jupyter notebook open or one that had been opened.
saun89 17740 37.3 0.3 1008004 199492 ? Sl 20:58 0:22 /home/saun89/.vscode-server-insiders/bin/fef85ea792f6627c83024d1df726ca729d8c9cb3/node /home/saun89/.vscode-server-insiders/extensions/ms-python.vscode-pylance-2022.11.32/dist/server.bundle.js --cancellationReceive=file:9178e897a2b78b36bfd167f79b36c3bdad2931d71b --node-ipc --clientProcessId=17651
saun89 18743 257 0.7 1304584 382288 ? Sl 20:59 0:20 /home/saun89/.vscode-server-insiders/bin/fef85ea792f6627c83024d1df726ca729d8c9cb3/node /home/saun89/.vscode-server-insiders/extensions/ms-python.vscode-pylance-2022.11.32/dist/server.bundle.js --cancellationReceive=file:8744a321767eed92821fd737be4dc7dcfb728284e5 --node-ipc --clientProcessId=17651
Pylance basically spins up a service for the workspace, and then spins up a separate service for the notebook.
Output from "Python Language Server" logs:
Disabling Jupyter removes the duplication, and after installing an earlier version of the extension (v2022.4) this appears to have fully resolved the issue. I'm going to go ahead and log the extension bug once I have something reproducible.
As of 11/30/22, Jupyter Extension Pre-Release version v2022.11.1003281132 is the latest version fixes this issue. Click the gear icon next to the extension and you should see "install another version..." Then you can select version v2022.11.1003281132.
I'm using astropy's units and EartLocation to set my observatory location. Hardcoded for now.
However, when I run the code in VScode pylint is bugging me with errors whereas the code runs fine when I run it in PyCharm and IDLE.
Code:
obsy_location = EarthLocation(lat=52.91044*units.deg, lon=5.242664*units.deg, height=0*units.m)
Pylint is slapping me with 3 errors in that one line of code:
E1101:Module 'astropy.units' has no 'deg' member; maybe 'dex'?
E1101:Module 'astropy.units' has no 'm' member; maybe 'g'?
E1101:Module 'astropy.units' has no 'hour' member
Mind you, I am quite the beginner but since neither PyCharm nor IDLE seem to have any problems running this line I wonder what VScode's pylint is doing here. Can someone enlighten me?
I run VScode with the most recent Anaconda interpreter.
Tools like pylint or PyCharm do static code analysis. They often do a good job for most Python code, but they fail in cases where the dynamic nature of Python is used.
In this case, astropy.units executes Python code on import to generate unit objects like deg (representing the unit "degree") or m (representing the unit "meter"). In this sense, it's expected and normal that you see "astropy.units has no member deg" warnings, because the static analysis tool doesn't execute the import, and thus those things don't exist in their analysis. I see the same warnings from PyCharm (which has it's own static analysis, doesn't execute PyLint in the background like in your case).
Now it is always possible to configure static analysis tools to ignore warnings of certain classes. Looking at https://stackoverflow.com/a/39500741/498873 , I'd expect this VS Code config setting to do the trick (but didn't try):
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=astropy.units"
]
Late to the party, but this showed up when I was trying to solve the problem. Adding this to my settings works for me to turn off that pylint warning:
"python.linting.pylintArgs": [
"--ignored-classes=astropy.units"
]