Skip to content

Commit

Permalink
Merge pull request #613 from sasstools/revert-604-feature/bem-convention
Browse files Browse the repository at this point in the history
Revert "Add BEM conventions for all naming rules #598"
  • Loading branch information
DanPurdy committed Apr 17, 2016
2 parents 4beda5a + 00a894e commit ee59893
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 762 deletions.
9 changes: 8 additions & 1 deletion bin/sass-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ var configPath,
configOptions = {},
exitCode = 0;

var tooManyWarnings = function (detects) {
var warningCount = lint.warningCount(detects).count;

return warningCount > 0 && warningCount > program.maxWarnings;
};

var detectPattern = function (pattern) {
var detects;

Expand All @@ -19,7 +25,7 @@ var detectPattern = function (pattern) {
lint.outputResults(detects, configOptions, configPath);
}

if (lint.errorCount(detects).count) {
if (lint.errorCount(detects).count || tooManyWarnings(detects)) {
exitCode = 1;
}

Expand All @@ -38,6 +44,7 @@ program
.option('-f, --format [format]', 'pass one of the available eslint formats')
.option('-o, --output [output]', 'the path and filename where you would like output to be written')
.option('-s, --syntax [syntax]', 'syntax to evaluate the file(s) with (either sass or scss)')
.option('--max-warnings [integer]', 'Number of warnings to trigger nonzero exit code')
.parse(process.argv);


Expand Down
1 change: 1 addition & 0 deletions docs/cli/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Command Line Flag | Description
`-f`,`--format [format]` | Pass one of the available [Eslint formats](https://github.com/eslint/eslint/tree/master/lib/formatters) to format the output of sass-lint results.
`-h`,`--help` | Outputs usage information for the CLI
`-i`,`--ignore [pattern]` | A pattern that should be ignored from linting. Multiple patterns can be used by separating each pattern by `, `. Patterns should be wrapped in quotes (will be merged with other ignore options)
`--max-warnings [integer]`| Normally, if SassLint runs and finds no errors (only warnings), it will exit with a success exit status. However, if this option is specified and the total warning count is greater than the specified threshold, SassLint will exit with an error status.
`-o`,`--output [output]` | The path plus file name relative to where Sass Lint is being run from where the output should be written to.
`-q`,`--no-exit` | Prevents the CLI from throwing an error if there is one (useful for development work)
`-s`,`--syntax` | Syntax to evaluate the given file(s) with, either sass or scss. Use with care: overrides filename extension-based syntax detection.
Expand Down
69 changes: 1 addition & 68 deletions docs/rules/function-name-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Rule `function-name-format` will enforce a convention for function names.
## Options

* `allow-leading-underscore`: `true`/`false` (defaults to `true`)
* `convention`: `'hyphenatedlowercase'` (default), `camelcase`, `snakecase`, [`strictbem`](https://en.bem.info/method/definitions/),
[`hyphenatedbem`](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/), or a Regular Expression that the function name must match (e.g. `^[_A-Z]+$`)
* `convention`: `'hyphenatedlowercase'` (default), `camelcase`, `snakecase`, or a Regular Expression that the function name must match (e.g. `^[_A-Z]+$`)
* `convention-explanation`: Custom explanation to display to the user if a function doesn't adhere to the convention

## Example 1
Expand Down Expand Up @@ -117,72 +116,6 @@ When enabled, the following are disallowed:

## Example 4

Settings:
- `convention: strictbem`

When enabled, the following are allowed:

```scss
@function namespace__function {
@return "foo";
}

@function namespace__function_mod-name {
@return "foo";
}

@function namespace_mod-name__function {
@return "foo";
}
```

When enabled, the following are disallowed:

```scss
@function HYPHENATED-UPPERCASE {
@return "foo";
}

.foo {
content: camelCase();
}
```

## Example 5

Settings:
- `convention: hyphenatedbem`

When enabled, the following are allowed:

```scss
@function namespace__function {
@return "foo";
}

@function namespace__function--mod-name {
@return "foo";
}

@function namespace--mod-name__function {
@return "foo";
}
```

When enabled, the following are disallowed:

```scss
@function HYPHENATED-UPPERCASE {
@return "foo";
}

.foo {
content: camelCase();
}
```

## Example 6

Settings:
- `allow-leading-underscore: true`
- `convention: '^[_A-Z]+$'`
Expand Down
70 changes: 1 addition & 69 deletions docs/rules/mixin-name-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Rule `mixin-name-format` will enforce a convention for mixin names.
## Options

* `allow-leading-underscore`: `true`/`false` (defaults to `true`)
* `convention`: `'hyphenatedlowercase'` (default), `camelcase`, `snakecase`, [`strictbem`](https://en.bem.info/method/definitions/),
[`hyphenatedbem`](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/), or a Regular Expression that the variable name must match (e.g. `^[_A-Z]+$`)
* `convention`: `'hyphenatedlowercase'` (default), `camelcase`, `snakecase`, or a Regular Expression that the variable name must match (e.g. `^[_A-Z]+$`)
* `convention-explanation`: Custom explanation to display to the user if a mixin doesn't adhere to the convention

## Example 1
Expand Down Expand Up @@ -118,73 +117,6 @@ When enabled, the following are disallowed:

## Example 4

Settings:
- `convention: strictbem`

When enabled, the following are allowed:

```scss
@mixin block-name {
content: '';
}

@mixin block-name__mixin {
content: '';
}

@mixin block-name_mod-name {
content: '';
}
```

When enabled, the following are disallowed:

```scss
@mixin HYPHENATED-UPPERCASE {
content: '';
}

.foo {
@include camelCase();
}
```

## Example 5

Settings:
- `convention: hyphenatedbem`

When enabled, the following are allowed:

```scss
@mixin block-name {
content: '';
}

@mixin block-name__mixin {
content: '';
}

@mixin block-name--mod-name {
content: '';
}
```

When enabled, the following are disallowed:

```scss
@mixin HYPHENATED-UPPERCASE {
content: '';
}

.foo {
@include camelCase();
}
```


## Example 6

Settings:
- `allow-leading-underscore: true`
- `convention: ^[_A-Z]+$`
Expand Down
69 changes: 1 addition & 68 deletions docs/rules/placeholder-name-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Rule `placeholder-name-format` will enforce a convention for placeholder names.
## Options

* `allow-leading-underscore`: `true`/`false` (defaults to `true`)
* `convention`: `'hyphenatedlowercase'` (default), `camelcase`, `snakecase`, [`strictbem`](https://en.bem.info/method/definitions/),
[`hyphenatedbem`](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/), or a Regular Expression that the variable name must match (e.g. `^[_A-Z]+$`)
* `convention`: `'hyphenatedlowercase'` (default), `camelcase`, `snakecase`, or a Regular Expression that the variable name must match (e.g. `^[_A-Z]+$`)
* `convention-explanation`: Custom explanation to display to the user if a placeholder doesn't adhere to the convention

## Example 1
Expand Down Expand Up @@ -118,72 +117,6 @@ When enabled, the following are disallowed:

## Example 4

Settings:
- `convention: strictbem`

When enabled, the following are allowed:

```scss
%block-name {
content: '';
}

%block-name__mixin {
content: '';
}

%block-name_mod-name {
content: '';
}
```

When enabled, the following are disallowed:

```scss
%HYPHENATED-UPPERCASE {
content: '';
}

.foo {
@extend %camelCase;
}
```

## Example 5

Settings:
- `convention: hyphenatedbem`

When enabled, the following are allowed:

```scss
%block-name {
content: '';
}

%block-name__mixin {
content: '';
}

%block-name--mod-name {
content: '';
}
```

When enabled, the following are disallowed:

```scss
%HYPHENATED-UPPERCASE {
content: '';
}

.foo {
@extend %camelCase;
}
```

## Example 6

Settings:
- `allow-leading-underscore: true`
- `convention: ^[_A-Z]+$`
Expand Down
57 changes: 1 addition & 56 deletions docs/rules/variable-name-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Rule `variable-name-format` will enforce a convention for variable names.
## Options

* `allow-leading-underscore`: `true`/`false` (defaults to `true`)
* `convention`: `'hyphenatedlowercase'` (default), `camelcase`, `snakecase`, [`strictbem`](https://en.bem.info/method/definitions/),
[`hyphenatedbem`](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/), or a Regular Expression that the variable name must match (e.g. `^[_A-Z]+$`)
* `convention`: `'hyphenatedlowercase'` (default), `camelcase`, `snakecase`, or a Regular Expression that the variable name must match (e.g. `^[_A-Z]+$`)
* `convention-explanation`: Custom explanation to display to the user if a variable doesn't adhere to the convention

## Example 1
Expand Down Expand Up @@ -94,60 +93,6 @@ $_snake_case_with_leading_underscore: 1px;

## Example 4

Settings:
- `convention: strictbem`

When enabled, the following are allowed:

```scss
$block-name__variable: 1px;
$block-name__variable_mod-name: 1px;
$block-name_mod-name__variable: 1px;

.foo {
width: $block-name__variable;
}
```

When enabled, the following are disallowed:

```scss
$HYPHENATED-UPPERCASE: 1px;

.foo {
width: $camelCase;
}
```

## Example 5

Settings:
- `convention: hyphenatedbem`

When enabled, the following are allowed:

```scss
$block-name__variable: 1px;
$block-name__variable--mod-name: 1px;
$block-name--mod-name__variable: 1px;

.foo {
width: $block-name__variable;
}
```

When enabled, the following are disallowed:

```scss
$HYPHENATED-UPPERCASE: 1px;

.foo {
width: $camelCase;
}
```

## Example 6

Settings:
- `allow-leading-underscore: true`
- `convention: ^[_A-Z]+$`
Expand Down
10 changes: 0 additions & 10 deletions lib/rules/function-name-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ module.exports = {
violationMessage = 'Function \'' + name + '\' should be written in snake_case';
}
break;
case 'strictbem':
if (!helpers.isStrictBEM(strippedName)) {
violationMessage = 'Function \'.' + name + '\' should be written in BEM (Block Element Modifier) format';
}
break;
case 'hyphenatedbem':
if (!helpers.isHyphenatedBEM(strippedName)) {
violationMessage = 'Function \'.' + name + '\' should be written in hyphenated BEM (Block Element Modifier) format';
}
break;
default:
if (!(new RegExp(parser.options.convention).test(strippedName))) {
violationMessage = 'Function \'' + name + '\' should match regular expression /' + parser.options.convention + '/';
Expand Down
10 changes: 0 additions & 10 deletions lib/rules/mixin-name-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ module.exports = {
violationMessage = 'Mixin \'' + name + '\' should be written in snake_case';
}
break;
case 'strictbem':
if (!helpers.isStrictBEM(strippedName)) {
violationMessage = 'Mixin \'.' + name + '\' should be written in BEM (Block Element Modifier) format';
}
break;
case 'hyphenatedbem':
if (!helpers.isHyphenatedBEM(strippedName)) {
violationMessage = 'Mixin \'.' + name + '\' should be written in hyphenated BEM (Block Element Modifier) format';
}
break;
default:
if (!(new RegExp(parser.options.convention).test(strippedName))) {
violationMessage = 'Mixin \'' + name + '\' should match regular expression /' + parser.options.convention + '/';
Expand Down
Loading

0 comments on commit ee59893

Please sign in to comment.