mirror of
https://github.com/primer/css.git
synced 2024-11-26 12:14:22 +03:00
chore: lint
This commit is contained in:
parent
08fe118c75
commit
ceb67a351c
@ -11,6 +11,7 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
|
||||
module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
||||
const {currentVersion} = options
|
||||
if (!currentVersion) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`No "currentVersion" supplied to ${ruleName}; bailing`)
|
||||
return () => null
|
||||
}
|
||||
@ -19,10 +20,13 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
|
||||
return (root, result) => {
|
||||
root.walkComments(node => {
|
||||
if ((match = node.text.match(pattern))) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [substr, todoVersion, message] = match
|
||||
if (semver.lte(todoVersion, currentVersion)) {
|
||||
stylelint.utils.report({
|
||||
message: messages.rejected(`Unresolved TODO comment: "${message}" (expected to be resolved in "${todoVersion}")`),
|
||||
message: messages.rejected(
|
||||
`Unresolved TODO comment: "${message}" (expected to be resolved in "${todoVersion}")`
|
||||
),
|
||||
node,
|
||||
result,
|
||||
ruleName
|
||||
|
@ -5,21 +5,20 @@ const {red} = require('colorette')
|
||||
const ruleName = 'primer-css/TODO'
|
||||
const cwd = process.cwd()
|
||||
|
||||
stylelint
|
||||
.lint({files: 'src/**/*.scss'})
|
||||
.then(data => {
|
||||
let fail = false
|
||||
for (const {source, warnings} of data.results) {
|
||||
if (warnings.some(w => w.rule === ruleName)) {
|
||||
console.warn('\n' + source.substr(cwd.length + 1))
|
||||
}
|
||||
for (const warning of warnings) {
|
||||
if (warning.rule === ruleName) {
|
||||
console.warn(`${red('✖')} ${warning.text}`)
|
||||
fail = true
|
||||
}
|
||||
stylelint.lint({files: 'src/**/*.scss'}).then(data => {
|
||||
let fail = false
|
||||
for (const {source, warnings} of data.results) {
|
||||
if (warnings.some(w => w.rule === ruleName)) {
|
||||
// eslint-disable-next-line prefer-template
|
||||
console.warn('\n' + source.substr(cwd.length + 1))
|
||||
}
|
||||
for (const warning of warnings) {
|
||||
if (warning.rule === ruleName) {
|
||||
console.warn(`${red('✖')} ${warning.text}`)
|
||||
fail = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(fail ? 1 : 0)
|
||||
})
|
||||
process.exit(fail ? 1 : 0)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user