diff --git a/.eleventy.js b/.eleventy.js index 2f121af6..f98867b0 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -11,20 +11,6 @@ const toc = require('./lib/eleventy/toc') const { environment } = require('./lib/nunjucks') module.exports = config => { - if (dev) { - const throttle = 100 - const reloadOnChange = require('./lib/eleventy/reload') - reloadOnChange(__filename, [ - 'lib/**/*.js', - // we need to watch these ones explicitly because they - // change how examples and color swatches are rendered - 'docs/_includes/{example,macros}.njk' - ], throttle) - - // throttle subsequent rebuilds - config.setWatchThrottleWaitTime(throttle) - } - config.addPlugin(navigation) config.addPlugin(remark, remarkConfig) config.addPlugin(toc, { @@ -38,6 +24,7 @@ module.exports = config => { config.setUseGitIgnore(false) config.addWatchTarget('./dist') config.addPassthroughCopy('dist') + config.addPassthroughCopy('docs/static') return { dir: { diff --git a/.eslintrc.js b/.eslintrc.js index 58bee9a7..7122b29e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,14 +1,20 @@ module.exports = { parser: '@babel/eslint-parser', - plugins: ['sfgov'], + plugins: [ + 'sfgov', + 'unicorn' + ], extends: [ 'plugin:sfgov/recommended' ], rules: { + 'unicorn/expiring-todo-comments': ['error', { + allowWarningComments: true + }] }, overrides: [ { - files: ['src/js/*.js', 'src/icons/index.js'], + files: ['src/**/*.js'], env: { browser: true }, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12aebf6c..4070f787 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,9 @@ jobs: with: node-version: 14 cache: npm - - run: npm ci + + - uses: xt0rted/markdownlint-problem-matcher@v1 - run: npm run lint # this sets NODE_ENV=production for all of the build scripts diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 00000000..5476c14b --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,15 @@ +default: false +heading-increment: true +heading-style: atx +first-heading-h1: { level: 2 } +front-matter: + required_keys: + - title +line-length: false +links: true +list-indent: true +no-bare-urls: false +no-empty: true +ul-indent: { indent: 2, start_indented: false } +ul-style: consistent +whitespace: true diff --git a/.stylelintrc.js b/.stylelintrc.js new file mode 100644 index 00000000..d1a9be45 --- /dev/null +++ b/.stylelintrc.js @@ -0,0 +1,23 @@ +module.exports = { + extends: [ + 'stylelint-config-standard' + ], + plugins: [ + './lib/stylelint/expiring-todo-comments' + ], + rules: { + 'at-rule-no-unknown': [true, { + ignoreAtRules: [ + 'apply', + 'layer', + 'responsive', + 'screen', + 'tailwind', + 'variants' + ] + }], + 'local/expiring-todo-comments': [true, { + }], + 'string-quotes': 'single' + } +} diff --git a/docs/_data/eleventyComputed.js b/docs/_data/eleventyComputed.js index ba602e57..f07ef3df 100644 --- a/docs/_data/eleventyComputed.js +++ b/docs/_data/eleventyComputed.js @@ -44,6 +44,8 @@ function getLastCommitFromGit (path) { } async function getLastCommitFromGitHub (path) { + if (process.env.NODE_ENV === 'development') return null + const args = { ...context, path, sha: branch, per_page: 1 } // console.info('getting last commit from github:', args) @@ -53,7 +55,7 @@ async function getLastCommitFromGitHub (path) { res = await github.rest.repos.listCommits(args) commits = res.data } catch (error) { - console.warn('error loading commits for "%s"', path, error) + console.warn('error loading commits for "%s"', path) gitMetaCache.set(path, null) return null } @@ -71,7 +73,7 @@ async function getLastCommitFromGitHub (path) { // console.info('caching git meta for "%s"', path, meta) return meta } else { - console.warn('unable to get commit for "%s"', path, res) + console.warn('unable to get commit for "%s"', path) return null } } diff --git a/docs/_data/examples.js b/docs/_data/examples.js index 279975ff..c0a0deb2 100644 --- a/docs/_data/examples.js +++ b/docs/_data/examples.js @@ -32,6 +32,5 @@ async function getExamples () { }) } - return examples } diff --git a/docs/_data/package.js b/docs/_data/package.js index 5a82c09f..96b17a16 100644 --- a/docs/_data/package.js +++ b/docs/_data/package.js @@ -30,6 +30,6 @@ async function getPublishedStatusVersion () { console.warn('no published version status for %s', sha, statuses) } } catch (error) { - console.warn('unable to get published version status:', error) + console.warn('unable to get published version status:', error.message) } } diff --git a/docs/_data/utilities.js b/docs/_data/utilities.js new file mode 100644 index 00000000..74232673 --- /dev/null +++ b/docs/_data/utilities.js @@ -0,0 +1,41 @@ +const postcss = require('postcss') +const { readFileSync } = require('fs') + +const UTILITY_SELECTOR_PATTERN = /^\.[-:\w]+$/ + +module.exports = function getUtilities () { + const css = readFileSync('dist/css/utilities.css', 'utf8') + const root = postcss.parse(css) + /** @type [postcss.Declaration] */ + const decls = [] + root.walkRules(rule => { + if (UTILITY_SELECTOR_PATTERN.test(rule.selector)) { + rule.walkDecls((decl, index) => { + decls.push(decl) + }) + } + }) + + return { + decls, + byClassname: Object.fromEntries( + decls.map(decl => [ + decl.parent.selector.substring(1), + decl + ]) + ), + byProperty: groupBy( + decls, + decl => decl.prop + ) + } +} + +function groupBy (list /** @type [any] */, keyFunction /** type Function */) { + return list.reduce((map, d, i) => { + const key = keyFunction(d, i) + if (key in map) map[key].push(d) + else map[key] = [d] + return map + }, {}) +} diff --git a/docs/_includes/toc.njk b/docs/_includes/toc.njk index 2e8364d3..882a83c5 100644 --- a/docs/_includes/toc.njk +++ b/docs/_includes/toc.njk @@ -1,5 +1,5 @@