forked from stylelint/stylelint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for async rules (stylelint#2351)
* Add support for async rules * Copy editing
- Loading branch information
1 parent
01474a3
commit ded4db2
Showing
4 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use strict" | ||
|
||
const stylelint = require("../../") | ||
|
||
const ruleName = "plugin/async" | ||
|
||
const rule = enabled => (root, result) => { | ||
const validOptions = stylelint.utils.validateOptions(result, ruleName, { | ||
actual: enabled, | ||
possible: [ true, false ], | ||
}) | ||
|
||
if (!validOptions) { | ||
return null | ||
} | ||
|
||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
stylelint.utils.report({ | ||
result, | ||
ruleName, | ||
message: "Async rule", | ||
node: root, | ||
}) | ||
resolve() | ||
}) | ||
}, 1) | ||
} | ||
|
||
module.exports = stylelint.createPlugin(ruleName, rule) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters