scss-validator

2.0.0 • Public • Published

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 = require('scss-validator');
 
const configObject = require('./SuccessScssConfig');
 
scssObject(configObject);
 
 

SuccessScssConfig.js - sample file

 
module.exports =  {
    '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

  1. root classname should be "filename"-component

  2. there should be only one root class in scss file

  3. spaceTagClassNameCheck i.e this html tag selectors are not allowed.

    1. not allowed example :
    .card {
        body {
            color : red;
        }
    }
    1. not allowed example :
    .drop-down {
        div {
            color : blue;
        }
    }
  4. containTagClassNameCheck same as spaceTagClassNameCheck but containg keyword classname not allowed

Tests

npm install
npm test

Dependencies

  • fs:
  • glob: a little globber
  • path: Node.JS path module
  • readline: Simple streaming readline module.

Dev Dependencies

License

MIT

Package Sidebar

Install

npm i scss-validator

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

21.3 kB

Total Files

14

Last publish

Collaborators

  • nirajkashyap