├── .editorconfig ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── index.js ├── package.json ├── rules ├── disallowMultiSpacesBetweenSelectorsAndDeclarationStartBlock.js ├── disallowNewLineBetweenSelectorsAndDeclarationStartBlock.js ├── disallowSpacesBeforeStartSelector.js ├── requireSemicolonInLastDeclaration.js ├── requireSpaceBetweenSelectorsAndDeclarationEndBlock.js └── requireSpaceBetweenSelectorsAndDeclarationStartBlock.js └── test └── index.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - iojs 5 | - "0.10" 6 | - "0.12" 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Copyright (c) 2015 Masaaki Morishita 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.)) 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CSSCS [![Build Status](https://travis-ci.org/morishitter/csscs.svg)](https://travis-ci.org/morishitter/csscs) 2 | 3 | [![Join the chat at https://gitter.im/morishitter/csscs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/morishitter/csscs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 | 5 | CSS Code Style 6 | 7 | ## Installation 8 | 9 | ```shell 10 | $ npm install csscs 11 | ``` 12 | 13 | ## Example 14 | 15 | ## License 16 | 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2015 Masaaki Morishita 20 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var postcss = require('postcss') 2 | 3 | function Csscs (css, rules) { 4 | if (!this instanceof Csscs) { 5 | return new Csscs(css, processors) 6 | } 7 | 8 | if (!rules) { 9 | rules = [] 10 | } 11 | 12 | this.css = css 13 | this.rules = rules 14 | } 15 | 16 | Csscs.prototype.check = function () { 17 | postcss(this.rules).process(this.css).css 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "csscs", 3 | "version": "0.0.0", 4 | "description": "CSS Code Style", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "tape test" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/morishitter/csscs/git" 12 | }, 13 | "keywords": [ 14 | "code style", 15 | "lint", 16 | "formatter", 17 | "linter", 18 | "validate", 19 | "css" 20 | ], 21 | "author": "Masaaki Morishita", 22 | "license": "MIT", 23 | "dependencies": { 24 | "postcss": "^4.1.16" 25 | }, 26 | "devDependencies": {} 27 | } 28 | -------------------------------------------------------------------------------- /rules/disallowMultiSpacesBetweenSelectorsAndDeclarationStartBlock.js: -------------------------------------------------------------------------------- 1 | var postcss = require('postcss') 2 | 3 | module.exports = function () { 4 | return function (root) { 5 | root.eachRule(function (rule) { 6 | var betweenCount = rule.between.length 7 | if (betweenCount > 1) { 8 | console.warn('disallow multi spaces between selector and {') 9 | } 10 | }) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /rules/disallowNewLineBetweenSelectorsAndDeclarationStartBlock.js: -------------------------------------------------------------------------------- 1 | var postcss = require('postcss') 2 | 3 | module.exports = function () { 4 | return function (root) { 5 | root.eachRule(function (rule) { 6 | if (rule.before.between('\n') === -1){ 7 | console.warn('need new line between last declaration and }') 8 | } 9 | }) 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rules/disallowSpacesBeforeStartSelector.js: -------------------------------------------------------------------------------- 1 | var postcss = require('postcss') 2 | 3 | module.exports = function () { 4 | return function (root) { 5 | root.eachRule(function (rule) { 6 | var beforeCount = rule.before.length 7 | if (betweenCount > 1) { 8 | console.warn('disallow spaces before selector') 9 | } 10 | }) 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /rules/requireSemicolonInLastDeclaration.js: -------------------------------------------------------------------------------- 1 | var postcss = require('postcss') 2 | 3 | module.exports = function () { 4 | return function (root) { 5 | root.eachRule(function (rule) { 6 | if (!rule.semicolon) { 7 | console.warn('need semicolon in last declaration') 8 | } 9 | }) 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rules/requireSpaceBetweenSelectorsAndDeclarationEndBlock.js: -------------------------------------------------------------------------------- 1 | var postcss = require('postcss') 2 | 3 | module.exports = function () { 4 | return function (root) { 5 | root.eachRule(function (rule) { 6 | if (after !== '\n') { 7 | console.warn('need new line between last declaration and }') 8 | } 9 | }) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /rules/requireSpaceBetweenSelectorsAndDeclarationStartBlock.js: -------------------------------------------------------------------------------- 1 | var postcss = require('postcss') 2 | 3 | module.exports = function () { 4 | return function (root) { 5 | root.eachRule(function (rule) { 6 | var betweenCount = rule.between.length 7 | if (betweenCount === 0) { 8 | console.warn('need space between selector and {') 9 | } 10 | }) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | var test = require('tape') 2 | var csscs = require('..') 3 | 4 | test('description', function (t) { 5 | t.end() 6 | }) 7 | --------------------------------------------------------------------------------