-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
добавил настройки отключения валидации #3
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,21 @@ var bemNaming = require('bem-naming'), | |
* | ||
* @constructor | ||
* @this {CssNaming} | ||
* @param {string[]} excludes - Исключения для проверки соответствия названий классов БЭМ-нотации | ||
* @param {Object} options - Настройки валидации | ||
* @param {String[]} [options.excludes] - Исключения для проверки соответствия названий классов БЭМ-нотации | ||
* @param {Boolean} [options.requireBlockClass] - Проверять наличие класса блока в селекторе | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тож с маленькой |
||
* @param {Boolean} [options.requireBemNaming] - Проверять соответствие названий классов БЭМ-нотации | ||
* @param {CssNaming~errorCallback} errCallback - Обработчик ошибок | ||
*/ | ||
function CssNaming(excludes, errCallback) { | ||
this._excludeRegexp = excludes && this._buildExcludeRegexp(excludes); | ||
function CssNaming(options, errCallback) { | ||
!options && (options = {}); | ||
|
||
!options.hasOwnProperty('requireBlockClass') && (options.requireBlockClass = true); | ||
!options.hasOwnProperty('requireBemNaming') && (options.requireBemNaming = true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. лучше не начинать с отрицания, а использовать || тут и выше options.hasOwnProperty('requireBemNaming') || (options.requireBemNaming = true); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ну и так как опция не используется далее, можно все это сразу ниже в присваивании делать, но то такое, чисто дело вкуса |
||
|
||
this._requireBlockClass = options.requireBlockClass; | ||
this._requireBemNaming = options.requireBemNaming; | ||
this._excludeRegexp = options.excludes && this._buildExcludeRegexp(options.excludes); | ||
this._errCallback = errCallback; | ||
}; | ||
|
||
|
@@ -80,7 +90,7 @@ CssNaming.prototype = { | |
hasTargetBlock |= _this._validateClass(cssClass, blockName, rule); | ||
}); | ||
|
||
hasTargetBlock || _this._errCallback( | ||
!hasTargetBlock && _this._requireBlockClass && _this._errCallback( | ||
'Selector does not contain block name specified in the file name', | ||
rule.selector, | ||
ruleStart.line, | ||
|
@@ -107,7 +117,7 @@ CssNaming.prototype = { | |
if (cssEntity) { | ||
return cssEntity.block === blockName; | ||
} else { | ||
this._errCallback('Invalid class naming', rule.selector, errorLine, cssClassStart.column); | ||
this._requireBemNaming && this._errCallback('Invalid class naming', rule.selector, errorLine, cssClassStart.column); | ||
} | ||
|
||
return false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это примитив, с маленькой буквы