- Notifications
You must be signed in to change notification settings - Fork8
NPM package to statically analyze the compatibility of a web page across a given browser scope
SphinxKnight/compat-tester
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
compat-tester is a static tool analysis that, provided a "browser scope", scans HTML, CSS and JS files and outputs a compatibility report for features that might not be available for such a scope (e.g. if my scope contains IE8 and mystyle.css stylesheet contains CSS Grid properties).
compat-tester's approach is pretty naive and currently doesn't detect anyprogressive enhancement, polyfills, etc. that could improve actual compatibility.
This tool is heavily built upon:
mdn-browser-compat-datafrom MDN team, pleasecontribute so that more data is available :)htmlparser2for parsing HTMLcss-treefor parsing CSSThanks to them for doing the heavy work :)
This project must be considered as alpha-stage.
npm install compat-testercompat-tester # Scans index.html as root file and uses scope.json as defaultscompat-tester mySite.html myScope.jsoncompat-tester https://developer.mozilla.org/en-US/ myScope.json # Scans the remote web pagecompat-tester -html myPage.html myScope.json # Only scans the HTML of myPage.htmlcompat-tester -css myStyle.css myScope.json # Only scans the CSS of myStyle.csscompat-tester -js myScript.js myScope.json # !Not implemented yet! Only scans myScript.jsconst compatTester = require("compat-tester");const options = {"contrib": "all"} // "all"|"true"|"null"let report = compatTester.cssStringAnalyzer(string, browserScope, callback[, options ]);let report = compatTester.cssFileAnalyzer(filePath, browserScope, callback[, options ]);let report = compatTester.htmlStringAnalyzer(string, browserScope, callback[, options ]);let report = compatTester.htmlFileAnalyzer(filePath, browserScope, callback[, options ]);let report = compatTester.jsStringAnalyzer(string, browserScope, callback[, options ]); // Not implemented yetlet report = compatTester.jsFileAnalyzer(filePath, browserScope, callback[, options ]); // Not implemented yetThescope.json file is simply a JSON file where the keys are the identifiers of the browsers you want/need to support, followingmdn-browser-compat's syntax and where the values are the minimum version you want/need to support.For instance with the followingscope.json
{ "ie":"8", "firefox":"34"}compat-tester will report any detected feature that isn't available before Internet Explorer 8 and Firefox 34.
Using an scope with IE "1" (not a typo ;)) and Firefox "8", the report might look like:
HTML Report: firefox incompatible - @index.html#L21 - <link> - attrcrossorigin - minVer: 18 firefox incompatible - @index.html#L21 - <link> - attrintegrity not implemented firefox incompatible - @index.html#L99 - <link> - attrcrossorigin - minVer: 18 firefox incompatible - @index.html#L186 - <details> - minVer: 49 ie incompatible - @index.html#L21 - <link> - attrcrossorigin not implemented ie incompatible - @index.html#L21 - <link> - attrintegrity not implemented ie incompatible - @index.html#L99 - <link> - attrcrossorigin not implemented ie incompatible - @index.html#L117 - <header> - minVer: 9 ie incompatible - @index.html#L186 - <details> not implementedCSS Report: firefox incompatible - @test_files/style.css#L191 - Property: animation - minVer: 16 firefox incompatible - @test_files/style.css#L477 - Property: word-wrap - minVer: 49 firefox incompatible - @test_files/style.css#L485 - Property: font-variant-ligatures - minVer: 34 firefox incompatible - @test_files/style.css#L489 - Property: word-wrap - minVer: 49 firefox incompatible - @test_files/style.css#L491 - Property: word-break - minVer: 15 firefox incompatible - @test_files/style.css#L522 - Property: box-sizing - minVer: 29 firefox incompatible - @test_files/style.css#L686 - Property: box-sizing - minVer: 29 firefox incompatible - @test_files/style.css#L941 - Property: transform - minVer: 16 ie incompatible - @test_files/style.css#L49 - Property: background-color - minVer: 4 ie incompatible - @test_files/style.css#L54 - Property: background-color - minVer: 4 ie incompatible - @test_files/style.css#L58 - Property: content - minVer: 8 ie incompatible - @test_files/style.css#L62 - Property: font-weight - minVer: 3 …The following features are currently missing :'(
(current feature set: properties, @-rules)
- Selectors
(current feature set: nothing)
- Parsing JS and dealing with primary features like statements, operators
- Resolving a tree of resources (e.g. fetch internal HTML pages, CSS with @import…)
- Adding comments to locally disable warnings
- An interactive CLI to easily create a
scope.jsonfile (something like "compat-tester --init") - Tests
- Addon for VSCode
- Addon for SublimeText
This project is one of my first "real" JavaScript project, feel free to addissues if you see any minor/major/confusing/horrendous stuff.
About
NPM package to statically analyze the compatibility of a web page across a given browser scope
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.