ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

Add configuration item to configure lint-events and add command to initiate linter (fixes #91, #114 & #125) #116

Closed rikvdh closed 1 year ago

rikvdh commented 6 years ago

@ikappas I think this should work. I can't seem to get my environment up and running. NPM keeps complaining about unfound commands. Can you take a look? This should fix #91

Edit: https://travis-ci.org/rikvdh/vscode-phpcs/builds/384413612

mfdeveloper commented 6 years ago

Hello @rikvdh .This is a usefull configuration.

Additionally, I think that will be great add too lintOnSave and lintOnOpen (or any other name for this options) properties for avoid performance issues. Maybe group this options into a single object, like this:

lintOn: {
   typing: false,
   save: true
   open: true
}

Together with this options, register a new command to executevalidateSingle() method can be awesome!!

What do you think about this?

rikvdh commented 6 years ago

@mfdeveloper Good idea! I've added it to the code. Also a command to call the linter on demand. I suppose this can indeed be useful in some cases.

@ikappas Do you have any time to review this? Thanks!

screen shot 2018-08-05 at 21 53 59 screen shot 2018-08-05 at 21 54 13

mfdeveloper commented 6 years ago

Woow, pretty awesome @rikvdh ! Thank you so much for implement my suggestions! This is lgtm for me

Once that you created Lint current file command, my only additional suggestion is register another command for Lint all. This is great for CI builds and local development to verify all files that contains code sniffer "problems". This new comand, needs read a specific folder, and exclude folders defined in some setting, like phpcs.exclude.

Maybe can be other PR for avoid "mix" many features into a only PR. What do you think about this?

PS: If you wish share/build a .vsix version of this extension before this PR is reviewed and accepted, I've been added some npm scripts to do automate this process. See my fork: mfdeveloper/vscode-phpcs/install-package-vsix. Just run npm run install:extensions. This branch contains docker support too.

rikvdh commented 6 years ago

You're welcome @mfdeveloper. Before implementing more commands perhaps @ikappas should take a look before we take a wrong turn since it is his project after all.

I'm not sure about the Lint all feature, I've never heard people running CI-builds with vscode. I'd much prefer running phpcs by hand for this cases. I've also read a lot of other issues with linting all files and looking at the code, how documents are handled in the Language Server this doesn't feel right for me at this point.

For now, I want to wait for the owner or other maintainer to respond. But for some use-cases it may be a good idea!

rahulv3a commented 5 years ago

@rikvdh It seems like @ikappas won't be able to look at your PR anytime soon. For some reason, lintOnType is always so far behind when I code. It is driving me nuts. I just want to lint when I save my file. I tried to use your fork by replace the extension files with https://github.com/rikvdh/vscode-phpcs/tree/feature/lint-while-typing and ran npm install. After this, VS Code stops detecting the phpcs extension. I'm unable to figure it out. Could you point me in the right direction.