PHP linter for CodeMirror
glayzzle / codemirror-linter Goto Github PK
View Code? Open in Web Editor NEWPHP linter for CodeMirror
Home Page: https://glayzzle.github.io/codemirror-linter/
License: BSD 3-Clause "New" or "Revised" License
PHP linter for CodeMirror
Home Page: https://glayzzle.github.io/codemirror-linter/
License: BSD 3-Clause "New" or "Revised" License
PHP linter for CodeMirror
Please have a look at codemirror/codemirror5#5907, perhaps it is to be solved here.
The linter in codemirror detects and triggers only the linter registered at position 0,0.
In order to mix in the same document JS / HTML and CSS, it's up to PHP linter to dispatch requests on others parts.
I don't see any elegant way to do it - should try to understand how http://codemirror.net/mode/htmlmixed/ works
The "Try the demo here" link at https://github.com/glayzzle/codemirror-linter to https://php-parser.glayzzle.com/codemirror-linter/ is broken.
The https://php-parser.glayzzle.com/ site does not help very much to find the demo.
I need to retrieve the token location that raised the error, actually got only line and column that started it.
Getting this error trying to use this linter:
Uncaught TypeError: Cannot read property 'line' of undefined
at groupByLine (lint.js?ver=10.5.0:107)
at updateLinting (lint.js?ver=10.5.0:167)
at lint.js?ver=10.5.0:159
at runInOp (codemirror.js?ver=10.5.0:3921)
at CodeMirror.operation (codemirror.js?ver=10.5.0:8603)
at startLinting (lint.js?ver=10.5.0:159)
at lint.js?ver=10.5.0:206
Also, is this rep still being maintained?
Actually minified version of php-parser is 119kb - first target under 70kb, 2nd pass (if possible) under 50kb.
The PHP parser is built in order to handle requirejs with browserify, maybe shoudl add UMD support.
At least in the case of WordPress, there is a very wide range of PHP versions that may be running. For use in its built-in file editor, there is a need to try to prevent users from accidentally introducing fatal PHP errors on their sites. One major source of such fatal errors is accidentally using a language feature from a “recent” PHP version when WordPress is running on an old version of PHP (version 5.2 is still supported). A recent example I came across was attempting to pass a function into empty()
which is a fatal error before PHP 5.5. In other words, this is essentially porting the PHPCompatibility sniffs for PHP_CodeSniffer into php-linter.
While we are working on server-ride solutions to actually try running the code and then rolling it back if there are fatal errors (e.g. #39766 and #21622), it is naturally highly preferable to avoid temporarily whitescreening a site by catching any such errors client-side before the file update is made.
This codemirror-linter for PHP currently is not doing anything with the options
that are passed to it. If there could be a version
passed in, then this could be used to determine whether unsupported PHP language features should be flagged as errors.
It would also be handy if there was a way to pass in a function blacklist which could pre-empt users from attempting to use unavailable functions (e.g. proc_open
and system
), dangerous functions (e.g. eval
and create_function
), or deprecated functions (e.g. wp_list_cats()
). Use of certain functions could generate errors or warnings. This would essentially be porting implementing aspects of the WordPress-Coding-Standards for PHP_COdeSniffer.
💡 Crazy idea: Could PHP_CodeSniffer and its sniffs as a whole be transpiled into JS and then run in the browser?
Here is the related WordPress Trac ticket: https://core.trac.wordpress.org/ticket/41873
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.