Skip to content

Instantly share code, notes, and snippets.

@a-x-
Last active August 4, 2016 19:22
Show Gist options
  • Select an option

  • Save a-x-/2a5b541198c9f66c3413f1305d122e7f to your computer and use it in GitHub Desktop.

Select an option

Save a-x-/2a5b541198c9f66c3413f1305d122e7f to your computer and use it in GitHub Desktop.
jshint configs
// Шаблоны для поиска файлов определённой технологии.
// Используется для includes/excludes в jshint-groups.
var files = {
all: [
'**/*.i18n/*.js'
],
bemdecl: [
'pages-*/**/common.bemdecl.js'
],
testPriv: [
'common/test/mocha.helper.js',
'*/blocks*/**/*.test-priv.js'
],
priv: [
'*/blocks*/**/*.priv.js',
'configs/**/*.priv.js'
],
bemhtml: ['*/blocks*/**/*.bemhtml.js'],
test: ['*/blocks*/**/*.test.js'],
deps: ['*/blocks*/**/*.deps.js'],
client: ['*/blocks*/**/*.js'],
e2e: ['**/e2e/**/*.js']
},
/**
* Формирует массив с файлами технологий, не относящихся к tech
*/
excludeForTech = function(tech) {
var keys = Object.keys(files),
excludes = [];
for (var i = 0, l = keys.length; i < l; i++) {
// Клиентский шаблон аффектит все js-файлы, его не добавляем в exclude
if (keys[i] !== tech && keys[i] !== 'client') {
excludes = excludes.concat(files[keys[i]]);
}
}
return excludes;
};
module.exports = {
options: {
maxerr: 50, // Maximum error before stopping
// Enforcing
// в JSCS более точная настройка
// curly: true, // Require {} for every new block or scope
// bitwise: true, // Prohibit bitwise operators (&, |, ^, etc.)
// plusplus: false, // Prohibit use of `++` & `--`
// strict: true, // Requires all functions run in ES5 Strict Mode
// camelCase: true, // Identifiers must be in camelCase
// caseindent: true, // If keywords case and default should be indented
eqeqeq: true, // Require triple equals (===) for comparison
forin: true, // Require filtering for..in loops with obj.hasOwnProperty()
immed: true, // Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
indent: 4, // Number of spaces to use for indentation
latedef: true, // Require variables/functions to be defined before being used
maxdepth: 4, // Max depth of nested blocks (within functions)
// Перенесено в jscs
// maxlen: 130, // Max number of characters per line
maxparams: 4, // Max number of formal params allowed per function
maxstatements: false, // Max number statements per function
maxcomplexity: false, // Max cyclomatic complexity per function
newcap: true, // Require capitalization of all constructor functions e.g. `new F()`
noarg: true, // Prohibit use of `arguments.caller` and `arguments.callee`
noempty: true, // Prohibit use of empty blocks
nonew: true, // Prohibit use of constructors for side-effects (without assignment)
quotmark: 'single', // Quotation mark consistency
trailing: true, // Prohibit trailing whitespaces
undef: true, // Require all non-global variables to be declared (prevents global leaks)
unused: true, // Require all defined variables be used
// Relaxing
asi: false, // Tolerate Automatic Semicolon Insertion (no semicolons)
boss: false, // Tolerate assignments where comparisons would be expected
debug: false, // Allow debugger statements e.g. browser breakpoints.
eqnull: false, // Tolerate use of `== null`
es5: false, // Allow ES5 syntax (ex: getters and setters)
esnext: false, // Allow ES.next (ES6) syntax (ex: `const`)
moz: false, // Allow Mozilla specific syntax (extends and overrides esnext features)
evil: false, // Tolerate use of `eval` and `new Function()`
expr: true, // Tolerate `ExpressionStatement` as Programs
funcscope: false, // Tolerate defining variables inside control statements
globalstrict: false, // Allow global use strict (also enables 'strict')
iterator: false, // Tolerate using the `__iterator__` property
lastsemic: false, // Tolerate omitting a semicolon for the last statement of a 1-line block
laxbreak: true, // Tolerate possibly unsafe line breakings
laxcomma: false, // Tolerate comma-first style coding
loopfunc: false, // Tolerate functions being defined in loops
multistr: false, // Tolerate multi-line strings
proto: false, // Tolerate using the `__proto__` property
scripturl: false, // Tolerate script-targeted URLs
smarttabs: false, // Tolerate mixed tabs/spaces when used for alignment
shadow: false, // Allows re-define variables later in code e.g. `var x=1; x=2;`
sub: false, // Tolerate using `[]` notation when it can still be expressed in dot notation
supernew: true, // Tolerate `new function () { ... };` and `new Object;`
validthis: false, // Tolerate using this in a non-constructor function
// Environments
devel: false, // Development/debugging (alert, confirm, etc)
nonstandard: false, // Widely adopted globals (escape, unescape, etc)
// Custom Globals
globals: {} // additional predefined global variables
},
groups: {
client: {
options: {
browser: true,
debug: false,
devel: false,
jquery: true,
predef: ['Hammer', 'BEM', 'BEMHTML', 'BEMPRIV', 'block', 'module'],
sub: true
},
includes: files.client,
excludes: excludeForTech('client')
},
priv: {
options: {
node: true,
predef: [
'_',
'BEM',
'BEMHTML',
'BEMPRIV',
'Text',
'Util',
'blocks',
'borschik',
'config',
'console'
],
sub: true
},
includes: files.priv,
excludes: excludeForTech('priv')
},
e2e:{
options: {
node: true,
predef: [
'casper',
// e2e helper vars
'betaURL',
'enableCbirAdvancedTests',
'fs',
'isTouch',
'isTouchPad',
'isTouchPhone',
'mouse',
'project',
'system',
'URI',
'utils',
'before',
'beforeEach',
'after',
'afterEach',
'createClient',
'describe',
'it',
'xit',
'client',
'window',
'assert',
'_',
'runnerOptions',
// e2e helper functions
'buildBetaUrl',
'encodeCounter',
'scrollToMore',
// e2e-model
'arrow',
'content',
'seriesNavigator',
// Add more as needed
'BEM',
'gemini'
],
sub: true,
loopfunc: true,
latedef: false
},
includes: files.e2e,
excludes: excludeForTech('e2e')
},
testPriv: {
options: {
node: true,
predef: [
'_',
'after',
'afterEach',
'assert',
'before',
'beforeEach',
'blocks',
'buildCommonData',
'describe',
'describeBlock',
'getImageStub',
'images',
'it',
'priv',
'img',
'sinon',
'stubBlocks',
'stubBlock',
'stubGlobal',
'xit',
'BEM',
'BEMPRIV',
'allure',
'every'
],
sub: true
},
includes: files.testPriv,
excludes: excludeForTech('testPriv')
},
test: {
options: {
node: true,
predef: [
'_',
'after',
'afterEach',
'assert',
'before',
'beforeEach',
'blocks',
'buildCommonData',
'describe',
'describeBlock',
'getImageStub',
'images',
'it',
'priv',
'sinon',
'stubBlocks',
'stubBlock',
'stubGlobal',
'xit',
'BEM',
'BEMPRIV',
'allure',
'buildBlock',
'addScript',
'buildLazyBlock',
'getLazyBlock',
'bemDomStub',
'$',
'window',
'document',
'BEMHTML',
'c'
],
sub: true
},
includes: files.test,
excludes: excludeForTech('test')
},
deps: {
options: {
asi: true,
expr: true
},
includes: files.deps,
excludes: excludeForTech('deps')
},
bemdecl: {
options: { node: true },
includes: files.bemdecl,
excludes: excludeForTech('bemdecl')
},
bemhtml: {
options: {
predef: [
'BEM',
'BEMHTML',
'block',
'js',
'elem',
'mod',
'mix',
'match',
'bem',
'tag',
'mode',
'attrs',
'apply',
'applyNext',
'applyCtx',
'content',
'_',
'def',
'oninit',
'elemMod',
'replace'
]
},
includes: files.bemhtml,
excludes: excludeForTech('bemhtml')
}
}
};
*.deps.js
*/*.deps.js
*/*/*.deps.js
*/*/*/*.deps.js
*/*/*/*/*.deps.js
*/*/*/*/*/*.deps.js
{
"passfail" : false, // Stop on first error.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"node" : true,
"predef" : [
"Base",
"BEM",
"BEM.DOM",
"BEMPRIV",
"BEMHTML",
"exports",
"i18n",
"Lego",
"blocks",
"block",
"$",
"jQuery",
"global",
"config",
"Util",
"Text",
"History",
"Modernizr",
"casper",
"require",
"client",
"PO",
"c",
"errcnt",
"_",
"screenfull"
],
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
"devel" : false, // Allow developments statements e.g. `console.log();`.
"es5" : false, // Allow ECMAScript 5 syntax.
"strict" : false, // Require `use strict` pragma in every file.
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"laxbreak" : true, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"curly" : false, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"eqnull" : true, // Tolerate use of `== null`.
"evil" : true, // Tolerate use of `eval`.
"expr" : true, // Tolerate `ExpressionStatement` as Programs.
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef" : true, // Prohipit variable use before definition.
"loopfunc" : false, // Allow functions to be defined within loops.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"scripturl" : true, // Tolerate script-targeted URLs.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"undef" : true, // Require all non-global variables be declared before they are used.
"unused" : true, // This option warns when you define and never use your variables.
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"trailing" : true // Prohibit trailing whitespaces.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment