Skip to content

Commit

Permalink
various hotfixes for edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross committed May 16, 2015
1 parent 430ae5c commit 09d0711
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ npm-debug.log
node_modules
coverage
lcov.info
wired-styl
33 changes: 18 additions & 15 deletions .stylintrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
{
"borderNone": true,
"brackets": false,
"colons": false,
"colors": false,
"brackets": true,
"colons": true,
"colors": true,
"commaSpace": true,
"commentSpace": false,
"cssLiteral": false,
"depthLimit": false,
"commentSpace": true,
"cssLiteral": true,
"depthLimit": 5,
"duplicates": true,
"efficient": true,
"enforceBlockStyle": false,
"enforceVarStyle": false,
"extendPref": false,
"emoji": true,
"enforceBlockStyle": true,
"enforceVarStyle": true,
"extendPref": "@extends",
"globalDupe": false,
"indentSpaces": 4,
"leadingZero": true,
"maxWarnings": 10,
"maxWarningsKill": false,
"mixed": false,
"namingConvention": false,
"parenSpace": false,
"mixed": true,
"namingConvention": "lowercase-dash",
"namingConventionStrict": true,
"parenSpace": true,
"placeholders": true,
"quotePref": "single",
"semicolons": false,
"sortorder": [ "margin", "padding", "float", "position" ],
"universal": true,
"semicolons": true,
"sortOrder": "alphabetical",
"stackedProperties": true,
"universal": false,
"valid": true,
"whitespace": true,
"zeroUnits": true,
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylint",
"version": "0.9.8",
"version": "0.9.9",
"description": "A linter for stylus",
"author": "Ross Patton",
"license": "ISC",
Expand Down Expand Up @@ -31,12 +31,9 @@
"preferGlobal": true,
"devDependencies": {
"chai": "1.10.0",
"chokidar": "1.0.1",
"istanbul": "0.3.5",
"glob": "4.3.1",
"mocha": "2.0.1",
"sinon": "1.12.2",
"stampit": "1.1.0"
"sinon": "1.12.2"
},
"dependencies": {
"chokidar": "1.0.1",
Expand Down
9 changes: 9 additions & 0 deletions patch-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
##### 0.9.9
make universal less greedy

minor bug fix, some valid properties coming up as non-valid: https://github.com/rossPatton/stylint/issues/100

duplicates was reporting false positives if sortOrder also on. this has been fixed in the 1.0 branch but wasn't brought over

nesting / depthlimit check was counting extra white space between properties and value. technically, that's bad practice but it should be a separate check so lets remove that from the check: https://github.com/rossPatton/stylint/issues/101

##### 0.9.8
minor bug fix: some valid properties (anything with -bottom) were coming up as non-valid.

Expand Down
13 changes: 8 additions & 5 deletions src/checks/nesting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// conditions in which we want to decrement the count
var decrementRe = /^(\&\:)/;


/**
* check nesting depth
* @param {string} line the line being tested
Expand All @@ -20,12 +21,14 @@ module.exports = function checkNesting( line, arr, limit, indentSpaces ) {
}

var count = 0,
index = 0;
index = 0,
indents = line.search(/\S/);

if ( indents === -1 ) {
return;
}

// get all single spaces in the line
arr = arr.filter(function( str ) {
return str.length === 0;
});
arr = line.slice( 0, indents );

// trim string and check if line starts with &:,
// if true then subtract one from count (for indents) and add one to limit (for spaces)
Expand Down
11 changes: 6 additions & 5 deletions src/checks/sortOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ module.exports = function checkSortOrder( line, valid, sortOrder ) {
indentCount = 0,
currContext = 0,
isItSorted = false,
textIndex = 0,
sortedArr = [],
validCSS = false;

// quick and dirty fixes for now, didnt' account for hard tabs for context check
// this just gets the number of indents so we don't throw false positives
if ( typeof this.config.indentSpaces !== 'number' ) {
while ( line.charAt( textIndex++ ) === '\t' ) {
currContext++;
}
arr.forEach(function( val, i ) {
if ( arr[i] === '\t' ) {
currContext++;
}
});
}
else {
arr.forEach(function( val, i ) {
if ( arr[i].length === 0 ) {
indentCount++; // spaces or tabs
indentCount++;
}
else {
currContext = indentCount / this.config.indentSpaces;
Expand Down
2 changes: 1 addition & 1 deletion src/checks/universal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var universalRe = /(\s|\w|\d)(\*)(\s|\w|\d|\$|\=)/;
var universalRe = /( |\w|\d|'|"|\*)(\*)( |\w|\d|'|"|\*|\$|\=)/;

/**
* check for * selector.
Expand Down
2 changes: 1 addition & 1 deletion src/checks/valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function checkForValidProperties( line, valid ) {
}

if ( !this.state.keyframes ) {
if ( line.match(/((from)|(to))(?= |\n|{)+/) ) {
if ( line.match(/((from)|(to))(?=( |{| {)$|\n)+/) ) {
return false;
}
}
Expand Down
10 changes: 10 additions & 0 deletions styl/nesting.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.a
display: block;
.b
display: block;


.a
display: block;
.b
display: block;
33 changes: 17 additions & 16 deletions styl/testKeyframes.styl
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
@keyframes
0%
margin 0
100%
margin 50px
0%
margin 0
100%
margin 50px

@keyframes
from
margin 0
to
margin 50px
from
margin 0
to
margin 50px


.test
border-bottom 0
border-bottom 0

.test2
border-top 0
border-top 0

.marg-big
margin 50px
margin 50px

.marg-none
margin 0px
margin 0px

from
0
to
0
from
0
to
0
68 changes: 68 additions & 0 deletions styl/universal.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@require '../singles/**/*'
@require '*'

*::selection
background blue

div *
text-transform uppercase

.margin
margin unit( 5 * 5, 'px' )

.padding
padding unit( 5*5, 'px' )

/**
* styl/style.styl -> css/style.css
*
*/


// nibbles
@require 'nib/overflow' // handy aliases
@require 'nib/positions' // handy aliases
@require 'nib/reset' // reset and normalize
@require 'nib/size' // handy aliases

@require '../core/_vars'
@require '../core/_extends'
@require '../core/_mixins'
@require '../core/_base'
@require '../core/_type'
@require '../core/_cards'
@require '../core/_footer'

// ads and consumer marketing
@require '../ads/**/*'

// flexbox spec
@require '../grid/**/*'

// global header
@require '../header/**/*'

// our many helper classes (hide / show, padding/margin, etc)
@require '../helpers/**/*'

// grids (home, sections, tags, etc)
@require '../sections/**/*'

// styles for articles, post-header is inlined
@require '../singles/**/*'

// search page styles, legacy posts, etc
@require '../misc/_search'
@require '../misc/_wp'

// navigation
@require '../navigation/**/*'

// our ui elements
@require '../ui/_icons'
@require '../ui/_ui-base'
@require '../ui/_ui-relative'
@require '../ui/_ui-misc'
@require '../ui/_ui-reviews'
@require '../ui/_ui-singles'
@require '../ui/_ui-social'

0 comments on commit 09d0711

Please sign in to comment.