diff --git a/package.json b/package.json index 3053651d..73886a86 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tools/test.js b/tools/test.js new file mode 100644 index 00000000..0134ac58 --- /dev/null +++ b/tools/test.js @@ -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); + } +}