Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting not working. Nothing is showing up when there are supposed to be errors. Errors don't show while coding, only if I compile would I get error messages. #274

Open
adriandelgg opened this issue Aug 2, 2021 · 17 comments

Comments

@adriandelgg
Copy link

Hello, I'm using the Solidity extension & before it used to work just fine and would show linting for errors, but now I never get them. It's clear that the errors are there because when I compile with Hardhat/Truffle it complains, but I'm not getting linting as I'm coding like how Remix IDE does.

I don't understand why it's not working anymore and it's really upsetting since I rely on the linting for work.

@adriandelgg adriandelgg changed the title Linting not working. Nothing is showing up when there are supposed to be errors. Linting not working. Nothing is showing up when there are supposed to be errors. Errors don't show while coding, only if I compile would I get error messages. Aug 2, 2021
@juanfranblanco
Copy link
Owner

Hi @adriandelgg what are your settings?

@adriandelgg
Copy link
Author

Hey @juanfranblanco, thanks for replying and making this awesome VS Code extension.
I've attached the extension settings I have. It used to work where I would get linting while typing like how Remix does, but now I don't anymore and I have no idea why.
2021-08-02_10-55_1
2021-08-02_10-55

@adriandelgg
Copy link
Author

Any ideas as to why it's not working?

Is there any way I can completely delete the extension and any past versions so that I can have a brand new fresh installation of it?

@AbhiGene
Copy link

bump on this thread, I am having the same error and it is causing me great trouble

@juanfranblanco
Copy link
Owner

@adriandelgg @ClockworkRainbow apologies this thread went out of track, are you still having the issues?

@adriandelgg
Copy link
Author

@adriandelgg @ClockworkRainbow apologies this thread went out of track, are you still having the issues?

It's okay. I'm not sure if I'm supposed to get the exact linting i get like i do with Remix IDE.

For example, I'm Remix, it detects on the IDE if I can turn a function into view, while on VSCode it only suggests that when I run the compiler.

Is this the right behaviour?

@juanfranblanco
Copy link
Owner

@adriandelgg does it look like this? This is mainly driven by the compiler in the background.
error_suggestions_visibility_compiler

@juanfranblanco
Copy link
Owner

juanfranblanco commented Sep 28, 2021

Oh I just have seen your settings, you have put in the local compiler path "latest", remove that value.. (this is why i needed glasses :) ) Edit: although it should not make any differences as your compiler is set to remote.

@adriandelgg
Copy link
Author

@adriandelgg does it look like this? This is mainly driven by the compiler in the background.
error_suggestions_visibility_compiler

No, mine doesn't do that.😭
Am I supposed to download something else aside from the Solidity extension for it to work like that?

@juanfranblanco
Copy link
Owner

No you don't need to install anything else.
What I am seeing is that you have enabled the error reporting as you type, you are using the latest version of solidity (which is downloaded, "remote"), you can compile as you have said and it shows the errors. So there might be an issue when starting the server. Can you try the latest version? This might solve your problem.

@adriandelgg
Copy link
Author

adriandelgg commented Sep 29, 2021

I tried & it's still not working, and now I'm getting a new error.
Source "@openzeppelin/contracts/access/Ownable.sol" not found: File import callback not supported

I'm not sure why I keep having issues with the extension.
2021-09-28_19-36
As well as this error on another .sol file with pragma solidity >0.6.1 <0.7.0;.

