add a test for the transition suppressor rule

This commit is contained in:
tophf 2021-03-09 19:22:17 +03:00
parent 4ae2c67033
commit ff63b84489
2 changed files with 18 additions and 2 deletions

View File

@ -28,11 +28,11 @@
},
"scripts": {
"lint": "eslint \"**/*.js\" --cache",
"test": "npm run lint",
"test": "node tools/test.js && npm run lint",
"update-locales": "tx pull --all && node tools/fix-transifex.js",
"update-transifex": "tx push -s",
"build-vendor": "node tools/build-vendor",
"zip": "node tools/zip.js",
"zip": "npm test && node tools/zip.js",
"start": "web-ext run",
"start-chrome": "web-ext run -t chromium",
"preversion": "npm test",

16
tools/test.js Normal file
View File

@ -0,0 +1,16 @@
'use strict';
const fs = require('fs');
testGlobalCss();
function testGlobalCss() {
const css = fs.readFileSync('global.css', {encoding: 'utf8'});
const ERR = 'global.css: the first rule must be the transition suppressor';
const RX_SUPPRESSOR = /^[^{}]+{\s*transition:\s*none\s*!\s*important/i;
const RX_COMMENT = /\/\*([^*]|\*(?!\/))*(\*\/|$)/g;
if (!RX_SUPPRESSOR.test(css.replace(RX_COMMENT, ''))) {
console.error(ERR);
process.exit(1);
}
}