scss-validator
This library will help to mandate rules for writing css in large enterprise UI component development.
Installation
This is a Node.js module available through the
npm registry. It can be installed using the
npm
or
yarn
command line tools.
npm install scss-validator --save
Usage
const scssObject = ; const configObject = ; ;
SuccessScssConfig.js - sample file
moduleexports = 'srcDir' : './src' 'srcFile' : '' 'ignoreFiles' : 'NoMatch.css' 'spaceTagClassNameCheck' : 'body' 'div' 'span' 'a' 'containTagClassNameCheck' : 'body' 'div' 'span'
run(configObject)
A exported main function.
Kind: global function
Param | Type | Description |
---|---|---|
configObject | Information about the configFile. | |
configObject.srcDir | string |
The source directory for sccs. default value "." |
configObject.srcFile | string |
The single scss file. if provided only single file will be scaned. |
configObject.ignoreFiles | Array.<string> |
The ignoreFiles. default value [] |
configObject.spaceTagClassNameCheck | Array.<string> |
Array of html tag ClassName to chek in scss. default value ['body', 'div', 'span','a'] |
configObject.containTagClassNameCheck | Array.<string> |
Array of contain html tag ClassName to chek in scss. default value [] |
Rules
-
root classname should be "filename"-component
-
there should be only one root class in scss file
-
spaceTagClassNameCheck i.e this html tag selectors are not allowed.
- not allowed example :
}- not allowed example :
} -
containTagClassNameCheck same as spaceTagClassNameCheck but containg keyword classname not allowed
Tests
npm installnpm test
Dependencies
Dev Dependencies
- jsdoc-to-markdown: Generates markdown API documentation from jsdoc annotated source code
- np: A better
npm publish
- package-json-to-readme: Generate a README.md from package.json contents
License
MIT