From 5ce6292f4c806ac6ae3370e331f589e823ddb321 Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Sun, 30 Nov 2014 16:20:19 +0700 Subject: [PATCH] Don't lint pseudo-selectors in SelectorFormat The SelectorFormat linter shouldn't lint pseudo-selectors since these must always use a hyphenated lowercase convention. Change-Id: I1b3f65a8017d69c5f984b7721f626c9c27348e75 Reviewed-on: http://gerrit.causes.com/44887 Tested-by: jenkins Reviewed-by: Shane da Silva --- CHANGELOG.md | 2 + lib/scss_lint/linter/README.md | 3 +- lib/scss_lint/linter/selector_format.rb | 4 -- spec/scss_lint/linter/selector_format_spec.rb | 69 +------------------ 4 files changed, 6 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 996db39e..4c9ddb97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ * Fix `DuplicateProperty` not reporting duplicate properties in nested rule sets * Fix `TrailingSemicolon` handling of comma-separated `@import`s +* Fix `SelectorFormat` to not allow format of pseudo-selectors to be defined, + as they are always hyphenated lowercase ## 0.30.0 diff --git a/lib/scss_lint/linter/README.md b/lib/scss_lint/linter/README.md index 9d4284b6..8abca4d6 100644 --- a/lib/scss_lint/linter/README.md +++ b/lib/scss_lint/linter/README.md @@ -883,12 +883,11 @@ Configuration Option | Description -------------------------|----------------------------------------------------- `convention` | Name of convention to use (`hyphenated_lowercase` (default) or `snake_case`, `camel_case`, or `BEM`, or `hyphenated_BEM`), or a regex the name must match `ignored_names` | Array of whitelisted names to not report lints for. -`ignored_types` | Array containing list of types of selectors to ignore (valid values are `attribute`, `class`, `element`, `id`, `placeholder`, or `pseudo-selector`) +`ignored_types` | Array containing list of types of selectors to ignore (valid values are `attribute`, `class`, `element`, `id`, `placeholder`) `attribute_convention` | Convention for attribute selectors only. See the `convention` option for possible values. `class_convention` | Convention for class selectors only. See the `convention` option for possible values. `id_convention` | Convention for id selectors only. See the `convention` option for possible values. `placeholder_convention` | Convention for placeholder selectors only. See the `convention` option for possible values. -`pseudo_convention` | Convention for pseudo-selectors only. See the `convention` option for possible values. ## Shorthand diff --git a/lib/scss_lint/linter/selector_format.rb b/lib/scss_lint/linter/selector_format.rb index 76a856c4..cc9b397b 100644 --- a/lib/scss_lint/linter/selector_format.rb +++ b/lib/scss_lint/linter/selector_format.rb @@ -29,10 +29,6 @@ def visit_placeholder(placeholder) check(placeholder, 'placeholder') unless @ignored_types.include?('placeholder') end - def visit_pseudo(pseudo) - check(pseudo, 'pseudo') unless @ignored_types.include?('pseudo-selector') - end - private def check(node, type) diff --git a/spec/scss_lint/linter/selector_format_spec.rb b/spec/scss_lint/linter/selector_format_spec.rb index 7d8bf5eb..edf806b4 100644 --- a/spec/scss_lint/linter/selector_format_spec.rb +++ b/spec/scss_lint/linter/selector_format_spec.rb @@ -37,15 +37,6 @@ it { should_not report_lint } end - context 'when pseudo-selector has alphanumeric chars and is separated by hyphens' do - let(:css) { <<-CSS } - [foo-bar-77=text] { - } - CSS - - it { should_not report_lint } - end - context 'when selector has alphanumeric chars and is separated by underscores' do let(:css) { <<-CSS } .foo_bar { @@ -73,15 +64,6 @@ it { should report_lint line: 1 } end - context 'psuedo-selector has alphanumeric chars and is separated by underscores' do - let(:css) { <<-CSS } - :foo_bar { - } - CSS - - it { should report_lint line: 1 } - end - context 'when attribute has alphanumeric chars and is separated by underscores' do let(:css) { <<-CSS } [data_text] { @@ -121,7 +103,7 @@ it { should report_lint line: 1 } end - context 'when selector has is in camelCase' do + context 'when selector is in camelCase' do let(:css) { <<-CSS } .fooBar77 { } @@ -219,9 +201,9 @@ end end - context 'when ignored types is set to id, element, placeholder, pseudo-selector' do + context 'when ignored types is set to id, element, placeholder' do let(:linter_config) do - { 'ignored_types' => %w[id attribute element placeholder pseudo-selector] } + { 'ignored_types' => %w[id attribute element placeholder] } end context 'it ignores all invalid ids' do @@ -259,15 +241,6 @@ it { should_not report_lint } end - - context 'it ignores all invalid pseudo-selectors' do - let(:css) { <<-CSS } - :fooBar { - } - CSS - - it { should_not report_lint } - end end context 'when using a unique `id_convention`' do @@ -399,42 +372,6 @@ end end - context 'when using a unique `pseudo_convention`' do - let(:linter_config) do - { - 'convention' => 'camel_case', - 'pseudo_convention' => 'hyphenated-lowercase' - } - end - - context 'and actual pseudo is correct' do - let(:css) { <<-CSS } - :hyphenated-lowercase {} - #camelCase {} - CSS - - it { should_not report_lint } - end - - context 'and actual pseudo is incorrect' do - let(:css) { <<-CSS } - :camelCase {} - #camelCase {} - CSS - - it { should report_lint line: 1 } - end - - context 'and something else uses the `pseudo_convention`' do - let(:css) { <<-CSS } - :hyphenated-lowercase {} - #hyphenated-lowercase {} - CSS - - it { should report_lint line: 2 } - end - end - context 'when using a unique `attribute_convention`' do let(:linter_config) do {