From 81aa8331a6c37af8d5e0ffe85969ec167e1e329a Mon Sep 17 00:00:00 2001 From: rodoabad Date: Sun, 3 Apr 2016 18:02:10 -0500 Subject: [PATCH] feat: each individual rule file inside the library folder can now be loaded individually --- index.js | 52 ++++++++++---------- lib/at-rule.js | 22 +++++---- lib/block.js | 22 +++++---- lib/color.js | 12 +++-- lib/comment.js | 6 ++- lib/custom-media.js | 4 +- lib/custom-property.js | 6 ++- lib/declaration-block.js | 102 ++++++++++++++++++++------------------- lib/declaration.js | 14 +++--- lib/font-family.js | 4 +- lib/font-weight.js | 4 +- lib/function.js | 26 +++++----- lib/general.js | 48 +++++++++--------- lib/media-feature.js | 14 +++--- lib/media-query-list.js | 10 ++-- lib/media-query.js | 4 +- lib/number.js | 10 ++-- lib/property.js | 16 +++--- lib/root-rule.js | 4 +- lib/rule.js | 6 ++- lib/selector-list.js | 10 ++-- lib/selector.js | 30 ++++++------ lib/string.js | 6 ++- lib/time.js | 4 +- lib/unit.js | 6 ++- lib/value-list.js | 10 ++-- lib/value.js | 4 +- 27 files changed, 254 insertions(+), 202 deletions(-) diff --git a/index.js b/index.js index d2d1a65..7b193e8 100644 --- a/index.js +++ b/index.js @@ -28,32 +28,32 @@ const valueListRules = require('./lib/value-list'); const rules = { rules: Object.assign( {}, - atRuleRules, - blockRules, - colorRules, - commentRules, - customMediaRules, - customPropertyRules, - declarationRules, - declarationBlockRules, - fontFamilyRules, - fontWeightRules, - functionRules, - generalRules, - mediaFeatureRules, - mediaQueryRules, - mediaQueryListRules, - numberRules, - propertyRules, - rootRuleRules, - ruleRules, - selectorRules, - selectorListRules, - stringRules, - timeRules, - unitRules, - valueRules, - valueListRules + atRuleRules.rules, + blockRules.rules, + colorRules.rules, + commentRules.rules, + customMediaRules.rules, + customPropertyRules.rules, + declarationRules.rules, + declarationBlockRules.rules, + fontFamilyRules.rules, + fontWeightRules.rules, + functionRules.rules, + generalRules.rules, + mediaFeatureRules.rules, + mediaQueryRules.rules, + mediaQueryListRules.rules, + numberRules.rules, + propertyRules.rules, + rootRuleRules.rules, + ruleRules.rules, + selectorRules.rules, + selectorListRules.rules, + stringRules.rules, + timeRules.rules, + unitRules.rules, + valueRules.rules, + valueListRules.rules ) }; diff --git a/lib/at-rule.js b/lib/at-rule.js index 0619623..8d84c0a 100644 --- a/lib/at-rule.js +++ b/lib/at-rule.js @@ -1,12 +1,14 @@ module.exports = { - 'at-rule-empty-line-before': [ - 'always', - { - except: [ - 'blockless-group' - ] - } - ], - 'at-rule-no-vendor-prefix': true, - 'at-rule-semicolon-newline-after': 'always' + rules: { + 'at-rule-empty-line-before': [ + 'always', + { + except: [ + 'blockless-group' + ] + } + ], + 'at-rule-no-vendor-prefix': true, + 'at-rule-semicolon-newline-after': 'always' + } }; diff --git a/lib/block.js b/lib/block.js index e1eee58..b5a8e66 100644 --- a/lib/block.js +++ b/lib/block.js @@ -1,12 +1,14 @@ module.exports = { - 'block-closing-brace-newline-after': 'always', - 'block-closing-brace-newline-before': 'always', - 'block-closing-brace-space-after': 'always-single-line', - 'block-closing-brace-space-before': 'always-single-line', - 'block-no-empty': true, - 'block-no-single-line': true, - 'block-opening-brace-newline-after': 'always', - 'block-opening-brace-newline-before': null, - 'block-opening-brace-space-after': 'always-single-line', - 'block-opening-brace-space-before': 'always' + rules: { + 'block-closing-brace-newline-after': 'always', + 'block-closing-brace-newline-before': 'always', + 'block-closing-brace-space-after': 'always-single-line', + 'block-closing-brace-space-before': 'always-single-line', + 'block-no-empty': true, + 'block-no-single-line': true, + 'block-opening-brace-newline-after': 'always', + 'block-opening-brace-newline-before': null, + 'block-opening-brace-space-after': 'always-single-line', + 'block-opening-brace-space-before': 'always' + } }; diff --git a/lib/color.js b/lib/color.js index a6b9208..a0d1840 100644 --- a/lib/color.js +++ b/lib/color.js @@ -1,7 +1,9 @@ module.exports = { - 'color-hex-case': 'lower', - 'color-hex-length': 'short', - 'color-named': 'always-where-possible', - 'color-no-hex': null, - 'color-no-invalid-hex': true + rules: { + 'color-hex-case': 'lower', + 'color-hex-length': 'short', + 'color-named': 'always-where-possible', + 'color-no-hex': null, + 'color-no-invalid-hex': true + } }; diff --git a/lib/comment.js b/lib/comment.js index e365883..31f8727 100644 --- a/lib/comment.js +++ b/lib/comment.js @@ -1,4 +1,6 @@ module.exports = { - 'comment-empty-line-before': 'always', - 'comment-whitespace-inside': 'always' + rules: { + 'comment-empty-line-before': 'always', + 'comment-whitespace-inside': 'always' + } }; diff --git a/lib/custom-media.js b/lib/custom-media.js index 4e66560..a0baf66 100644 --- a/lib/custom-media.js +++ b/lib/custom-media.js @@ -1,3 +1,5 @@ module.exports = { - 'custom-media-pattern': /^([a-z]+-+?)*([a-z]+)$/ + rules: { + 'custom-media-pattern': /^([a-z]+-+?)*([a-z]+)$/ + } }; diff --git a/lib/custom-property.js b/lib/custom-property.js index d6bfc3b..7fc1933 100644 --- a/lib/custom-property.js +++ b/lib/custom-property.js @@ -1,4 +1,6 @@ module.exports = { - 'custom-property-no-outside-root': true, - 'custom-property-pattern': /^.([a-z](-[a-z])?)+(__([a-z](-[a-z])?)+)?(--([a-z](-[a-z])?)+)?$/ + rules: { + 'custom-property-no-outside-root': true, + 'custom-property-pattern': /^.([a-z](-[a-z])?)+(__([a-z](-[a-z])?)+)?(--([a-z](-[a-z])?)+)?$/ + } }; diff --git a/lib/declaration-block.js b/lib/declaration-block.js index 1212311..ac3b999 100644 --- a/lib/declaration-block.js +++ b/lib/declaration-block.js @@ -1,55 +1,57 @@ module.exports = { - 'declaration-block-no-duplicate-properties': true, - 'declaration-block-no-shorthand-property-overrides': true, - 'declaration-block-properties-order': [ - [ + rules: { + 'declaration-block-no-duplicate-properties': true, + 'declaration-block-no-shorthand-property-overrides': true, + 'declaration-block-properties-order': [ + [ + { + order: 'strict', + emptyLineBefore: 'always', + properties: [ + 'color', + 'background' + ] + }, + { + order: 'strict', + emptyLineBefore: 'always', + properties: [ + 'top', + 'right', + 'bottom', + 'left' + ] + }, + { + order: 'strict', + emptyLineBefore: 'always', + properties: [ + 'margin-top', + 'margin-right', + 'margin-bottom', + 'margin-left' + ] + }, + { + order: 'strict', + emptyLineBefore: 'always', + properties: [ + 'padding-top', + 'padding-right', + 'padding-bottom', + 'padding-left' + ] + } + ], { - order: 'strict', - emptyLineBefore: 'always', - properties: [ - 'color', - 'background' - ] - }, - { - order: 'strict', - emptyLineBefore: 'always', - properties: [ - 'top', - 'right', - 'bottom', - 'left' - ] - }, - { - order: 'strict', - emptyLineBefore: 'always', - properties: [ - 'margin-top', - 'margin-right', - 'margin-bottom', - 'margin-left' - ] - }, - { - order: 'strict', - emptyLineBefore: 'always', - properties: [ - 'padding-top', - 'padding-right', - 'padding-bottom', - 'padding-left' - ] + unspecified: 'bottomAlphabetical' } ], - { - unspecified: 'bottomAlphabetical' - } - ], - 'declaration-block-semicolon-newline-after': 'always', - 'declaration-block-semicolon-newline-before': 'never-multi-line', - 'declaration-block-semicolon-space-after': 'always-single-line', - 'declaration-block-semicolon-space-before': 'never', - 'declaration-block-single-line-max-declarations': 1, - 'declaration-block-trailing-semicolon': 'always' + 'declaration-block-semicolon-newline-after': 'always', + 'declaration-block-semicolon-newline-before': 'never-multi-line', + 'declaration-block-semicolon-space-after': 'always-single-line', + 'declaration-block-semicolon-space-before': 'never', + 'declaration-block-single-line-max-declarations': 1, + 'declaration-block-trailing-semicolon': 'always' + } }; diff --git a/lib/declaration.js b/lib/declaration.js index d36250c..6f2f2ee 100644 --- a/lib/declaration.js +++ b/lib/declaration.js @@ -1,8 +1,10 @@ module.exports = { - 'declaration-bang-space-after': 'never', - 'declaration-bang-space-before': 'always', - 'declaration-colon-newline-after': null, - 'declaration-colon-space-after': 'always-single-line', - 'declaration-colon-space-before': 'never', - 'declaration-no-important': true + rules: { + 'declaration-bang-space-after': 'never', + 'declaration-bang-space-before': 'always', + 'declaration-colon-newline-after': null, + 'declaration-colon-space-after': 'always-single-line', + 'declaration-colon-space-before': 'never', + 'declaration-no-important': true + } }; diff --git a/lib/font-family.js b/lib/font-family.js index bef62b1..4bfd5aa 100644 --- a/lib/font-family.js +++ b/lib/font-family.js @@ -1,3 +1,5 @@ module.exports = { - 'font-family-name-quotes': 'single-unless-keyword' + rules: { + 'font-family-name-quotes': 'single-unless-keyword' + } }; diff --git a/lib/font-weight.js b/lib/font-weight.js index c94a347..97b5003 100644 --- a/lib/font-weight.js +++ b/lib/font-weight.js @@ -1,3 +1,5 @@ module.exports = { - 'font-weight-notation': 'named-where-possible' + rules: { + 'font-weight-notation': 'named-where-possible' + } }; diff --git a/lib/function.js b/lib/function.js index 04fe72c..e6cd809 100644 --- a/lib/function.js +++ b/lib/function.js @@ -1,14 +1,16 @@ module.exports = { - 'function-blacklist': null, - 'function-calc-no-unspaced-operator': true, - 'function-comma-newline-after': 'always-multi-line', - 'function-comma-newline-before': 'never-multi-line', - 'function-comma-space-after': 'always-single-line', - 'function-comma-space-before': 'never-single-line', - 'function-linear-gradient-no-nonstandard-direction': true, - 'function-parentheses-newline-inside': 'always-multi-line', - 'function-parentheses-space-inside': 'never-single-line', - 'function-url-quotes': 'single', - 'function-whitelist': null, - 'function-whitespace-after': 'always' + rules: { + 'function-blacklist': null, + 'function-calc-no-unspaced-operator': true, + 'function-comma-newline-after': 'always-multi-line', + 'function-comma-newline-before': 'never-multi-line', + 'function-comma-space-after': 'always-single-line', + 'function-comma-space-before': 'never-single-line', + 'function-linear-gradient-no-nonstandard-direction': true, + 'function-parentheses-newline-inside': 'always-multi-line', + 'function-parentheses-space-inside': 'never-single-line', + 'function-url-quotes': 'single', + 'function-whitelist': null, + 'function-whitespace-after': 'always' + } }; diff --git a/lib/general.js b/lib/general.js index 5edf310..cf262e7 100644 --- a/lib/general.js +++ b/lib/general.js @@ -1,25 +1,27 @@ module.exports = { - 'indentation': 4, - 'max-empty-lines': 1, - 'max-line-length': 120, - 'max-nesting-depth': 5, - 'no-browser-hacks': [ - true, - { - browsers: [ - '> 1%', - 'last 2 versions', - 'Firefox ESR' - ] - } - ], - 'no-descending-specificity': true, - 'no-duplicate-selectors': true, - 'no-eol-whitespace': true, - 'no-indistinguishable-colors': true, - 'no-invalid-double-slash-comments': true, - 'no-missing-eof-newline': true, - 'no-unknown-animations': true, - 'no-unsupported-browser-features': null, - 'stylelint-disable-reason': 'always-after' + rules: { + 'indentation': 4, + 'max-empty-lines': 1, + 'max-line-length': 120, + 'max-nesting-depth': 5, + 'no-browser-hacks': [ + true, + { + browsers: [ + '> 1%', + 'last 2 versions', + 'Firefox ESR' + ] + } + ], + 'no-descending-specificity': true, + 'no-duplicate-selectors': true, + 'no-eol-whitespace': true, + 'no-indistinguishable-colors': true, + 'no-invalid-double-slash-comments': true, + 'no-missing-eof-newline': true, + 'no-unknown-animations': true, + 'no-unsupported-browser-features': null, + 'stylelint-disable-reason': 'always-after' + } }; diff --git a/lib/media-feature.js b/lib/media-feature.js index b67a865..b2f7783 100644 --- a/lib/media-feature.js +++ b/lib/media-feature.js @@ -1,8 +1,10 @@ module.exports = { - 'media-feature-colon-space-after': 'always', - 'media-feature-colon-space-before': 'never', - 'media-feature-name-no-vendor-prefix': true, - 'media-feature-no-missing-punctuation': true, - 'media-feature-range-operator-space-after': 'always', - 'media-feature-range-operator-space-before': 'always' + rules: { + 'media-feature-colon-space-after': 'always', + 'media-feature-colon-space-before': 'never', + 'media-feature-name-no-vendor-prefix': true, + 'media-feature-no-missing-punctuation': true, + 'media-feature-range-operator-space-after': 'always', + 'media-feature-range-operator-space-before': 'always' + } }; diff --git a/lib/media-query-list.js b/lib/media-query-list.js index 0306902..e83fea7 100644 --- a/lib/media-query-list.js +++ b/lib/media-query-list.js @@ -1,6 +1,8 @@ module.exports = { - 'media-query-list-comma-newline-after': 'always-multi-line', - 'media-query-list-comma-newline-before': 'never-multi-line', - 'media-query-list-comma-space-after': 'always-single-line', - 'media-query-list-comma-space-before': 'never' + rules: { + 'media-query-list-comma-newline-after': 'always-multi-line', + 'media-query-list-comma-newline-before': 'never-multi-line', + 'media-query-list-comma-space-after': 'always-single-line', + 'media-query-list-comma-space-before': 'never' + } }; diff --git a/lib/media-query.js b/lib/media-query.js index 057068d..7e194e0 100644 --- a/lib/media-query.js +++ b/lib/media-query.js @@ -1,3 +1,5 @@ module.exports = { - 'media-query-parentheses-space-inside': 'never' + rules: { + 'media-query-parentheses-space-inside': 'never' + } }; diff --git a/lib/number.js b/lib/number.js index 38f78aa..6ded0d5 100644 --- a/lib/number.js +++ b/lib/number.js @@ -1,6 +1,8 @@ module.exports = { - 'number-leading-zero': 'always', - 'number-max-precision': 2, - 'number-no-trailing-zeros': true, - 'number-zero-length-no-unit': true + rules: { + 'number-leading-zero': 'always', + 'number-max-precision': 2, + 'number-no-trailing-zeros': true, + 'number-zero-length-no-unit': true + } }; diff --git a/lib/property.js b/lib/property.js index 2250524..f8b0440 100644 --- a/lib/property.js +++ b/lib/property.js @@ -1,9 +1,11 @@ module.exports = { - 'property-blacklist': null, - 'property-no-vendor-prefix': true, - 'property-unit-blacklist': null, - 'property-unit-whitelist': null, - 'property-value-blacklist': null, - 'property-value-whitelist': null, - 'property-whitelist': null + rules: { + 'property-blacklist': null, + 'property-no-vendor-prefix': true, + 'property-unit-blacklist': null, + 'property-unit-whitelist': null, + 'property-value-blacklist': null, + 'property-value-whitelist': null, + 'property-whitelist': null + } }; diff --git a/lib/root-rule.js b/lib/root-rule.js index b9d3954..284f351 100644 --- a/lib/root-rule.js +++ b/lib/root-rule.js @@ -1,3 +1,5 @@ module.exports = { - 'root-no-standard-properties': true + rules: { + 'root-no-standard-properties': true + } }; diff --git a/lib/rule.js b/lib/rule.js index 82d89ec..4c686d0 100644 --- a/lib/rule.js +++ b/lib/rule.js @@ -1,4 +1,6 @@ module.exports = { - 'rule-nested-empty-line-before': 'always', - 'rule-non-nested-empty-line-before': 'always' + rules: { + 'rule-nested-empty-line-before': 'always', + 'rule-non-nested-empty-line-before': 'always' + } }; diff --git a/lib/selector-list.js b/lib/selector-list.js index a1c8d43..95d0b55 100644 --- a/lib/selector-list.js +++ b/lib/selector-list.js @@ -1,6 +1,8 @@ module.exports = { - 'selector-list-comma-newline-after': 'always', - 'selector-list-comma-newline-before': 'never-multi-line', - 'selector-list-comma-space-after': 'always-single-line', - 'selector-list-comma-space-before': 'never' + rules: { + 'selector-list-comma-newline-after': 'always', + 'selector-list-comma-newline-before': 'never-multi-line', + 'selector-list-comma-space-after': 'always-single-line', + 'selector-list-comma-space-before': 'never' + } }; diff --git a/lib/selector.js b/lib/selector.js index a3b4bf5..4fd5446 100644 --- a/lib/selector.js +++ b/lib/selector.js @@ -1,16 +1,18 @@ module.exports = { - 'selector-class-pattern': /^.([a-z](-[a-z])?)+(__([a-z](-[a-z])?)+)?(--([a-z](-[a-z])?)+)?$/, - 'selector-combinator-space-after': 'always', - 'selector-combinator-space-before': 'always', - 'selector-id-pattern': null, - 'selector-max-specificity': '0,2,0', - 'selector-no-attribute': true, - 'selector-no-combinator': true, - 'selector-no-id': true, - 'selector-no-type': true, - 'selector-no-universal': true, - 'selector-no-vendor-prefix': true, - 'selector-pseudo-element-colon-notation': 'single', - 'selector-root-no-composition': true, - 'selector-type-case': 'lower' + rules: { + 'selector-class-pattern': /^.([a-z](-[a-z])?)+(__([a-z](-[a-z])?)+)?(--([a-z](-[a-z])?)+)?$/, + 'selector-combinator-space-after': 'always', + 'selector-combinator-space-before': 'always', + 'selector-id-pattern': null, + 'selector-max-specificity': '0,2,0', + 'selector-no-attribute': true, + 'selector-no-combinator': true, + 'selector-no-id': true, + 'selector-no-type': true, + 'selector-no-universal': true, + 'selector-no-vendor-prefix': true, + 'selector-pseudo-element-colon-notation': 'single', + 'selector-root-no-composition': true, + 'selector-type-case': 'lower' + } }; diff --git a/lib/string.js b/lib/string.js index 6fa7efd..dbd0676 100644 --- a/lib/string.js +++ b/lib/string.js @@ -1,4 +1,6 @@ module.exports = { - 'string-no-newline': true, - 'string-quotes': 'single' + rules: { + 'string-no-newline': true, + 'string-quotes': 'single' + } }; diff --git a/lib/time.js b/lib/time.js index 91aea0c..eef5b24 100644 --- a/lib/time.js +++ b/lib/time.js @@ -1,3 +1,5 @@ module.exports = { - 'time-no-imperceptible': true + rules: { + 'time-no-imperceptible': true + } }; diff --git a/lib/unit.js b/lib/unit.js index 24d00e1..3052968 100644 --- a/lib/unit.js +++ b/lib/unit.js @@ -1,4 +1,6 @@ module.exports = { - 'unit-blacklist': null, - 'unit-whitelist': null + rules: { + 'unit-blacklist': null, + 'unit-whitelist': null + } }; diff --git a/lib/value-list.js b/lib/value-list.js index 921b016..90d75b9 100644 --- a/lib/value-list.js +++ b/lib/value-list.js @@ -1,6 +1,8 @@ module.exports = { - 'value-list-comma-newline-after': 'always-multi-line', - 'value-list-comma-newline-before': 'never-multi-line', - 'value-list-comma-space-after': 'always-single-line', - 'value-list-comma-space-before': 'never-single-line' + rules: { + 'value-list-comma-newline-after': 'always-multi-line', + 'value-list-comma-newline-before': 'never-multi-line', + 'value-list-comma-space-after': 'always-single-line', + 'value-list-comma-space-before': 'never-single-line' + } }; diff --git a/lib/value.js b/lib/value.js index 2cc3e93..a7704d7 100644 --- a/lib/value.js +++ b/lib/value.js @@ -1,3 +1,5 @@ module.exports = { - 'value-no-vendor-prefix': true + rules: { + 'value-no-vendor-prefix': true + } };