Source file requires different compiler version (current compiler is 0.8.8+commit.dddeac2f.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version

I wasn't getting these errors until I changed what you said, but I've gotten them before.

@adriandelgg
Copy link
Author

adriandelgg commented Sep 29, 2021

These are my settings.json in VS Code:

{
	"telemetry.enableCrashReporter": false,
	"liveServer.settings.donotShowInfoMsg": true,
	"git.autofetch": true,
	"workbench.iconTheme": "material-icon-theme",
	"editor.fontFamily": "'Fira Code', monospace",
	"telemetry.enableTelemetry": false,
	"workbench.startupEditor": "newUntitledFile",
	"editor.renderWhitespace": "none",
	"workbench.editor.decorations.colors": true,
	"oneDarkPro.bold": true,
	"git.enableSmartCommit": true,
	"gitlens.advanced.messages": {
		"suppressGitMissingWarning": true
	},
	"explorer.confirmDragAndDrop": false,
	"[json]": {
		"editor.quickSuggestions": {
			"strings": true
		},
		"editor.suggest.insertMode": "replace",
		"gitlens.codeLens.scopes": ["document"],
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'zero', 'onum'",
	"editor.fontSize": 15.95,
	"javascript.updateImportsOnFileMove.enabled": "always",
	"editor.tabSize": 2,
	"[javascript]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"[typescript]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"[typescriptreact]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"prettier.singleQuote": true,
	"prettier.arrowParens": "avoid",
	"prettier.useTabs": true,
	"prettier.trailingComma": "none",
	"explorer.confirmDelete": false,
	"[javascriptreact]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"[html]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"editor.minimap.renderCharacters": false,
	"editor.cursorSmoothCaretAnimation": true,
	"editor.cursorWidth": 2,
	"editor.tokenColorCustomizations": {
		"textMateRules": [
			{
				"scope": ["entity.name.function", "entity.name.method"],
				"settings": {
					"fontStyle": "bold"
				}
			}
		]
	},
	"editor.semanticHighlighting.enabled": true
	"editor.cursorBlinking": "expand",
	"terminal.integrated.cursorBlinking": true,
	"editor.linkedEditing": true,
	"launch": {
		"configurations": [],
		"compounds": []
	},
	"typescript.updateImportsOnFileMove.enabled": "always",
	"emmet.showSuggestionsAsSnippets": true,
	"emmet.includeLanguages": {
		"javascript": "javascriptreact",
		"typescript": "typescriptreact"
	},
	"solidity.compileUsingRemoteVersion": "v0.8.7+commit.e28d00a7",
	"git.confirmSync": false,
	"tailwindCSS.emmetCompletions": true,
	"files.trimTrailingWhitespace": true,
	"codesnap.backgroundColor": "#fb6f7d",
	"codesnap.boxShadow": "rgba(0, 0, 0, 0.55) 0px 10px 20px",
	"git.enableCommitSigning": true,
	"editor.minimap.enabled": false,
	"editor.formatOnSave": true,
	"[markdown]": {
		"editor.defaultFormatter": "yzhang.markdown-all-in-one"
	},
	"security.workspace.trust.untrustedFiles": "open",
	"terminal.integrated.defaultProfile.linux": "zsh",
	"[jsonc]": {
		"editor.defaultFormatter": "esbenp.prettier-vscode"
	},
	"python.pythonPath": "C:\\Users\\adria\\AppData\\Local\\Programs\\Python\\Python39\\python.exe",
	"editor.bracketPairColorization.enabled": true,
	"redhat.telemetry.enabled": false,
	"vs-kubernetes": {
		"vscode-kubernetes.kubectl-path.linux": "/home/CodeOnBlocks/.vs-kubernetes/tools/kubectl/kubectl",
		"vscode-kubernetes.helm-path.linux": "/home/CodeOnBlocks/.vs-kubernetes/tools/helm/linux-amd64/helm",
		"vscode-kubernetes.minikube-path.linux": "/home/CodeOnBlocks/.vs-kubernetes/tools/minikube/linux-amd64/minikube"
	},
	"workbench.colorTheme": "Electronic Moonlight"
}

As well as all the global NPM packages I have installed:

├── eslint@7.32.0
├── ganache-cli@6.12.2
├── hardhat-shorthand@1.0.0
├── mocha@9.1.1
├── nodemon@2.0.12
├── npm-check-updates@11.8.5
├── npm@7.24.0
├── truffle@5.4.9
├── typescript@4.4.3
└── yarn@1.22.11

@adriandelgg
Copy link
Author

I FIGURED OUT WHY IT'S NOT WORKING. The "solidity.packageDefaultDependenciesDirectory": needs to be set to my project.

However, how can I make it so it auto detects it? In the screenshot, you can see that in my workspace I have multiple folders with different projects. I had to set the rule for this specific project as "solidity.packageDefaultDependenciesDirectory": "bp-nft-meetings/hardhat/node_modules" in my global settings.json file, but obviously this isn't ideal because I have multiple projects & don't want to be having to manually change it every time.

2021-09-28_20-04

Is there a way to set the settings.json for each individual project or something?

@juanfranblanco
Copy link
Owner

Ah yeah at the moment the settings in a workspace apply to all folders, (workspace settings), the only solution is to open each folder separate. This is the same for the new remappings. So mainly your bp-projects, you will need to open each folder separate, we are all discussing to have a project file, which will make things much easier (eventually)

@adriandelgg
Copy link
Author

Ah yeah at the moment the settings in a workspace apply to all folders, (workspace settings), the only solution is to open each folder separately. This is the same for the new remappings. So mainly your bp-projects, you will need to open each folder separate, we are all discussing having a project file, which will make things much easier (eventually)

That'd be awesome. I've noticed that even though the path is set to another project, if I go into a new project it will actually still work, so that's good. But yes, it'd be great to have it detect it all on its own. I'm assuming it works because it finds the necessary info in the other project, but if I import for example @openzepplin I'm assuming it may be referencing the node_modules from the other project and not the current one I'm on.

@juanfranblanco
Copy link
Owner

@adriandelgg yes that is the side effect, this workspaces folders is rather painful, as you will need folder settings per folder in workspace, but that is not possible.

@juanfranblanco
Copy link
Owner

@adriandelgg try to add a remappings.txt file in the root folder of each project. Here you can map specific files or folder.
ie

@openzeppelin/=lib/openzeppelin-contracts/
ds-test/=lib/ds-test/src/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants