-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(non-space-content): switch all non-empty checks to new generic c…
…heck (#2215) * feat(non-space-content): switch all non-empty checks to new generic check * udpate doc
- Loading branch information
Showing
12 changed files
with
87 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Generic checks are evaluate functions that are used by multiple checks. They cannot be used directly by a rule (thus there is no check meatadata file associated with them) and must be used by another check passing in the required options. | ||
|
||
To use these checks, pass the check id (found in the metadata-function-map file) as the value of a checks `evaluate` property and pass any required options. | ||
|
||
```json | ||
{ | ||
"id": "my-check", | ||
"evaluate": "generic-check-id", | ||
"options": { | ||
"required": true | ||
} | ||
} | ||
``` |
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,14 @@ | ||
import { sanitize } from '../../commons/text'; | ||
|
||
function attrNonSpaceContentEvaluate(node, options = {}, vNode) { | ||
if (!options.attribute || typeof options.attribute !== 'string') { | ||
throw new TypeError( | ||
'attr-non-space-content requires options.attribute to be a string' | ||
); | ||
} | ||
|
||
const attribute = vNode.attr(options.attribute) || ''; | ||
return !!sanitize(attribute.trim()); | ||
} | ||
|
||
export default attrNonSpaceContentEvaluate; |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
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
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