Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back vnu-jar for HTML validation #24149

Merged
merged 4 commits into from
Oct 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ group :development, :test do
gem 'jekyll', '~> 3.6.0'
gem 'jekyll-redirect-from', '~> 0.12.1'
gem 'jekyll-sitemap', '~> 1.1.1'
gem 'jekyll-toc', '~> 0.3.0'
gem 'jekyll-toc', '~> 0.4.0.rc2'
end
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GEM
sass (~> 3.4)
jekyll-sitemap (1.1.1)
jekyll (~> 3.3)
jekyll-toc (0.3.0)
jekyll-toc (0.4.0.rc2)
nokogiri (~> 1.6)
jekyll-watch (1.5.0)
listen (~> 3.0, < 3.1)
Expand Down Expand Up @@ -61,7 +61,7 @@ DEPENDENCIES
jekyll (~> 3.6.0)
jekyll-redirect-from (~> 0.12.1)
jekyll-sitemap (~> 1.1.1)
jekyll-toc (~> 0.3.0)
jekyll-toc (~> 0.4.0.rc2)

BUNDLED WITH
1.15.4
46 changes: 46 additions & 0 deletions build/htmllint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env node

/*!
* Script to run vnu-jar if Java is available.
* Copyright 2017 The Bootstrap Authors
* Copyright 2017 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/

'use strict'

const childProcess = require('child_process')
const vnu = require('vnu-jar')

childProcess.exec('java -version', function (error) {
if (error) {
console.error('Skipping HTML lint test; Java is missing.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you return directly after that console.error you should throw an error instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to fail here; if Java isn't installed we are just skipping vnu-jar.

return
}

const ignores = [
'Attribute “autocomplete” is only allowed when the input type is “color”, “date”, “datetime-local”, “email”, “hidden”, “month”, “number”, “password”, “range”, “search”, “tel”, “text”, “time”, “url”, or “week”.',
'Attribute “autocomplete” not allowed on element “button” at this point.',
'Attribute “title” not allowed on element “circle” at this point.',
'Bad value “tablist” for attribute “role” on element “nav”.',
'Element “img” is missing required attribute “src”.',
'Element “legend” not allowed as child of element “div” in this context.*'
].join('|')

const args = [
'-jar',
vnu,
'--asciiquotes',
'--errors-only',
'--skip-non-html',
`--filterpattern "${ignores}"`,
'_gh_pages/',
'js/tests/'
]

return childProcess.spawn('java', args, {
shell: true,
stdio: 'inherit'
})
.on('exit', process.exit)
})
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"docs-compile": "bundle exec jekyll build",
"postdocs-compile": "npm run docs-workbox-precache",
"docs-github": "shx echo \"github: true\" > twbsconfig.yml && npm run docs-compile -- --config _config.yml,twbsconfig.yml && shx rm ./twbsconfig.yml",
"docs-lint": "htmllint --rc build/.htmllintrc \"_gh_pages/**/*.html\" \"js/tests/**/*.html\"",
"docs-lint": "htmllint --rc build/.htmllintrc \"_gh_pages/**/*.html\" \"js/tests/**/*.html\" && node build/htmllint.js",
"docs-serve": "bundle exec jekyll serve",
"docs-upload-preview": "build/upload-preview.sh",
"docs-workbox-precache": "node build/workbox.js",
Expand Down Expand Up @@ -111,6 +111,7 @@
"stylelint-order": "^0.7.0",
"stylelint-scss": "^2.1.0",
"uglify-js": "^3.0.24",
"vnu-jar": "^17.11.1",
"workbox-build": "^2.0.1"
},
"engines": {
Expand Down