From cf6f7858878fcb798f82fcf577f2d75c37fd11fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Thu, 12 Oct 2017 13:02:08 +0200 Subject: [PATCH 01/24] initial implementation --- package.json | 6 +- src/babel/preval-extract/index.js | 18 ++ src/index.stylelint.js | 25 +++ src/tools/stylelint-preprocessor.js | 35 ++++ stylelint-preprocessor.js | 1 + website/src/components/.stylelintrc | 8 + yarn.lock | 277 +++++++++++++++++++++++++++- 7 files changed, 366 insertions(+), 4 deletions(-) create mode 100644 src/index.stylelint.js create mode 100644 src/tools/stylelint-preprocessor.js create mode 100644 stylelint-preprocessor.js create mode 100644 website/src/components/.stylelintrc diff --git a/package.json b/package.json index 36d515505..29e69dd67 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,9 @@ "/babel.js", "/server.js" ], + "peerDependencies": { + "stylelint": "8.x" + }, "dependencies": { "babel-code-frame": "^6.26.0", "babel-core": "^6.26.0", @@ -62,7 +65,8 @@ "glob": "^7.1.2", "jest": "^21.1.0", "prettier": "^1.6.1", - "strip-ansi": "^4.0.0" + "strip-ansi": "^4.0.0", + "stylelint": "^8.2.0" }, "jest": { "testRegex": "/__(integration-)?tests__/.*\\.(test|spec)\\.js$", diff --git a/src/babel/preval-extract/index.js b/src/babel/preval-extract/index.js index f1615cf11..1e4b1d17c 100644 --- a/src/babel/preval-extract/index.js +++ b/src/babel/preval-extract/index.js @@ -21,6 +21,8 @@ import prevalStyles from './prevalStyles'; import resolveSource from './resolveSource'; import extractStyles from './extractStyles'; +let interceptors = {}; + export const externalRequirementsVisitor = { Identifier(path: NodePath) { if (path.isReferenced() && getSelfBinding(path) && !isExcluded(path)) { @@ -100,9 +102,25 @@ export default (babel: BabelCore) => { types, }); + runInterceptor('pre-eval', { requirements }); + prevalStyles(babel, path, state, requirements); } }, }, }; }; + +export function addInterceptor(name: string, fn: Function) { + interceptors[name] = fn; +} + +function runInterceptor(name: string, ...args: any[]) { + if (interceptors[name]) { + interceptors[name](...args); + } +} + +// function clearInterceptors() { +// interceptors = {}; +// } diff --git a/src/index.stylelint.js b/src/index.stylelint.js new file mode 100644 index 000000000..fb31b0ac0 --- /dev/null +++ b/src/index.stylelint.js @@ -0,0 +1,25 @@ +/* @flow */ + +import dedent from 'dedent'; + +// Custom implementation of css.named for stylelint. +function cssNamed() { + return (template: string[], ...expressions: string[]) => { + const styles = dedent( + template, + ...expressions.map(expression => String(expression).replace('\n', ' ')) + ).trim(); + + process.emit('linaria-extract', { styles }); + + return ''; + }; +} + +export const css = cssNamed(); + +css.named = cssNamed; + +export { default as include } from './include'; +export { default as names } from './names'; +export { default as styles } from './styles'; diff --git a/src/tools/stylelint-preprocessor.js b/src/tools/stylelint-preprocessor.js new file mode 100644 index 000000000..a2ded59ab --- /dev/null +++ b/src/tools/stylelint-preprocessor.js @@ -0,0 +1,35 @@ +import * as babel from 'babel-core'; +import { addInterceptor } from '../babel/preval-extract'; + +export default function linariaStylelintPreprocessor(options) { + return { + code(input, filename) { + const extractedStyles = []; + process.on('linaria-extract', ({ styles }) => { + extractedStyles.push(styles); + }); + + addInterceptor('pre-eval', ({ requirements }) => { + requirements.forEach(requirement => { + // eslint-disable-next-line no-param-reassign + requirement.code = requirement.code.replace( + /import {.*} from ["|'](linaria)["|']/, + (substring, ...args) => + substring.replace(args[0], 'linaria/build/index.stylelint.js') + ); + }); + }); + + const { code, ast } = babel.transform(input, { + filename, + sourceMaps: true, + }); + + return extractedStyles.reduce( + (acc, style, i) => `${acc}\n.test${i} {${style}}`, + '' + ); + }, + result(stylelintResult, filepath) {}, + }; +} diff --git a/stylelint-preprocessor.js b/stylelint-preprocessor.js new file mode 100644 index 000000000..8e6c7d09b --- /dev/null +++ b/stylelint-preprocessor.js @@ -0,0 +1 @@ +module.exports = require('./build/tools/stylelint-preprocessor').default; diff --git a/website/src/components/.stylelintrc b/website/src/components/.stylelintrc new file mode 100644 index 000000000..b5f3734f0 --- /dev/null +++ b/website/src/components/.stylelintrc @@ -0,0 +1,8 @@ +{ + "processors": ["../../../stylelint-preprocessor.js"], + "syntax": "scss", + "rules": { + "block-no-empty": true, + "property-no-unknown": true + } +} diff --git a/yarn.lock b/yarn.lock index f7a710640..7e60ed2b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -223,6 +223,17 @@ asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" +autoprefixer@^7.1.2: + version "7.1.5" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-7.1.5.tgz#d65d14b83c7cd1dd7bc801daa00557addf5a06b2" + dependencies: + browserslist "^2.5.0" + caniuse-lite "^1.0.30000744" + normalize-range "^0.1.2" + num2fraction "^1.2.2" + postcss "^6.0.13" + postcss-value-parser "^3.2.3" + aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" @@ -1018,6 +1029,13 @@ browserslist@^2.1.2: caniuse-lite "^1.0.30000718" electron-to-chromium "^1.3.18" +browserslist@^2.5.0: + version "2.5.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.5.1.tgz#68e4bc536bbcc6086d62843a2ffccea8396821c6" + dependencies: + caniuse-lite "^1.0.30000744" + electron-to-chromium "^1.3.24" + bser@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" @@ -1065,6 +1083,10 @@ caniuse-lite@^1.0.30000718: version "1.0.30000721" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000721.tgz#931a21a7bd85016300328d21f126d84b73437d35" +caniuse-lite@^1.0.30000744: + version "1.0.30000745" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000745.tgz#20d6fede1157a4935133502946fc7e0e6b880da5" + capture-stack-trace@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" @@ -1157,6 +1179,13 @@ cliui@^3.2.0: strip-ansi "^3.0.1" wrap-ansi "^2.0.0" +clone-regexp@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/clone-regexp/-/clone-regexp-1.0.0.tgz#eae0a2413f55c0942f818c229fefce845d7f3b1c" + dependencies: + is-regexp "^1.0.0" + is-supported-regexp-flag "^1.0.0" + co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -1248,6 +1277,15 @@ core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" +cosmiconfig@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-3.1.0.tgz#640a94bf9847f321800403cd273af60665c73397" + dependencies: + is-directory "^0.3.1" + js-yaml "^3.9.0" + parse-json "^3.0.0" + require-from-string "^2.0.1" + create-error-class@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" @@ -1304,6 +1342,12 @@ debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: dependencies: ms "2.0.0" +debug@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1416,6 +1460,10 @@ electron-to-chromium@^1.3.18: version "1.3.18" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.18.tgz#3dcc99da3e6b665f6abbc71c28ad51a2cd731a9c" +electron-to-chromium@^1.3.24: + version "1.3.24" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.24.tgz#9b7b88bb05ceb9fa016a177833cc2dde388f21b6" + emoji-regex@^6.1.0: version "6.5.1" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.5.1.tgz#9baea929b155565c11ea41c6626eaa65cef992c2" @@ -1432,7 +1480,7 @@ errno@^0.1.4: dependencies: prr "~0.0.0" -error-ex@^1.2.0: +error-ex@^1.2.0, error-ex@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" dependencies: @@ -1688,6 +1736,12 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +execall@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/execall/-/execall-1.0.0.tgz#73d0904e395b3cab0658b08d09ec25307f29bb73" + dependencies: + clone-regexp "^1.0.0" + expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -1819,6 +1873,10 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" +flatten@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" + flow-bin@^0.53.1: version "0.53.1" resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.53.1.tgz#9b22b63a23c99763ae533ebbab07f88c88c97d84" @@ -1991,6 +2049,10 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" +globjoin@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/globjoin/-/globjoin-0.1.4.tgz#2f4494ac8919e3767c5cbb691e9f463324285d43" + got@^6.7.1: version "6.7.1" resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" @@ -2090,6 +2152,10 @@ html-encoding-sniffer@^1.0.1: dependencies: whatwg-encoding "^1.0.1" +html-tags@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b" + http-signature@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" @@ -2124,6 +2190,10 @@ indent-string@^2.1.0: dependencies: repeating "^2.0.0" +indexes-of@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607" + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -2202,6 +2272,10 @@ is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" +is-directory@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1" + is-dotfile@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" @@ -2300,6 +2374,10 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" +is-regexp@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" + is-resolvable@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" @@ -2314,6 +2392,10 @@ is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" +is-supported-regexp-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-supported-regexp-flag/-/is-supported-regexp-flag-1.0.0.tgz#8b520c85fae7a253382d4b02652e045576e13bb8" + is-symbol@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" @@ -2643,6 +2725,10 @@ jest@^21.1.0: dependencies: jest-cli "^21.1.0" +js-base64@^2.1.9: + version "2.3.2" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.3.2.tgz#a79a923666372b580f8e27f51845c6f7e8fbfbaf" + js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" @@ -2654,6 +2740,13 @@ js-yaml@^3.7.0, js-yaml@^3.9.1: argparse "^1.0.7" esprima "^4.0.0" +js-yaml@^3.9.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -2763,6 +2856,10 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" +known-css-properties@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.4.1.tgz#baaaf704e5f8a5f10e0e221212aae3ea738ea372" + latest-version@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" @@ -2824,6 +2921,12 @@ lodash@^4.0.0, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" +log-symbols@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.1.0.tgz#f35fa60e278832b538dc4dddcbb478a45d3e3be6" + dependencies: + chalk "^2.0.1" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -2868,13 +2971,17 @@ map-obj@^1.0.0, map-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" +mathml-tag-names@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.0.1.tgz#8d41268168bf86d1102b98109e28e531e7a34578" + mem@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" dependencies: mimic-fn "^1.0.0" -meow@^3.6.0: +meow@^3.6.0, meow@^3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" dependencies: @@ -3017,6 +3124,14 @@ normalize-path@^2.0.0, normalize-path@^2.0.1: dependencies: remove-trailing-separator "^1.0.1" +normalize-range@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942" + +normalize-selector@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/normalize-selector/-/normalize-selector-0.2.0.tgz#d0b145eb691189c63a78d201dc4fdb1293ef0c03" + npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -3032,6 +3147,10 @@ npmlog@^4.0.2: gauge "~2.7.3" set-blocking "~2.0.0" +num2fraction@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede" + number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" @@ -3166,6 +3285,12 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" +parse-json@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-3.0.0.tgz#fa6f47b18e23826ead32f263e744d0e1e847fb13" + dependencies: + error-ex "^1.3.1" + parse5@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/parse5/-/parse5-1.5.1.tgz#9b7f3b0de32be78dc2401b17573ccaf0f6f59d94" @@ -3246,6 +3371,70 @@ pluralize@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762" +postcss-less@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/postcss-less/-/postcss-less-1.1.1.tgz#4bd240db517ce3407583d927858184f50045f4ab" + dependencies: + postcss "^5.2.16" + +postcss-media-query-parser@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/postcss-media-query-parser/-/postcss-media-query-parser-0.2.3.tgz#27b39c6f4d94f81b1a73b8f76351c609e5cef244" + +postcss-reporter@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/postcss-reporter/-/postcss-reporter-5.0.0.tgz#a14177fd1342829d291653f2786efd67110332c3" + dependencies: + chalk "^2.0.1" + lodash "^4.17.4" + log-symbols "^2.0.0" + postcss "^6.0.8" + +postcss-resolve-nested-selector@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/postcss-resolve-nested-selector/-/postcss-resolve-nested-selector-0.1.1.tgz#29ccbc7c37dedfac304e9fff0bf1596b3f6a0e4e" + +postcss-safe-parser@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/postcss-safe-parser/-/postcss-safe-parser-3.0.1.tgz#b753eff6c7c0aea5e8375fbe4cde8bf9063ff142" + dependencies: + postcss "^6.0.6" + +postcss-scss@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/postcss-scss/-/postcss-scss-1.0.2.tgz#ff45cf3354b879ee89a4eb68680f46ac9bb14f94" + dependencies: + postcss "^6.0.3" + +postcss-selector-parser@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-2.2.3.tgz#f9437788606c3c9acee16ffe8d8b16297f27bb90" + dependencies: + flatten "^1.0.2" + indexes-of "^1.0.1" + uniq "^1.0.1" + +postcss-value-parser@^3.2.3, postcss-value-parser@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz#87f38f9f18f774a4ab4c8a232f5c5ce8872a9d15" + +postcss@^5.2.16: + version "5.2.18" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.18.tgz#badfa1497d46244f6390f58b319830d9107853c5" + dependencies: + chalk "^1.1.3" + js-base64 "^2.1.9" + source-map "^0.5.6" + supports-color "^3.2.3" + +postcss@^6.0.0, postcss@^6.0.13, postcss@^6.0.3, postcss@^6.0.6, postcss@^6.0.8: + version "6.0.13" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.13.tgz#b9ecab4ee00c89db3ec931145bd9590bbf3f125f" + dependencies: + chalk "^2.1.0" + source-map "^0.6.1" + supports-color "^4.4.0" + postcss@^6.0.10: version "6.0.10" resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.10.tgz#c311b89734483d87a91a56dc9e53f15f4e6e84e4" @@ -3499,6 +3688,10 @@ require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" +require-from-string@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.1.tgz#c545233e9d7da6616e9d59adfb39fc9f588676ff" + require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" @@ -3514,6 +3707,10 @@ resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" + resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" @@ -3651,6 +3848,10 @@ source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" +source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + source-map@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d" @@ -3671,6 +3872,10 @@ spdx-license-ids@^1.0.2: version "1.2.2" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" +specificity@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.3.2.tgz#99e6511eceef0f8d9b57924937aac2cb13d13c42" + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -3761,15 +3966,67 @@ strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" +style-search@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902" + +stylelint@^8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-8.2.0.tgz#6a15044553fb5c3143b16d62013a370314495b0d" + dependencies: + autoprefixer "^7.1.2" + balanced-match "^1.0.0" + chalk "^2.0.1" + cosmiconfig "^3.1.0" + debug "^3.0.0" + execall "^1.0.0" + file-entry-cache "^2.0.0" + get-stdin "^5.0.1" + globby "^6.1.0" + globjoin "^0.1.4" + html-tags "^2.0.0" + ignore "^3.3.3" + imurmurhash "^0.1.4" + known-css-properties "^0.4.0" + lodash "^4.17.4" + log-symbols "^2.0.0" + mathml-tag-names "^2.0.1" + meow "^3.7.0" + micromatch "^2.3.11" + normalize-selector "^0.2.0" + pify "^3.0.0" + postcss "^6.0.6" + postcss-less "^1.1.0" + postcss-media-query-parser "^0.2.3" + postcss-reporter "^5.0.0" + postcss-resolve-nested-selector "^0.1.1" + postcss-safe-parser "^3.0.1" + postcss-scss "^1.0.2" + postcss-selector-parser "^2.2.3" + postcss-value-parser "^3.3.0" + resolve-from "^4.0.0" + specificity "^0.3.1" + string-width "^2.1.0" + style-search "^0.1.0" + sugarss "^1.0.0" + svg-tags "^1.0.0" + table "^4.0.1" + stylis@^3.2.13: version "3.2.14" resolved "https://registry.yarnpkg.com/stylis/-/stylis-3.2.14.tgz#30700e0507b7a804c03d7e2c28d8ee865697fb50" +sugarss@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/sugarss/-/sugarss-1.0.0.tgz#65e51b3958432fb70d5451a68bb33e32d0cf1ef7" + dependencies: + postcss "^6.0.0" + supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^3.1.2: +supports-color@^3.1.2, supports-color@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" dependencies: @@ -3781,6 +4038,16 @@ supports-color@^4.0.0, supports-color@^4.2.1: dependencies: has-flag "^2.0.0" +supports-color@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e" + dependencies: + has-flag "^2.0.0" + +svg-tags@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764" + symbol-observable@1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d" @@ -3930,6 +4197,10 @@ uid-number@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" +uniq@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" + unique-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" From dec769bdc6b8d23ed2dbd6838a07fdc633a29087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 15:35:08 +0200 Subject: [PATCH 02/24] MVP of stylelint preprocessor --- babel.js | 12 +- src/babel/preval-extract/index.js | 18 -- src/css.js | 11 + src/index.stylelint.js | 25 --- src/tools/stylelint-preprocessor.js | 93 ++++++-- website/package.json | 3 +- website/yarn.lock | 327 +++++++++++++++++++++++++++- 7 files changed, 414 insertions(+), 75 deletions(-) delete mode 100644 src/index.stylelint.js diff --git a/babel.js b/babel.js index 85b7316f0..75e9a5da4 100644 --- a/babel.js +++ b/babel.js @@ -1,11 +1,17 @@ /* eslint-disable global-require */ module.exports = function linariaBabelPreset(context, opts = {}) { + const options = { + ...opts, + // Escape hatch for overwriting linaria preset's options. + ...JSON.parse(process.env.LINARIA_OVERWRITE_BABEL_PRESET || '{}'), + }; + return { plugins: [ - [require('./build/babel/hoist-css').default, opts], - [require('./build/babel/preval-extract').default, opts], - [require('./build/babel/rewire-imports').default, opts], + [require('./build/babel/hoist-css').default, options], + [require('./build/babel/preval-extract').default, options], + [require('./build/babel/rewire-imports').default, options], ], }; }; diff --git a/src/babel/preval-extract/index.js b/src/babel/preval-extract/index.js index 1e4b1d17c..f1615cf11 100644 --- a/src/babel/preval-extract/index.js +++ b/src/babel/preval-extract/index.js @@ -21,8 +21,6 @@ import prevalStyles from './prevalStyles'; import resolveSource from './resolveSource'; import extractStyles from './extractStyles'; -let interceptors = {}; - export const externalRequirementsVisitor = { Identifier(path: NodePath) { if (path.isReferenced() && getSelfBinding(path) && !isExcluded(path)) { @@ -102,25 +100,9 @@ export default (babel: BabelCore) => { types, }); - runInterceptor('pre-eval', { requirements }); - prevalStyles(babel, path, state, requirements); } }, }, }; }; - -export function addInterceptor(name: string, fn: Function) { - interceptors[name] = fn; -} - -function runInterceptor(name: string, ...args: any[]) { - if (interceptors[name]) { - interceptors[name](...args); - } -} - -// function clearInterceptors() { -// interceptors = {}; -// } diff --git a/src/css.js b/src/css.js index bab012093..b74f8d035 100644 --- a/src/css.js +++ b/src/css.js @@ -5,6 +5,12 @@ import slugify from './slugify'; import sheet from './sheet'; import { getFramesFromStack, enhanceFrames } from './babel/lib/errorUtils'; +const rawStyles = {}; + +export function getRawStyles() { + return rawStyles; +} + const named = (name?: string = 'css', filename: ?string = null) => ( template: string[], ...expressions: string[] @@ -69,6 +75,11 @@ const named = (name?: string = 'css', filename: ?string = null) => ( const slug = slugify(filename || styles); const classname = `${name}__${slug}`; + if (filename && process.env.LINARIA_COLLECT_RAW_STYLES) { + rawStyles[filename] = (rawStyles[filename] || []) + .concat({ template, expressions, classname }); + } + sheet.insert(`.${classname}`, styles); return classname; diff --git a/src/index.stylelint.js b/src/index.stylelint.js deleted file mode 100644 index fb31b0ac0..000000000 --- a/src/index.stylelint.js +++ /dev/null @@ -1,25 +0,0 @@ -/* @flow */ - -import dedent from 'dedent'; - -// Custom implementation of css.named for stylelint. -function cssNamed() { - return (template: string[], ...expressions: string[]) => { - const styles = dedent( - template, - ...expressions.map(expression => String(expression).replace('\n', ' ')) - ).trim(); - - process.emit('linaria-extract', { styles }); - - return ''; - }; -} - -export const css = cssNamed(); - -css.named = cssNamed; - -export { default as include } from './include'; -export { default as names } from './names'; -export { default as styles } from './styles'; diff --git a/src/tools/stylelint-preprocessor.js b/src/tools/stylelint-preprocessor.js index a2ded59ab..97bd05cb5 100644 --- a/src/tools/stylelint-preprocessor.js +++ b/src/tools/stylelint-preprocessor.js @@ -1,35 +1,82 @@ import * as babel from 'babel-core'; -import { addInterceptor } from '../babel/preval-extract'; +import { SourceMapConsumer } from 'source-map'; + +import { getCachedModule } from '../babel/lib/moduleSystem'; + +function toString(templates, expressions) { + return templates.reduce( + (acc, template, i) => + `${acc}${template}${i >= expressions.length ? '' : expressions[i]}`, + '' + ); +} + +export default function linariaStylelintPreprocessor(/* options */) { + process.env.LINARIA_OVERWRITE_BABEL_PRESET = JSON.stringify({ + extract: false, + }); + process.env.LINARIA_COLLECT_RAW_STYLES = true; + + const cache = {}; -export default function linariaStylelintPreprocessor(options) { return { code(input, filename) { - const extractedStyles = []; - process.on('linaria-extract', ({ styles }) => { - extractedStyles.push(styles); + const { code, map } = babel.transform(input, { + filename, + sourceMaps: true, }); - addInterceptor('pre-eval', ({ requirements }) => { - requirements.forEach(requirement => { - // eslint-disable-next-line no-param-reassign - requirement.code = requirement.code.replace( - /import {.*} from ["|'](linaria)["|']/, - (substring, ...args) => - substring.replace(args[0], 'linaria/build/index.stylelint.js') - ); + const rawStyles = getCachedModule( + require.resolve('../css.js') + ).exports.getRawStyles(); + + const css = rawStyles[ + filename + ].reduce((acc, { template, expressions, classname }) => { + const styles = toString( + template, + expressions.map(expression => String(expression).replace('\n', ' ')) + ); + return `${acc}\n.${classname} {${styles}}`; + }, ''); + + cache[filename] = { css, code, map }; + + return css; + }, + result(stylelintResult, filename) { + const { code, css, map } = cache[filename]; + const { warnings } = stylelintResult; + + warnings.forEach(warning => { + const relevantCss = css.split('\n').slice(0, warning.line); + + let classname; + let offset = 0; + for (let i = relevantCss.length - 1; i >= 0; i--) { + const match = relevantCss[i].match(/\.([a-zA-Z0-9]+__[a-z0-9]+) {/); + if (match) { + classname = match[1]; + offset = relevantCss.length - i - 1; + break; + } + } + + const startLineLocation = + code.split('\n').findIndex(line => line.includes(classname)) + 1; + // prettier-ignore + const startColumnLocation = code.split('\n')[startLineLocation - 1] + .indexOf(classname); + + const consumer = new SourceMapConsumer(map); + const originalPos = consumer.originalPositionFor({ + line: startLineLocation, + column: startColumnLocation, }); - }); - const { code, ast } = babel.transform(input, { - filename, - sourceMaps: true, + // eslint-disable-next-line no-param-reassign + warning.line = originalPos.line + offset; }); - - return extractedStyles.reduce( - (acc, style, i) => `${acc}\n.test${i} {${style}}`, - '' - ); }, - result(stylelintResult, filepath) {}, }; } diff --git a/website/package.json b/website/package.json index 5688bdd3f..021b97a79 100644 --- a/website/package.json +++ b/website/package.json @@ -24,7 +24,8 @@ "preact-compat": "^3.17.0", "prismjs": "^1.6.0", "react": "^16.0.0", - "react-dom": "^16.0.0" + "react-dom": "^16.0.0", + "stylelint": "^8.2.0" }, "devDependencies": { "babel-cli": "^6.26.0", diff --git a/website/yarn.lock b/website/yarn.lock index 0491b80ee..348c00cfc 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -27,7 +27,7 @@ acorn@^5.0.0: version "5.1.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.1.tgz#53fe161111f912ab999ee887a90a0bc52822fd75" -ajv-keywords@^2.0.0: +ajv-keywords@^2.0.0, ajv-keywords@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.0.tgz#a296e17f7bfae7c1ce4f7e0de53d29cb32162df0" @@ -47,6 +47,15 @@ ajv@^5.0.0, ajv@^5.1.5: json-schema-traverse "^0.3.0" json-stable-stringify "^1.0.1" +ajv@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.3.tgz#c06f598778c44c6b161abafe3466b81ad1814ed2" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + json-schema-traverse "^0.3.0" + json-stable-stringify "^1.0.1" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -154,6 +163,10 @@ array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + asap@~2.0.3: version "2.0.6" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" @@ -213,6 +226,17 @@ autoprefixer@^6.3.1: postcss "^5.2.16" postcss-value-parser "^3.2.3" +autoprefixer@^7.1.2: + version "7.1.5" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-7.1.5.tgz#d65d14b83c7cd1dd7bc801daa00557addf5a06b2" + dependencies: + browserslist "^2.5.0" + caniuse-lite "^1.0.30000744" + normalize-range "^0.1.2" + num2fraction "^1.2.2" + postcss "^6.0.13" + postcss-value-parser "^3.2.3" + aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" @@ -970,6 +994,13 @@ browserslist@^2.1.2: caniuse-lite "^1.0.30000718" electron-to-chromium "^1.3.18" +browserslist@^2.5.0: + version "2.5.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.5.1.tgz#68e4bc536bbcc6086d62843a2ffccea8396821c6" + dependencies: + caniuse-lite "^1.0.30000744" + electron-to-chromium "^1.3.24" + buffer-indexof@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-indexof/-/buffer-indexof-1.1.1.tgz#52fabcc6a606d1a00302802648ef68f639da268c" @@ -1042,6 +1073,10 @@ caniuse-lite@^1.0.30000718: version "1.0.30000718" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000718.tgz#0dd24290beb11310b2d80f6b70a823c2a65a6fad" +caniuse-lite@^1.0.30000744: + version "1.0.30000747" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000747.tgz#da86e78e12d0641abeeaee6ecd55d81bd9bd3b5d" + capture-stack-trace@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" @@ -1097,6 +1132,10 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" +circular-json@^0.3.1: + version "0.3.3" + resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" + clap@^1.0.9: version "1.2.0" resolved "https://registry.yarnpkg.com/clap/-/clap-1.2.0.tgz#59c90fe3e137104746ff19469a27a634ff68c857" @@ -1131,6 +1170,13 @@ cliui@^3.2.0: strip-ansi "^3.0.1" wrap-ansi "^2.0.0" +clone-regexp@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/clone-regexp/-/clone-regexp-1.0.0.tgz#eae0a2413f55c0942f818c229fefce845d7f3b1c" + dependencies: + is-regexp "^1.0.0" + is-supported-regexp-flag "^1.0.0" + clone@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.2.tgz#260b7a99ebb1edfe247538175f783243cb19d149" @@ -1294,6 +1340,15 @@ core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" +cosmiconfig@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-3.1.0.tgz#640a94bf9847f321800403cd273af60665c73397" + dependencies: + is-directory "^0.3.1" + js-yaml "^3.9.0" + parse-json "^3.0.0" + require-from-string "^2.0.1" + create-ecdh@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.0.tgz#888c723596cdf7612f6498233eebd7a35301737d" @@ -1473,6 +1528,12 @@ debug@2.6.9: dependencies: ms "2.0.0" +debug@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1508,6 +1569,18 @@ del-cli@^1.0.0: meow "^3.6.0" update-notifier "^2.1.0" +del@^2.0.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" + dependencies: + globby "^5.0.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + rimraf "^2.2.8" + del@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/del/-/del-3.0.0.tgz#53ecf699ffcbcb39637691ab13baf160819766e5" @@ -1616,6 +1689,10 @@ electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.18: version "1.3.18" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.18.tgz#3dcc99da3e6b665f6abbc71c28ad51a2cd731a9c" +electron-to-chromium@^1.3.24: + version "1.3.26" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.26.tgz#996427294861a74d9c7c82b9260ea301e8c02d66" + elliptic@^6.0.0: version "6.4.0" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.0.tgz#cac9af8762c85836187003c8dfe193e5e2eae5df" @@ -1657,7 +1734,7 @@ errno@^0.1.3: dependencies: prr "~0.0.0" -error-ex@^1.2.0: +error-ex@^1.2.0, error-ex@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" dependencies: @@ -1763,6 +1840,10 @@ esprima@^2.6.0: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" +esprima@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" + esrecurse@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.0.tgz#fa9568d98d3823f9a41d91e902dcab9ea6e5b163" @@ -1822,6 +1903,12 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +execall@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/execall/-/execall-1.0.0.tgz#73d0904e395b3cab0658b08d09ec25307f29bb73" + dependencies: + clone-regexp "^1.0.0" + expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -1934,6 +2021,13 @@ fbjs@^0.8.9: setimmediate "^1.0.5" ua-parser-js "^0.7.9" +file-entry-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" + dependencies: + flat-cache "^1.2.1" + object-assign "^4.0.1" + filename-regex@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" @@ -1981,6 +2075,15 @@ find-up@^2.0.0, find-up@^2.1.0: dependencies: locate-path "^2.0.0" +flat-cache@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" + dependencies: + circular-json "^0.3.1" + del "^2.0.2" + graceful-fs "^4.1.2" + write "^0.2.1" + flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" @@ -2080,6 +2183,10 @@ get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" +get-stdin@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398" + get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -2118,6 +2225,17 @@ globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" +globby@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" + dependencies: + array-union "^1.0.1" + arrify "^1.0.0" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" @@ -2128,6 +2246,10 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" +globjoin@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/globjoin/-/globjoin-0.1.4.tgz#2f4494ac8919e3767c5cbb691e9f463324285d43" + good-listener@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.2.tgz#d53b30cdf9313dffb7dc9a0d477096aa6d145c50" @@ -2262,6 +2384,10 @@ html-entities@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.2.1.tgz#0df29351f0721163515dfb9e5543e5f6eed5162f" +html-tags@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b" + http-deceiver@^1.2.7: version "1.2.7" resolved "https://registry.yarnpkg.com/http-deceiver/-/http-deceiver-1.2.7.tgz#fa7168944ab9a519d337cb0bec7284dc3e723d87" @@ -2321,6 +2447,10 @@ ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" +ignore@^3.3.3: + version "3.3.5" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.5.tgz#c4e715455f6073a8d7e5dae72d2fc9d71663dba6" + immutability-helper@^2.1.2: version "2.3.1" resolved "https://registry.yarnpkg.com/immutability-helper/-/immutability-helper-2.3.1.tgz#8ccfce92157208c120b2afad7ed05c11114c086e" @@ -2428,6 +2558,10 @@ is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" +is-directory@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1" + is-dotfile@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" @@ -2536,6 +2670,10 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" +is-regexp@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" + is-retry-allowed@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" @@ -2544,6 +2682,10 @@ is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" +is-supported-regexp-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-supported-regexp-flag/-/is-supported-regexp-flag-1.0.0.tgz#8b520c85fae7a253382d4b02652e045576e13bb8" + is-svg@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-svg/-/is-svg-2.1.0.tgz#cf61090da0d9efbcab8722deba6f032208dbb0e9" @@ -2595,6 +2737,13 @@ js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" +js-yaml@^3.9.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + js-yaml@~3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80" @@ -2675,6 +2824,10 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" +known-css-properties@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.4.1.tgz#baaaf704e5f8a5f10e0e221212aae3ea738ea372" + latest-version@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" @@ -2749,6 +2902,12 @@ lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" +log-symbols@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.1.0.tgz#f35fa60e278832b538dc4dddcbb478a45d3e3be6" + dependencies: + chalk "^2.0.1" + loglevel@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.4.1.tgz#95b383f91a3c2756fd4ab093667e4309161f2bcd" @@ -2799,6 +2958,10 @@ math-expression-evaluator@^1.2.14: version "1.2.17" resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz#de819fdbcd84dccd8fae59c6aeb79615b9d266ac" +mathml-tag-names@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.0.1.tgz#8d41268168bf86d1102b98109e28e531e7a34578" + md5.js@^1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.4.tgz#e9bdbde94a20a5ac18b04340fc5764d5b09d901d" @@ -2823,7 +2986,7 @@ memory-fs@^0.4.0, memory-fs@~0.4.1: errno "^0.1.3" readable-stream "^2.0.1" -meow@^3.3.0, meow@^3.6.0: +meow@^3.3.0, meow@^3.6.0, meow@^3.7.0: version "3.7.0" resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" dependencies: @@ -3023,6 +3186,10 @@ normalize-range@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942" +normalize-selector@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/normalize-selector/-/normalize-selector-0.2.0.tgz#d0b145eb691189c63a78d201dc4fdb1293ef0c03" + normalize-url@^1.4.0: version "1.9.1" resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-1.9.1.tgz#2cc0d66b31ea23036458436e3620d85954c66c3c" @@ -3208,6 +3375,12 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" +parse-json@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-3.0.0.tgz#fa6f47b18e23826ead32f263e744d0e1e847fb13" + dependencies: + error-ex "^1.3.1" + parseurl@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.1.tgz#c8ab8c9223ba34888aa64a297b28853bec18da56" @@ -3363,6 +3536,16 @@ postcss-filter-plugins@^2.0.0: postcss "^5.0.4" uniqid "^4.0.0" +postcss-less@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/postcss-less/-/postcss-less-1.1.1.tgz#4bd240db517ce3407583d927858184f50045f4ab" + dependencies: + postcss "^5.2.16" + +postcss-media-query-parser@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/postcss-media-query-parser/-/postcss-media-query-parser-0.2.3.tgz#27b39c6f4d94f81b1a73b8f76351c609e5cef244" + postcss-merge-idents@^2.1.5: version "2.1.7" resolved "https://registry.yarnpkg.com/postcss-merge-idents/-/postcss-merge-idents-2.1.7.tgz#4c5530313c08e1d5b3bbf3d2bbc747e278eea270" @@ -3494,7 +3677,32 @@ postcss-reduce-transforms@^1.0.3: postcss "^5.0.8" postcss-value-parser "^3.0.1" -postcss-selector-parser@^2.0.0, postcss-selector-parser@^2.2.2: +postcss-reporter@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/postcss-reporter/-/postcss-reporter-5.0.0.tgz#a14177fd1342829d291653f2786efd67110332c3" + dependencies: + chalk "^2.0.1" + lodash "^4.17.4" + log-symbols "^2.0.0" + postcss "^6.0.8" + +postcss-resolve-nested-selector@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/postcss-resolve-nested-selector/-/postcss-resolve-nested-selector-0.1.1.tgz#29ccbc7c37dedfac304e9fff0bf1596b3f6a0e4e" + +postcss-safe-parser@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/postcss-safe-parser/-/postcss-safe-parser-3.0.1.tgz#b753eff6c7c0aea5e8375fbe4cde8bf9063ff142" + dependencies: + postcss "^6.0.6" + +postcss-scss@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/postcss-scss/-/postcss-scss-1.0.2.tgz#ff45cf3354b879ee89a4eb68680f46ac9bb14f94" + dependencies: + postcss "^6.0.3" + +postcss-selector-parser@^2.0.0, postcss-selector-parser@^2.2.2, postcss-selector-parser@^2.2.3: version "2.2.3" resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-2.2.3.tgz#f9437788606c3c9acee16ffe8d8b16297f27bb90" dependencies: @@ -3540,6 +3748,14 @@ postcss@^5.0.10, postcss@^5.0.11, postcss@^5.0.12, postcss@^5.0.13, postcss@^5.0 source-map "^0.5.6" supports-color "^3.2.3" +postcss@^6.0.0, postcss@^6.0.13, postcss@^6.0.3, postcss@^6.0.6, postcss@^6.0.8: + version "6.0.13" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.13.tgz#b9ecab4ee00c89db3ec931145bd9590bbf3f125f" + dependencies: + chalk "^2.1.0" + source-map "^0.6.1" + supports-color "^4.4.0" + postcss@^6.0.1: version "6.0.10" resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.10.tgz#c311b89734483d87a91a56dc9e53f15f4e6e84e4" @@ -3922,6 +4138,10 @@ require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" +require-from-string@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.1.tgz#c545233e9d7da6616e9d59adfb39fc9f588676ff" + require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" @@ -3930,6 +4150,10 @@ requires-port@1.0.x, requires-port@1.x.x: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" + right-align@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" @@ -4066,6 +4290,12 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" +slice-ansi@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" + dependencies: + is-fullwidth-code-point "^2.0.0" + sntp@1.x.x: version "1.0.9" resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" @@ -4110,6 +4340,10 @@ source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1, sour version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" +source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + spdx-correct@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" @@ -4147,6 +4381,10 @@ spdy@^3.4.1: select-hose "^2.0.0" spdy-transport "^2.0.18" +specificity@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.3.2.tgz#99e6511eceef0f8d9b57924937aac2cb13d13c42" + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -4202,7 +4440,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0: +string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" dependencies: @@ -4266,6 +4504,58 @@ style-loader@^0.18.2: loader-utils "^1.0.2" schema-utils "^0.3.0" +style-search@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902" + +stylelint@^8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-8.2.0.tgz#6a15044553fb5c3143b16d62013a370314495b0d" + dependencies: + autoprefixer "^7.1.2" + balanced-match "^1.0.0" + chalk "^2.0.1" + cosmiconfig "^3.1.0" + debug "^3.0.0" + execall "^1.0.0" + file-entry-cache "^2.0.0" + get-stdin "^5.0.1" + globby "^6.1.0" + globjoin "^0.1.4" + html-tags "^2.0.0" + ignore "^3.3.3" + imurmurhash "^0.1.4" + known-css-properties "^0.4.0" + lodash "^4.17.4" + log-symbols "^2.0.0" + mathml-tag-names "^2.0.1" + meow "^3.7.0" + micromatch "^2.3.11" + normalize-selector "^0.2.0" + pify "^3.0.0" + postcss "^6.0.6" + postcss-less "^1.1.0" + postcss-media-query-parser "^0.2.3" + postcss-reporter "^5.0.0" + postcss-resolve-nested-selector "^0.1.1" + postcss-safe-parser "^3.0.1" + postcss-scss "^1.0.2" + postcss-selector-parser "^2.2.3" + postcss-value-parser "^3.3.0" + resolve-from "^4.0.0" + specificity "^0.3.1" + string-width "^2.1.0" + style-search "^0.1.0" + sugarss "^1.0.0" + svg-tags "^1.0.0" + table "^4.0.1" + +sugarss@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/sugarss/-/sugarss-1.0.0.tgz#65e51b3958432fb70d5451a68bb33e32d0cf1ef7" + dependencies: + postcss "^6.0.0" + supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" @@ -4282,6 +4572,16 @@ supports-color@^4.0.0, supports-color@^4.2.1: dependencies: has-flag "^2.0.0" +supports-color@^4.4.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" + dependencies: + has-flag "^2.0.0" + +svg-tags@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764" + svgo@^0.7.0: version "0.7.2" resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5" @@ -4294,6 +4594,17 @@ svgo@^0.7.0: sax "~1.2.1" whet.extend "~0.9.9" +table@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" + dependencies: + ajv "^5.2.3" + ajv-keywords "^2.1.0" + chalk "^2.1.0" + lodash "^4.17.4" + slice-ansi "1.0.0" + string-width "^2.1.1" + tapable@^0.2.7: version "0.2.8" resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.8.tgz#99372a5c999bf2df160afc0d74bed4f47948cd22" @@ -4709,6 +5020,12 @@ write-file-atomic@^2.0.0: imurmurhash "^0.1.4" signal-exit "^3.0.2" +write@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" + dependencies: + mkdirp "^0.5.1" + xdg-basedir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" From 51a9e663f64b5607ed8961f662ce90e5e481e450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 15:57:45 +0200 Subject: [PATCH 03/24] lint styles on circle ci --- .circleci/config.yml | 2 +- src/tools/stylelint-preprocessor.js | 23 +++++++++++++++++++---- website/{src/components => }/.stylelintrc | 2 +- website/package.json | 3 ++- 4 files changed, 23 insertions(+), 7 deletions(-) rename website/{src/components => }/.stylelintrc (64%) diff --git a/.circleci/config.yml b/.circleci/config.yml index c3b284a5f..14cc7cad0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,8 +39,8 @@ jobs: - run: yarn run flow - run: yarn test -- --coverage - run: yarn run test:integration:ci + - run: cd example && yarn run lint-css && cd .. - run: cat ./coverage/lcov.info | ./node_modules/.bin/codecov - store_artifacts: path: coverage - # test-e2e: diff --git a/src/tools/stylelint-preprocessor.js b/src/tools/stylelint-preprocessor.js index 97bd05cb5..9197d4e0e 100644 --- a/src/tools/stylelint-preprocessor.js +++ b/src/tools/stylelint-preprocessor.js @@ -1,9 +1,15 @@ +/* @flow */ + import * as babel from 'babel-core'; import { SourceMapConsumer } from 'source-map'; import { getCachedModule } from '../babel/lib/moduleSystem'; -function toString(templates, expressions) { +type LintResults = { + warnings: { line: number, column: number }[], +}; + +function toString(templates: string[], expressions: string[]) { return templates.reduce( (acc, template, i) => `${acc}${template}${i >= expressions.length ? '' : expressions[i]}`, @@ -15,12 +21,13 @@ export default function linariaStylelintPreprocessor(/* options */) { process.env.LINARIA_OVERWRITE_BABEL_PRESET = JSON.stringify({ extract: false, }); + // $FlowFixMe process.env.LINARIA_COLLECT_RAW_STYLES = true; const cache = {}; return { - code(input, filename) { + code(input: string, filename: string) { const { code, map } = babel.transform(input, { filename, sourceMaps: true, @@ -30,6 +37,10 @@ export default function linariaStylelintPreprocessor(/* options */) { require.resolve('../css.js') ).exports.getRawStyles(); + if (!Object.keys(rawStyles).length || !rawStyles[filename]) { + return ''; + } + const css = rawStyles[ filename ].reduce((acc, { template, expressions, classname }) => { @@ -44,9 +55,13 @@ export default function linariaStylelintPreprocessor(/* options */) { return css; }, - result(stylelintResult, filename) { + result(lintResults: LintResults, filename: string) { + if (!cache[filename]) { + return; + } + const { code, css, map } = cache[filename]; - const { warnings } = stylelintResult; + const { warnings } = lintResults; warnings.forEach(warning => { const relevantCss = css.split('\n').slice(0, warning.line); diff --git a/website/src/components/.stylelintrc b/website/.stylelintrc similarity index 64% rename from website/src/components/.stylelintrc rename to website/.stylelintrc index b5f3734f0..90bebcf05 100644 --- a/website/src/components/.stylelintrc +++ b/website/.stylelintrc @@ -1,5 +1,5 @@ { - "processors": ["../../../stylelint-preprocessor.js"], + "processors": ["linaria/stylelint-preprocessor"], "syntax": "scss", "rules": { "block-no-empty": true, diff --git a/website/package.json b/website/package.json index 021b97a79..288e81bf1 100644 --- a/website/package.json +++ b/website/package.json @@ -12,7 +12,8 @@ "prebuild": "yarn run clean", "server": "node static/server/server.js", "start-server-render": "yarn build:all && yarn server", - "start": "webpack-dev-server" + "start": "webpack-dev-server", + "lint-css": "stylelint src/**/*.js" }, "dependencies": { "compression": "^1.7.1", From 3fb595d510d77e5f7c83104dac6bc5ececb42902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 16:05:39 +0200 Subject: [PATCH 04/24] add test and fix babel preset error --- babel.js | 8 ++++---- src/__tests__/css.spec.js | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/babel.js b/babel.js index 75e9a5da4..3875a3dd1 100644 --- a/babel.js +++ b/babel.js @@ -1,11 +1,11 @@ /* eslint-disable global-require */ module.exports = function linariaBabelPreset(context, opts = {}) { - const options = { - ...opts, + const options = Object.assign( + opts, // Escape hatch for overwriting linaria preset's options. - ...JSON.parse(process.env.LINARIA_OVERWRITE_BABEL_PRESET || '{}'), - }; + JSON.parse(process.env.LINARIA_OVERWRITE_BABEL_PRESET || '{}') + ); return { plugins: [ diff --git a/src/__tests__/css.spec.js b/src/__tests__/css.spec.js index 2d6db359c..4747b71c4 100644 --- a/src/__tests__/css.spec.js +++ b/src/__tests__/css.spec.js @@ -1,6 +1,6 @@ /* @flow */ -import css from '../css'; +import css, { getRawStyles } from '../css'; jest.mock('../babel/lib/errorUtils', () => ({ getFramesFromStack: (...args) => @@ -38,4 +38,22 @@ describe('css module', () => { css.named('test')`color: ${null}`; }).toThrowError('Expression cannot be undefined or null'); }); + + it('should collect raw styles', () => { + // $FlowFixMe + process.env.LINARIA_COLLECT_RAW_STYLES = true; + + const header = css.named('header', 'test.js')` + color: blue; + `; + process.env.LINARIA_COLLECT_RAW_STYLES = undefined; + + expect(getRawStyles()).toEqual({ + 'test.js': { + template: ['\n color: blue;\n'], + expressions: [], + classname: header, + }, + }); + }); }); From 87418a244d9910e0fb24ba6a8bd834b6eb043e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 16:09:29 +0200 Subject: [PATCH 05/24] fix flow errors --- .flowconfig | 1 + package.json | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.flowconfig b/.flowconfig index ba292921f..5bf21922b 100644 --- a/.flowconfig +++ b/.flowconfig @@ -1,6 +1,7 @@ [ignore] /build/.* /website/node_modules/preact/.* +/website/node_modules/stylelint/.* [include] flow-typed/ diff --git a/package.json b/package.json index 29e69dd67..34a1c11bb 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,7 @@ "glob": "^7.1.2", "jest": "^21.1.0", "prettier": "^1.6.1", - "strip-ansi": "^4.0.0", - "stylelint": "^8.2.0" + "strip-ansi": "^4.0.0" }, "jest": { "testRegex": "/__(integration-)?tests__/.*\\.(test|spec)\\.js$", From 995cbc7c07ae3c81ea939318539149f3038927a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 16:12:22 +0200 Subject: [PATCH 06/24] fix test error --- src/__tests__/css.spec.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/__tests__/css.spec.js b/src/__tests__/css.spec.js index 4747b71c4..3b79add34 100644 --- a/src/__tests__/css.spec.js +++ b/src/__tests__/css.spec.js @@ -49,11 +49,13 @@ describe('css module', () => { process.env.LINARIA_COLLECT_RAW_STYLES = undefined; expect(getRawStyles()).toEqual({ - 'test.js': { - template: ['\n color: blue;\n'], - expressions: [], - classname: header, - }, + 'test.js': [ + { + template: ['\n color: blue;\n'], + expressions: [], + classname: header, + }, + ], }); }); }); From 945166c009d1ae7cfefefcf45222b826629977f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 16:14:55 +0200 Subject: [PATCH 07/24] fix test --- src/__tests__/css.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/css.spec.js b/src/__tests__/css.spec.js index 3b79add34..6d9ae8b80 100644 --- a/src/__tests__/css.spec.js +++ b/src/__tests__/css.spec.js @@ -51,7 +51,7 @@ describe('css module', () => { expect(getRawStyles()).toEqual({ 'test.js': [ { - template: ['\n color: blue;\n'], + template: ['\n color: blue;\n '], expressions: [], classname: header, }, From b04b4b71c3604038011784424a0590b8170e45ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 16:17:09 +0200 Subject: [PATCH 08/24] update yarn lock file --- yarn.lock | 277 +----------------------------------------------------- 1 file changed, 3 insertions(+), 274 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7e60ed2b3..f7a710640 100644 --- a/yarn.lock +++ b/yarn.lock @@ -223,17 +223,6 @@ asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" -autoprefixer@^7.1.2: - version "7.1.5" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-7.1.5.tgz#d65d14b83c7cd1dd7bc801daa00557addf5a06b2" - dependencies: - browserslist "^2.5.0" - caniuse-lite "^1.0.30000744" - normalize-range "^0.1.2" - num2fraction "^1.2.2" - postcss "^6.0.13" - postcss-value-parser "^3.2.3" - aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" @@ -1029,13 +1018,6 @@ browserslist@^2.1.2: caniuse-lite "^1.0.30000718" electron-to-chromium "^1.3.18" -browserslist@^2.5.0: - version "2.5.1" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.5.1.tgz#68e4bc536bbcc6086d62843a2ffccea8396821c6" - dependencies: - caniuse-lite "^1.0.30000744" - electron-to-chromium "^1.3.24" - bser@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" @@ -1083,10 +1065,6 @@ caniuse-lite@^1.0.30000718: version "1.0.30000721" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000721.tgz#931a21a7bd85016300328d21f126d84b73437d35" -caniuse-lite@^1.0.30000744: - version "1.0.30000745" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000745.tgz#20d6fede1157a4935133502946fc7e0e6b880da5" - capture-stack-trace@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" @@ -1179,13 +1157,6 @@ cliui@^3.2.0: strip-ansi "^3.0.1" wrap-ansi "^2.0.0" -clone-regexp@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/clone-regexp/-/clone-regexp-1.0.0.tgz#eae0a2413f55c0942f818c229fefce845d7f3b1c" - dependencies: - is-regexp "^1.0.0" - is-supported-regexp-flag "^1.0.0" - co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -1277,15 +1248,6 @@ core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" -cosmiconfig@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-3.1.0.tgz#640a94bf9847f321800403cd273af60665c73397" - dependencies: - is-directory "^0.3.1" - js-yaml "^3.9.0" - parse-json "^3.0.0" - require-from-string "^2.0.1" - create-error-class@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" @@ -1342,12 +1304,6 @@ debug@^2.2.0, debug@^2.6.3, debug@^2.6.8: dependencies: ms "2.0.0" -debug@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" - dependencies: - ms "2.0.0" - decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1460,10 +1416,6 @@ electron-to-chromium@^1.3.18: version "1.3.18" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.18.tgz#3dcc99da3e6b665f6abbc71c28ad51a2cd731a9c" -electron-to-chromium@^1.3.24: - version "1.3.24" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.24.tgz#9b7b88bb05ceb9fa016a177833cc2dde388f21b6" - emoji-regex@^6.1.0: version "6.5.1" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.5.1.tgz#9baea929b155565c11ea41c6626eaa65cef992c2" @@ -1480,7 +1432,7 @@ errno@^0.1.4: dependencies: prr "~0.0.0" -error-ex@^1.2.0, error-ex@^1.3.1: +error-ex@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" dependencies: @@ -1736,12 +1688,6 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -execall@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/execall/-/execall-1.0.0.tgz#73d0904e395b3cab0658b08d09ec25307f29bb73" - dependencies: - clone-regexp "^1.0.0" - expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" @@ -1873,10 +1819,6 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" -flatten@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" - flow-bin@^0.53.1: version "0.53.1" resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.53.1.tgz#9b22b63a23c99763ae533ebbab07f88c88c97d84" @@ -2049,10 +1991,6 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" -globjoin@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/globjoin/-/globjoin-0.1.4.tgz#2f4494ac8919e3767c5cbb691e9f463324285d43" - got@^6.7.1: version "6.7.1" resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" @@ -2152,10 +2090,6 @@ html-encoding-sniffer@^1.0.1: dependencies: whatwg-encoding "^1.0.1" -html-tags@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b" - http-signature@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" @@ -2190,10 +2124,6 @@ indent-string@^2.1.0: dependencies: repeating "^2.0.0" -indexes-of@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/indexes-of/-/indexes-of-1.0.1.tgz#f30f716c8e2bd346c7b67d3df3915566a7c05607" - inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -2272,10 +2202,6 @@ is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" -is-directory@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1" - is-dotfile@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" @@ -2374,10 +2300,6 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" -is-regexp@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" - is-resolvable@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" @@ -2392,10 +2314,6 @@ is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" -is-supported-regexp-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-supported-regexp-flag/-/is-supported-regexp-flag-1.0.0.tgz#8b520c85fae7a253382d4b02652e045576e13bb8" - is-symbol@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" @@ -2725,10 +2643,6 @@ jest@^21.1.0: dependencies: jest-cli "^21.1.0" -js-base64@^2.1.9: - version "2.3.2" - resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.3.2.tgz#a79a923666372b580f8e27f51845c6f7e8fbfbaf" - js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" @@ -2740,13 +2654,6 @@ js-yaml@^3.7.0, js-yaml@^3.9.1: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@^3.9.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -2856,10 +2763,6 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" -known-css-properties@^0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.4.1.tgz#baaaf704e5f8a5f10e0e221212aae3ea738ea372" - latest-version@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" @@ -2921,12 +2824,6 @@ lodash@^4.0.0, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" -log-symbols@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.1.0.tgz#f35fa60e278832b538dc4dddcbb478a45d3e3be6" - dependencies: - chalk "^2.0.1" - longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -2971,17 +2868,13 @@ map-obj@^1.0.0, map-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" -mathml-tag-names@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.0.1.tgz#8d41268168bf86d1102b98109e28e531e7a34578" - mem@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" dependencies: mimic-fn "^1.0.0" -meow@^3.6.0, meow@^3.7.0: +meow@^3.6.0: version "3.7.0" resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" dependencies: @@ -3124,14 +3017,6 @@ normalize-path@^2.0.0, normalize-path@^2.0.1: dependencies: remove-trailing-separator "^1.0.1" -normalize-range@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942" - -normalize-selector@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/normalize-selector/-/normalize-selector-0.2.0.tgz#d0b145eb691189c63a78d201dc4fdb1293ef0c03" - npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -3147,10 +3032,6 @@ npmlog@^4.0.2: gauge "~2.7.3" set-blocking "~2.0.0" -num2fraction@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede" - number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" @@ -3285,12 +3166,6 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" -parse-json@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-3.0.0.tgz#fa6f47b18e23826ead32f263e744d0e1e847fb13" - dependencies: - error-ex "^1.3.1" - parse5@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/parse5/-/parse5-1.5.1.tgz#9b7f3b0de32be78dc2401b17573ccaf0f6f59d94" @@ -3371,70 +3246,6 @@ pluralize@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762" -postcss-less@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/postcss-less/-/postcss-less-1.1.1.tgz#4bd240db517ce3407583d927858184f50045f4ab" - dependencies: - postcss "^5.2.16" - -postcss-media-query-parser@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/postcss-media-query-parser/-/postcss-media-query-parser-0.2.3.tgz#27b39c6f4d94f81b1a73b8f76351c609e5cef244" - -postcss-reporter@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/postcss-reporter/-/postcss-reporter-5.0.0.tgz#a14177fd1342829d291653f2786efd67110332c3" - dependencies: - chalk "^2.0.1" - lodash "^4.17.4" - log-symbols "^2.0.0" - postcss "^6.0.8" - -postcss-resolve-nested-selector@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/postcss-resolve-nested-selector/-/postcss-resolve-nested-selector-0.1.1.tgz#29ccbc7c37dedfac304e9fff0bf1596b3f6a0e4e" - -postcss-safe-parser@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/postcss-safe-parser/-/postcss-safe-parser-3.0.1.tgz#b753eff6c7c0aea5e8375fbe4cde8bf9063ff142" - dependencies: - postcss "^6.0.6" - -postcss-scss@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/postcss-scss/-/postcss-scss-1.0.2.tgz#ff45cf3354b879ee89a4eb68680f46ac9bb14f94" - dependencies: - postcss "^6.0.3" - -postcss-selector-parser@^2.2.3: - version "2.2.3" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-2.2.3.tgz#f9437788606c3c9acee16ffe8d8b16297f27bb90" - dependencies: - flatten "^1.0.2" - indexes-of "^1.0.1" - uniq "^1.0.1" - -postcss-value-parser@^3.2.3, postcss-value-parser@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz#87f38f9f18f774a4ab4c8a232f5c5ce8872a9d15" - -postcss@^5.2.16: - version "5.2.18" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-5.2.18.tgz#badfa1497d46244f6390f58b319830d9107853c5" - dependencies: - chalk "^1.1.3" - js-base64 "^2.1.9" - source-map "^0.5.6" - supports-color "^3.2.3" - -postcss@^6.0.0, postcss@^6.0.13, postcss@^6.0.3, postcss@^6.0.6, postcss@^6.0.8: - version "6.0.13" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.13.tgz#b9ecab4ee00c89db3ec931145bd9590bbf3f125f" - dependencies: - chalk "^2.1.0" - source-map "^0.6.1" - supports-color "^4.4.0" - postcss@^6.0.10: version "6.0.10" resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.10.tgz#c311b89734483d87a91a56dc9e53f15f4e6e84e4" @@ -3688,10 +3499,6 @@ require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" -require-from-string@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.1.tgz#c545233e9d7da6616e9d59adfb39fc9f588676ff" - require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" @@ -3707,10 +3514,6 @@ resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" -resolve-from@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" - resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" @@ -3848,10 +3651,6 @@ source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" -source-map@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - source-map@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d" @@ -3872,10 +3671,6 @@ spdx-license-ids@^1.0.2: version "1.2.2" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" -specificity@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.3.2.tgz#99e6511eceef0f8d9b57924937aac2cb13d13c42" - sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -3966,67 +3761,15 @@ strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" -style-search@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902" - -stylelint@^8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-8.2.0.tgz#6a15044553fb5c3143b16d62013a370314495b0d" - dependencies: - autoprefixer "^7.1.2" - balanced-match "^1.0.0" - chalk "^2.0.1" - cosmiconfig "^3.1.0" - debug "^3.0.0" - execall "^1.0.0" - file-entry-cache "^2.0.0" - get-stdin "^5.0.1" - globby "^6.1.0" - globjoin "^0.1.4" - html-tags "^2.0.0" - ignore "^3.3.3" - imurmurhash "^0.1.4" - known-css-properties "^0.4.0" - lodash "^4.17.4" - log-symbols "^2.0.0" - mathml-tag-names "^2.0.1" - meow "^3.7.0" - micromatch "^2.3.11" - normalize-selector "^0.2.0" - pify "^3.0.0" - postcss "^6.0.6" - postcss-less "^1.1.0" - postcss-media-query-parser "^0.2.3" - postcss-reporter "^5.0.0" - postcss-resolve-nested-selector "^0.1.1" - postcss-safe-parser "^3.0.1" - postcss-scss "^1.0.2" - postcss-selector-parser "^2.2.3" - postcss-value-parser "^3.3.0" - resolve-from "^4.0.0" - specificity "^0.3.1" - string-width "^2.1.0" - style-search "^0.1.0" - sugarss "^1.0.0" - svg-tags "^1.0.0" - table "^4.0.1" - stylis@^3.2.13: version "3.2.14" resolved "https://registry.yarnpkg.com/stylis/-/stylis-3.2.14.tgz#30700e0507b7a804c03d7e2c28d8ee865697fb50" -sugarss@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/sugarss/-/sugarss-1.0.0.tgz#65e51b3958432fb70d5451a68bb33e32d0cf1ef7" - dependencies: - postcss "^6.0.0" - supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^3.1.2, supports-color@^3.2.3: +supports-color@^3.1.2: version "3.2.3" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" dependencies: @@ -4038,16 +3781,6 @@ supports-color@^4.0.0, supports-color@^4.2.1: dependencies: has-flag "^2.0.0" -supports-color@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e" - dependencies: - has-flag "^2.0.0" - -svg-tags@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764" - symbol-observable@1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d" @@ -4197,10 +3930,6 @@ uid-number@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" -uniq@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" - unique-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" From 35f4c0da518e532484900ae31e6fe5e55addd7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 16:17:48 +0200 Subject: [PATCH 09/24] fix circle ci config --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 14cc7cad0..af04b1cbb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,7 +39,7 @@ jobs: - run: yarn run flow - run: yarn test -- --coverage - run: yarn run test:integration:ci - - run: cd example && yarn run lint-css && cd .. + - run: cd website && yarn run lint-css && cd .. - run: cat ./coverage/lcov.info | ./node_modules/.bin/codecov - store_artifacts: path: coverage From 327ab71cf00b8db080f42da0cf3051a23bf14ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Wed, 18 Oct 2017 16:46:49 +0200 Subject: [PATCH 10/24] add linaria stylelint config --- package.json | 3 ++- stylelint-config.js | 12 ++++++++++++ website/.stylelintrc | 7 +++---- website/package.json | 3 ++- website/yarn.lock | 4 ++++ 5 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 stylelint-config.js diff --git a/package.json b/package.json index 34a1c11bb..fae55792a 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "/server.js" ], "peerDependencies": { - "stylelint": "8.x" + "stylelint": "8.x", + "stylelint-config-recommended": "1.x" }, "dependencies": { "babel-code-frame": "^6.26.0", diff --git a/stylelint-config.js b/stylelint-config.js new file mode 100644 index 000000000..b60392aec --- /dev/null +++ b/stylelint-config.js @@ -0,0 +1,12 @@ +module.exports = { + extends: 'stylelint-config-recommended', + rules: { + 'at-rule-name-case': 'lower', + 'unit-case': 'lower', + 'at-rule-semicolon-newline-after': 'always', + 'max-empty-lines': 1, + 'no-empty-source': null, + 'length-zero-no-unit': true, + 'no-extra-semicolons': null, + }, +}; diff --git a/website/.stylelintrc b/website/.stylelintrc index 90bebcf05..11b26565c 100644 --- a/website/.stylelintrc +++ b/website/.stylelintrc @@ -1,8 +1,7 @@ { "processors": ["linaria/stylelint-preprocessor"], "syntax": "scss", - "rules": { - "block-no-empty": true, - "property-no-unknown": true - } + "extends": [ + "linaria/stylelint-config" + ] } diff --git a/website/package.json b/website/package.json index 288e81bf1..4e5d00a25 100644 --- a/website/package.json +++ b/website/package.json @@ -26,7 +26,8 @@ "prismjs": "^1.6.0", "react": "^16.0.0", "react-dom": "^16.0.0", - "stylelint": "^8.2.0" + "stylelint": "^8.2.0", + "stylelint-config-recommended": "1.0.0" }, "devDependencies": { "babel-cli": "^6.26.0", diff --git a/website/yarn.lock b/website/yarn.lock index 348c00cfc..da4c38ded 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -4508,6 +4508,10 @@ style-search@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902" +stylelint-config-recommended@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/stylelint-config-recommended/-/stylelint-config-recommended-1.0.0.tgz#752c17fc68fa64cd5e7589e24f6e46e77e14a735" + stylelint@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-8.2.0.tgz#6a15044553fb5c3143b16d62013a370314495b0d" From 90bba7a3d79471f0cbb2ebfaf96fbcde24fb23ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Thu, 19 Oct 2017 14:59:22 +0200 Subject: [PATCH 11/24] add documentation --- README.md | 27 ++++++++++++++++----------- docs/LINTING.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 docs/LINTING.md diff --git a/README.md b/README.md index 7827d44ab..33da5efd1 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,22 @@ Add the `linaria/babel` preset to your Babel configuration: } ``` -See [Configuring Babel](/docs/BABEL_PRESET.md) for more options and [Bundlers integration](/docs/BUNDLERS_INTEGRATION.md) for integrating with Webpack. +## Documentation + +* [API and usage](/docs/API.md) + * [Client APIs](/docs/API.md#client-apis) + * [Server APIs](/docs/API.md#server-apis) +* [Configuring Babel](/docs/BABEL_PRESET.md) + * [Preset documentation](/docs/BABEL_PRESET.md#linariababel-preset) + * [Create React App](/docs/BABEL_PRESET.md#create-react-app-ejected) + * [Next.js](/docs/BABEL_PRESET.md#nextjs) +* [Dynamic Styles](/docs/DYNAMIC_STYLES.md) +* [Theming](/docs/THEMING.md) +* [Server Rendering](/docs/SERVER_RENDERING.md) +* [Bundlers integration](/docs/BUNDLERS_INTEGRATION.md) + * [Webpack](/docs/BUNDLERS_INTEGRATION.md#webpack) +* [Linting](/docs/LINTING.md) +* [Example](/website) ## How it works @@ -170,16 +185,6 @@ export function App() { ``` Here, there should be no side-effects in the `colors.js` file, or any file it imports. We recommend to move helpers and shared configuration to files without any side-effects. -## Documentation - -* [API and usage](/docs/API.md) -* [Configuring Babel](/docs/BABEL_PRESET.md) -* [Dynamic Styles](/docs/DYNAMIC_STYLES.md) -* [Theming](/docs/THEMING.md) -* [Server Rendering](/docs/SERVER_RENDERING.md) -* [Bundlers integration](/docs/BUNDLERS_INTEGRATION.md) -* [Example](/website) - ## Editor Plugins ### VSCode diff --git a/docs/LINTING.md b/docs/LINTING.md new file mode 100644 index 000000000..534311d4a --- /dev/null +++ b/docs/LINTING.md @@ -0,0 +1,45 @@ +# Linting + +## stylelint + +For linting styles with [stylelint](https://stylelint.io/), we provide our custom preprocessor (`linaria/stylelint-preprocessor`) and a basic config tailored for linaria - `linaria/stylelint-config` based on [`stylelint-config-recommended`](https://github.com/stylelint/stylelint-config-recommended). + +### Installation + +Both `stylelint` and `stylelint-config-recommended` are `peerDependencies` so you need to install them manually: + +```bash +yarn add stylelint stylelint-config-recommended --dev +``` + +### Configuring stylelint + +First of all, you need to add `linaria/stylelint-preprocessor` to the `preprocessors` array in your stylelint configuration as well as set `syntax` to `scss`. + +Please refer to the [official stylelint documentation](https://stylelint.io/user-guide/configuration/) for more info about configuration. + +We strongly recommend to use our `linaria/stylelint-config` to provide sensible defaults for linting. + +Here's the example `.stylelintrc` configuration file: + +```json +{ + "processors": ["linaria/stylelint-preprocessor"], + "syntax": "scss", + "extends": [ + "linaria/stylelint-config" + ] +} +``` + +### Running the linter + +Add the following to your `package.json` scripts: + +```json +"lint:css": "stylelint src/**/*.js" +``` + +Now, you can run `yarn lint:css` to run the linter. + +For more information refer to [stylelint documentation](https://stylelint.io/user-guide/cli/). From 059adec7960e244da0c2f59d7a698a600b0d7edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 11:45:44 +0200 Subject: [PATCH 12/24] lint css on circle CI --- .circleci/config.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 048c81774..d00f3dc6d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,13 +60,15 @@ jobs: - store_artifacts: path: website/__integration-tests__/__image_snapshots__/__diff_output__ destination: website-snapshot-diffs - build-website: + build-and-lint-website: <<: *defaults steps: - attach_workspace: at: ~/linaria - - run: | - cd website && yarn run build:all && cd .. + - run: cd website + - run: yarn run build:all + - run: yarn run lint-css + - run: cd .. workflows: version: 2 build-and-test: @@ -81,6 +83,6 @@ workflows: - integration-tests: requires: - install-dependencies - - build-website: + - build-and-lint-website: requires: - install-dependencies From 6d6765141550ec6e7441c926c7bc755031cc5fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 11:49:27 +0200 Subject: [PATCH 13/24] fix website's package.json --- website/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/package.json b/website/package.json index 25a7c2d45..9d9fb3460 100644 --- a/website/package.json +++ b/website/package.json @@ -12,7 +12,7 @@ "prebuild": "yarn run clean", "server": "node static/server/server.js", "start-server-render": "yarn build:all && yarn server", - "start": "cross-env NODE_ENV=development webpack-dev-server" + "start": "cross-env NODE_ENV=development webpack-dev-server", "lint-css": "stylelint src/**/*.js" }, "dependencies": { From 522a5affd9bb4733dd9a3c23d8b64e7e63793bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 11:55:07 +0200 Subject: [PATCH 14/24] fix errors --- .circleci/config.yml | 6 ++---- babel.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d00f3dc6d..7ebdf1a76 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -65,10 +65,8 @@ jobs: steps: - attach_workspace: at: ~/linaria - - run: cd website - - run: yarn run build:all - - run: yarn run lint-css - - run: cd .. + - run: cd website && yarn run build:all && cd .. + - run: cd website && yarn run lint-css && cd .. workflows: version: 2 build-and-test: diff --git a/babel.js b/babel.js index 9aea1bc80..b20ab07f5 100644 --- a/babel.js +++ b/babel.js @@ -9,8 +9,8 @@ module.exports = function linariaBabelPreset(context, opts = {}) { return { plugins: [ - [require('./build/babel/preval-extract').default, opts], - [require('./build/babel/rewire-imports').default, opts], + [require('./build/babel/preval-extract').default, options], + [require('./build/babel/rewire-imports').default, options], ], }; }; From ef5fd80bd9a254d374432e12bfaf184e076e737d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 14:00:31 +0200 Subject: [PATCH 15/24] move processor and syntax properties to linaria stylelint config --- stylelint-config.js | 2 ++ website/.stylelintrc | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stylelint-config.js b/stylelint-config.js index b60392aec..465ff6098 100644 --- a/stylelint-config.js +++ b/stylelint-config.js @@ -1,4 +1,6 @@ module.exports = { + processors: [require.resolve('./stylelint-preprocessor.js')], + syntax: 'scss', extends: 'stylelint-config-recommended', rules: { 'at-rule-name-case': 'lower', diff --git a/website/.stylelintrc b/website/.stylelintrc index 11b26565c..727684e57 100644 --- a/website/.stylelintrc +++ b/website/.stylelintrc @@ -1,6 +1,4 @@ { - "processors": ["linaria/stylelint-preprocessor"], - "syntax": "scss", "extends": [ "linaria/stylelint-config" ] From a5d1990aebb28878d8c79cdae433dd0517fd702f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 14:02:54 +0200 Subject: [PATCH 16/24] update docs --- docs/LINTING.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/LINTING.md b/docs/LINTING.md index 534311d4a..39fd7412c 100644 --- a/docs/LINTING.md +++ b/docs/LINTING.md @@ -2,7 +2,7 @@ ## stylelint -For linting styles with [stylelint](https://stylelint.io/), we provide our custom preprocessor (`linaria/stylelint-preprocessor`) and a basic config tailored for linaria - `linaria/stylelint-config` based on [`stylelint-config-recommended`](https://github.com/stylelint/stylelint-config-recommended). +For linting styles with [stylelint](https://stylelint.io/), we provide our custom config tailored for linaria - `linaria/stylelint-config` based on [`stylelint-config-recommended`](https://github.com/stylelint/stylelint-config-recommended). ### Installation @@ -14,24 +14,20 @@ yarn add stylelint stylelint-config-recommended --dev ### Configuring stylelint -First of all, you need to add `linaria/stylelint-preprocessor` to the `preprocessors` array in your stylelint configuration as well as set `syntax` to `scss`. - -Please refer to the [official stylelint documentation](https://stylelint.io/user-guide/configuration/) for more info about configuration. - -We strongly recommend to use our `linaria/stylelint-config` to provide sensible defaults for linting. +All you need to do is to set your config to extend from `linaria/stylelint-config`. Here's the example `.stylelintrc` configuration file: ```json { - "processors": ["linaria/stylelint-preprocessor"], - "syntax": "scss", "extends": [ "linaria/stylelint-config" ] } ``` +Please refer to the [official stylelint documentation](https://stylelint.io/user-guide/configuration/) for more info about configuration. + ### Running the linter Add the following to your `package.json` scripts: From 81d37cc4cc72ea9a85f9ef2a28e3b3fda0e6c3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 14:28:58 +0200 Subject: [PATCH 17/24] more tweaks --- .../__tests__/prevalStyles.spec.js | 32 ++++++++++++++----- .../__tests__/resolveSource.spec.js | 8 +++++ src/babel/preval-extract/prevalStyles.js | 7 ++++ src/babel/preval-extract/resolveSource.js | 8 +++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/babel/preval-extract/__tests__/prevalStyles.spec.js b/src/babel/preval-extract/__tests__/prevalStyles.spec.js index 4ece57d09..2cf8e75e2 100644 --- a/src/babel/preval-extract/__tests__/prevalStyles.spec.js +++ b/src/babel/preval-extract/__tests__/prevalStyles.spec.js @@ -12,7 +12,7 @@ jest.mock('../../lib/moduleSystem', () => ({ instantiateModule: jest.fn(() => ({ exports: 'header__abc123' })), })); -function runAssertions(expectedReplacement) { +function runAssertions(expectedReplacement, source = 'css`color: #ffffff`') { const path = { node: { loc: { @@ -30,7 +30,7 @@ function runAssertions(expectedReplacement) { }, }, getSource() { - return 'css`color: #ffffff`'; + return source; }, findParent() { return this.parentPath; @@ -50,18 +50,34 @@ function runAssertions(expectedReplacement) { expect(instantiateModule).toHaveBeenCalled(); } +function clearMocks() { + process.env.NODE_ENV = ''; + getReplacement.mockClear(); + instantiateModule.mockClear(); + clearLocalModulesFromCache.mockClear(); +} + describe('preval-extract/prevalStyles', () => { - beforeEach(() => { - process.env.NODE_ENV = ''; - getReplacement.mockClear(); - instantiateModule.mockClear(); - clearLocalModulesFromCache.mockClear(); - }); + beforeEach(clearMocks); it('should eval styles and replace css with class name from content', () => { runAssertions("css.named('header', 'test.js')`color: #ffffff`"); }); + it('should eval styles and append filename if used with css.named', () => { + runAssertions( + "css.named('header', 'test.js')`color: #ffffff`", + "css.named('header')`color: #ffffff`" + ); + + clearMocks(); + + runAssertions( + "css.named('header', 'filename.js')`color: #ffffff`", + "css.named('header', 'filename.js')`color: #ffffff`" + ); + }); + it('should eval styles and replace css with class name from filename', () => { process.env.NODE_ENV = 'production'; runAssertions("css.named('header')`color: #ffffff`"); diff --git a/src/babel/preval-extract/__tests__/resolveSource.spec.js b/src/babel/preval-extract/__tests__/resolveSource.spec.js index ff3680b46..206bd4e03 100644 --- a/src/babel/preval-extract/__tests__/resolveSource.spec.js +++ b/src/babel/preval-extract/__tests__/resolveSource.spec.js @@ -148,4 +148,12 @@ describe('preval-extract/resolveSource', () => { null ); }); + + it("should return null if it's a global identifier", () => { + expect(resolveSource({}, { node: { name: 'module' } })).toBeNull(); + expect(resolveSource({}, { node: { name: '__filename' } })).toBeNull(); + expect(resolveSource({}, { node: { name: '__dirname' } })).toBeNull(); + expect(resolveSource({}, { node: { name: 'global' } })).toBeNull(); + expect(resolveSource({}, { node: { name: 'exports' } })).toBeNull(); + }); }); diff --git a/src/babel/preval-extract/prevalStyles.js b/src/babel/preval-extract/prevalStyles.js index 47f0d0d61..ae896808e 100644 --- a/src/babel/preval-extract/prevalStyles.js +++ b/src/babel/preval-extract/prevalStyles.js @@ -52,6 +52,13 @@ export default function( env === 'production' ? `css.named('${name}')` : `css.named('${name}', '${state.filename}')` + ) + .replace( + /css\.named\(([^,]+)\)/, + (input, customName) => + env === 'production' + ? input + : `css.named(${customName}, '${state.filename}')` )}`, loc: path.node.loc.start, }, diff --git a/src/babel/preval-extract/resolveSource.js b/src/babel/preval-extract/resolveSource.js index a530c51c7..b7ef6004a 100644 --- a/src/babel/preval-extract/resolveSource.js +++ b/src/babel/preval-extract/resolveSource.js @@ -34,6 +34,14 @@ export default function resolveSource( types: BabelTypes, path: NodePath<*> ): ?RequirementSource { + if ( + ['module', 'global', '__dirname', '__filename', 'exports'].includes( + path.node.name + ) + ) { + return null; + } + const binding = getSelfBinding(path); if (!binding) { From 31c2e560c7721cb03f8be96eb3bb32d6f0f44636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 14:30:31 +0200 Subject: [PATCH 18/24] fix linter --- src/tools/stylelint-preprocessor.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/tools/stylelint-preprocessor.js b/src/tools/stylelint-preprocessor.js index 9197d4e0e..e0562fe2b 100644 --- a/src/tools/stylelint-preprocessor.js +++ b/src/tools/stylelint-preprocessor.js @@ -51,7 +51,7 @@ export default function linariaStylelintPreprocessor(/* options */) { return `${acc}\n.${classname} {${styles}}`; }, ''); - cache[filename] = { css, code, map }; + cache[filename] = { css, code, map, input }; return css; }, @@ -60,16 +60,16 @@ export default function linariaStylelintPreprocessor(/* options */) { return; } - const { code, css, map } = cache[filename]; + const { code, css, map, input } = cache[filename]; const { warnings } = lintResults; warnings.forEach(warning => { - const relevantCss = css.split('\n').slice(0, warning.line); + const relevantCss = css.split('\n').slice(1, warning.line); let classname; let offset = 0; for (let i = relevantCss.length - 1; i >= 0; i--) { - const match = relevantCss[i].match(/\.([a-zA-Z0-9]+__[a-z0-9]+) {/); + const match = relevantCss[i].match(/\.(_?[a-zA-Z0-9]+__[a-z0-9]+) {/); if (match) { classname = match[1]; offset = relevantCss.length - i - 1; @@ -77,18 +77,24 @@ export default function linariaStylelintPreprocessor(/* options */) { } } - const startLineLocation = - code.split('\n').findIndex(line => line.includes(classname)) + 1; + const startLineLocation = code + .split('\n') + .findIndex(line => line.includes(classname)); // prettier-ignore - const startColumnLocation = code.split('\n')[startLineLocation - 1] + const startColumnLocation = code.split('\n')[startLineLocation] .indexOf(classname); const consumer = new SourceMapConsumer(map); const originalPos = consumer.originalPositionFor({ - line: startLineLocation, + line: startLineLocation + 1, column: startColumnLocation, }); + offset += input + .split('\n') + .slice(originalPos.line - 1) + .findIndex(line => /css(\.named\(.+\))?`/.test(line)); + // eslint-disable-next-line no-param-reassign warning.line = originalPos.line + offset; }); From d2adfbc857086b760d81ddde2875de0556fd06a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 14:33:04 +0200 Subject: [PATCH 19/24] tweak linaria overrides name --- babel.js | 2 +- src/tools/stylelint-preprocessor.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/babel.js b/babel.js index b20ab07f5..2f8aee2eb 100644 --- a/babel.js +++ b/babel.js @@ -4,7 +4,7 @@ module.exports = function linariaBabelPreset(context, opts = {}) { const options = Object.assign( opts, // Escape hatch for overwriting linaria preset's options. - JSON.parse(process.env.LINARIA_OVERWRITE_BABEL_PRESET || '{}') + JSON.parse(process.env.LINARIA_BABEL_PRESET_OVERRIDES || '{}') ); return { diff --git a/src/tools/stylelint-preprocessor.js b/src/tools/stylelint-preprocessor.js index e0562fe2b..db4e04f0f 100644 --- a/src/tools/stylelint-preprocessor.js +++ b/src/tools/stylelint-preprocessor.js @@ -18,7 +18,7 @@ function toString(templates: string[], expressions: string[]) { } export default function linariaStylelintPreprocessor(/* options */) { - process.env.LINARIA_OVERWRITE_BABEL_PRESET = JSON.stringify({ + process.env.LINARIA_BABEL_PRESET_OVERRIDES = JSON.stringify({ extract: false, }); // $FlowFixMe From cb706a4b41e40643c246a89e6e66f3c1e02f546c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 14:33:19 +0200 Subject: [PATCH 20/24] remove unnecessary rules from stylelint config --- stylelint-config.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/stylelint-config.js b/stylelint-config.js index 465ff6098..1a8213ba5 100644 --- a/stylelint-config.js +++ b/stylelint-config.js @@ -5,10 +5,7 @@ module.exports = { rules: { 'at-rule-name-case': 'lower', 'unit-case': 'lower', - 'at-rule-semicolon-newline-after': 'always', - 'max-empty-lines': 1, 'no-empty-source': null, - 'length-zero-no-unit': true, 'no-extra-semicolons': null, }, }; From 9a11aba4e35cfd1a85f6dc9c5ed60f99eb045759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Fri, 27 Oct 2017 14:57:08 +0200 Subject: [PATCH 21/24] update snapshots --- .../preval-extract/__snapshots__/errors.spec.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/babel/__integration-tests__/preval-extract/__snapshots__/errors.spec.js.snap b/src/babel/__integration-tests__/preval-extract/__snapshots__/errors.spec.js.snap index 8a4921d3e..df4bf7f74 100644 --- a/src/babel/__integration-tests__/preval-extract/__snapshots__/errors.spec.js.snap +++ b/src/babel/__integration-tests__/preval-extract/__snapshots__/errors.spec.js.snap @@ -67,7 +67,7 @@ SyntaxError: test.js: Linaria css evaluation error: 5 | \`; at File.buildCodeFrameError (<>/node_modules/babel-core/lib/transformation/file/index.js:427:15) at NodePath.buildCodeFrameError (<>/node_modules/babel-traverse/lib/path/index.js:140:26) - at resolveSource (<>/build/babel/preval-extract/resolveSource.js:31:16) + at resolveSource (<>/build/babel/preval-extract/resolveSource.js:35:16) at Object.Identifier (<>/build/babel/preval-extract/index.js:46:48) at NodePath._call (<>/node_modules/babel-traverse/lib/path/context.js:76:18) at NodePath.call (<>/node_modules/babel-traverse/lib/path/context.js:48:17) From 8d8ae9b1dae0090e214e9ca8ba0c397ad4e4726b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Thu, 2 Nov 2017 11:29:28 +0100 Subject: [PATCH 22/24] store raw styles in sheet module --- .eslintignore | 1 + src/css.js | 12 +----------- src/sheet.js | 21 +++++++++++++++++++++ src/tools/stylelint-preprocessor.js | 4 ++-- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.eslintignore b/.eslintignore index 3c628f408..52f868b98 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,3 +4,4 @@ coverage/ flow-typed/ node_modules/ vendor/ +website/ diff --git a/src/css.js b/src/css.js index b74f8d035..def036fe6 100644 --- a/src/css.js +++ b/src/css.js @@ -5,12 +5,6 @@ import slugify from './slugify'; import sheet from './sheet'; import { getFramesFromStack, enhanceFrames } from './babel/lib/errorUtils'; -const rawStyles = {}; - -export function getRawStyles() { - return rawStyles; -} - const named = (name?: string = 'css', filename: ?string = null) => ( template: string[], ...expressions: string[] @@ -75,11 +69,7 @@ const named = (name?: string = 'css', filename: ?string = null) => ( const slug = slugify(filename || styles); const classname = `${name}__${slug}`; - if (filename && process.env.LINARIA_COLLECT_RAW_STYLES) { - rawStyles[filename] = (rawStyles[filename] || []) - .concat({ template, expressions, classname }); - } - + sheet.insertRaw({ filename, template, expressions, classname }); sheet.insert(`.${classname}`, styles); return classname; diff --git a/src/sheet.js b/src/sheet.js index 4151919e4..318685abf 100644 --- a/src/sheet.js +++ b/src/sheet.js @@ -2,8 +2,15 @@ import stylis from 'stylis'; +type RawStyles = { + template: string[], + expressions: string[], + classname: string, +}; + function sheet() { let cache: { [selector: string]: string } = {}; + const rawCache: { [selector: string]: RawStyles[] } = {}; const isBrowser = typeof window === 'object' && window != null && window.document != null; @@ -25,6 +32,17 @@ function sheet() { } return { + insertRaw({ + filename, + template, + expressions, + classname, + }: RawStyles & { filename: ?string }) { + if (filename && process.env.LINARIA_COLLECT_RAW_STYLES) { + rawCache[filename] = (rawCache[filename] || []) + .concat({ template, expressions, classname }); + } + }, insert(selector: string, css: string) { if (selector in cache) { return; @@ -34,6 +52,9 @@ function sheet() { cache[selector] = css; node.appendData(`\n${text}`); }, + rawStyles() { + return rawCache; + }, styles() { return cache; }, diff --git a/src/tools/stylelint-preprocessor.js b/src/tools/stylelint-preprocessor.js index db4e04f0f..7744d825d 100644 --- a/src/tools/stylelint-preprocessor.js +++ b/src/tools/stylelint-preprocessor.js @@ -34,8 +34,8 @@ export default function linariaStylelintPreprocessor(/* options */) { }); const rawStyles = getCachedModule( - require.resolve('../css.js') - ).exports.getRawStyles(); + require.resolve('../sheet.js') + ).exports.default.rawStyles(); if (!Object.keys(rawStyles).length || !rawStyles[filename]) { return ''; From 4b0c6f84c0b6d5c1b990b20d26310488cd3fe8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Thu, 2 Nov 2017 11:48:34 +0100 Subject: [PATCH 23/24] fix tests --- src/__tests__/css.spec.js | 22 +--------------------- src/__tests__/sheet.spec.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/__tests__/css.spec.js b/src/__tests__/css.spec.js index 6d9ae8b80..2d6db359c 100644 --- a/src/__tests__/css.spec.js +++ b/src/__tests__/css.spec.js @@ -1,6 +1,6 @@ /* @flow */ -import css, { getRawStyles } from '../css'; +import css from '../css'; jest.mock('../babel/lib/errorUtils', () => ({ getFramesFromStack: (...args) => @@ -38,24 +38,4 @@ describe('css module', () => { css.named('test')`color: ${null}`; }).toThrowError('Expression cannot be undefined or null'); }); - - it('should collect raw styles', () => { - // $FlowFixMe - process.env.LINARIA_COLLECT_RAW_STYLES = true; - - const header = css.named('header', 'test.js')` - color: blue; - `; - process.env.LINARIA_COLLECT_RAW_STYLES = undefined; - - expect(getRawStyles()).toEqual({ - 'test.js': [ - { - template: ['\n color: blue;\n '], - expressions: [], - classname: header, - }, - ], - }); - }); }); diff --git a/src/__tests__/sheet.spec.js b/src/__tests__/sheet.spec.js index a59bc19a5..b06aa1314 100644 --- a/src/__tests__/sheet.spec.js +++ b/src/__tests__/sheet.spec.js @@ -51,4 +51,29 @@ describe('sheet module', () => { expect(sheet.dump()).toBe('.lol{color:pink;}'); }); + + it('should collect raw styles', () => { + // $FlowFixMe + process.env.LINARIA_COLLECT_RAW_STYLES = true; + + const header = 'header_123abc'; + sheet.insertRaw({ + filename: 'test.js', + template: ['color: blue;'], + expressions: [], + classname: header, + }); + + process.env.LINARIA_COLLECT_RAW_STYLES = undefined; + + expect(sheet.rawStyles()).toEqual({ + 'test.js': [ + { + template: ['color: blue;'], + expressions: [], + classname: header, + }, + ], + }); + }); }); From 302edc64d284a243a47fe18b7e5d9d7ca37ee95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Trys=C5=82a?= Date: Thu, 2 Nov 2017 11:53:30 +0100 Subject: [PATCH 24/24] ignore server folder from website --- .eslintignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintignore b/.eslintignore index 52f868b98..fb1f525ec 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,4 +4,4 @@ coverage/ flow-typed/ node_modules/ vendor/ -website/ +website/static/server