WordPress / better-code-editing

[✅ Merged into 4.9-alpha] Better Code Editing WordPress plugin
https://wordpress.org/plugins/better-code-editing/
37 stars 16 forks source link

Add code linting #3

Closed georgestephanis closed 7 years ago

georgestephanis commented 7 years ago

Fixes #2

Doesn't offer PHP syntax checking -- we may need to do some sort of ajax command to have the server lint the php code, I'm not seeing much by way of pure JS syntax checking.

georgestephanis commented 7 years ago

The error tooltips don't seem to be displaying for me in the customizer for some reason -- if anyone can take a look at why, that'd be appreciated.

georgestephanis commented 7 years ago

Tooltips now show in the customizer -- I had to bump their z-index to 500000 because of reasons.

westonruter commented 7 years ago

So there is no PHP syntax error checking implemented in JS for CodeMirror? What about http://codemirror.net/1/contrib/php/ ?

georgestephanis commented 7 years ago

Hadn't seen that previously, I'm playing with it now. Probably because I was only looking at the CM Core repo.

Thanks!

georgestephanis commented 7 years ago

Ah, that's for the old CodeMirror 1 branch -- current is v5-- I'm exploring to see what's feasible.

georgestephanis commented 7 years ago

I'm sure there's some optimizations involving promises that I can have ^^ do, but for the moment I can't even get the helper to run to do the linting -- I'm not sure what I'm doing wrong, maybe fresh eyes can help?

westonruter commented 7 years ago

It makes me really nervous allow arbitrary PHP to be written to the file system, even though it's in a temporary directory. I am dubious as to whether the php binary will be available, and I think shell_exec is disabled by many hosts for security reasons. If PHP is to be used for linting, then I think the php_check_syntax() function should be used instead, but alas it is deprecated was removed from PHP. I don't see a good server-side option here.

georgestephanis commented 7 years ago

I agree completely.

Unfortunately I haven't found a pure JS linter for PHP -- they're all build tool wrappers around a PHP binary.

georgestephanis commented 7 years ago

I'm nuking my work on a PHP linter -- I'm really not happy with it, hopefully we'll find something better if we do anything at all.