Skip to content

Commit ceb67a3

Browse files
committed
chore: lint
1 parent 08fe118 commit ceb67a3

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

lib/stylelint-todo.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
1111
module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
1212
const {currentVersion} = options
1313
if (!currentVersion) {
14+
// eslint-disable-next-line no-console
1415
console.warn(`No "currentVersion" supplied to ${ruleName}; bailing`)
1516
return () => null
1617
}
@@ -19,10 +20,13 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}) => {
1920
return (root, result) => {
2021
root.walkComments(node => {
2122
if ((match = node.text.match(pattern))) {
23+
// eslint-disable-next-line no-unused-vars
2224
const [substr, todoVersion, message] = match
2325
if (semver.lte(todoVersion, currentVersion)) {
2426
stylelint.utils.report({
25-
message: messages.rejected(`Unresolved TODO comment: "${message}" (expected to be resolved in "${todoVersion}")`),
27+
message: messages.rejected(
28+
`Unresolved TODO comment: "${message}" (expected to be resolved in "${todoVersion}")`
29+
),
2630
node,
2731
result,
2832
ruleName

script/test-todos.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@ const {red} = require('colorette')
55
const ruleName = 'primer-css/TODO'
66
const cwd = process.cwd()
77

8-
stylelint
9-
.lint({files: 'src/**/*.scss'})
10-
.then(data => {
11-
let fail = false
12-
for (const {source, warnings} of data.results) {
13-
if (warnings.some(w => w.rule === ruleName)) {
14-
console.warn('\n' + source.substr(cwd.length + 1))
15-
}
16-
for (const warning of warnings) {
17-
if (warning.rule === ruleName) {
18-
console.warn(`${red('✖')} ${warning.text}`)
19-
fail = true
20-
}
8+
stylelint.lint({files: 'src/**/*.scss'}).then(data => {
9+
let fail = false
10+
for (const {source, warnings} of data.results) {
11+
if (warnings.some(w => w.rule === ruleName)) {
12+
// eslint-disable-next-line prefer-template
13+
console.warn('\n' + source.substr(cwd.length + 1))
14+
}
15+
for (const warning of warnings) {
16+
if (warning.rule === ruleName) {
17+
console.warn(`${red('✖')} ${warning.text}`)
18+
fail = true
2119
}
2220
}
21+
}
2322

24-
process.exit(fail ? 1 : 0)
25-
})
23+
process.exit(fail ? 1 : 0)
24+
})

0 commit comments

Comments
 (0)