Comments (3)
Again probably misleading option names. However it is described in README.md. In this context 'nesting' means function exp. call inside function exp. call:
foo( bar( 1,1 ) )
For example sources of jQuery still styled mostly for the outdated styleguide - no spaces for the nesting calls
foo( bar(1,1) )
So this style ruleset modifier allows to describe such cases. In the given example _self.normal(input, options);
is within a closure, but has no inner function expression calls, so it is treated as high-level call.
from jscodesniffer.
Consider
/*jshint -W068 */
/*jshint multistr: true */
var Sniffer = require( "../lib/Sniffer" );
require( "should" );
Array.prototype.hasErrorCode = function( errCode ) {
return !!this.filter(function( msg ){
return msg.errorCode === errCode;
}).length;
};
var OPTIONS = {
standard: "Jquery"
};
describe( " Custom checks ", function () {
var sniffer, logger = null;
beforeEach(function(){
sniffer = new Sniffer();
});
it(" must implement custom standard correctly", function () {
var code = "define('library/uielements/textinput', [\
'core'\
], function(require) {\
var core = require('core'),\
_textinput = {\
create: function(input, type, options) {\
switch(type) {\
case _self.TYPE_NORMAL:\
_self.normal(input, options);\
break;\
}\
}\
};\
});",
modifiers = {
"Indentation": false,
"QuoteConventions": false,
"ParametersSpacing": false,
"LineLength": false,
"ArrayLiteralSpacing": false,
"ObjectLiteralSpacing": false,
"CompoundStatementConventions": false,
"ArgumentsSpacing": {
"allowArgPrecedingWhitespaces": 1,
"allowArgTrailingWhitespaces": 0,
"exceptions": {
"singleArg" : {
"for": ["FunctionExpression", "ArrayExpression", "ObjectExpression", "Literal"],
"allowArgPrecedingWhitespaces": 0,
"allowArgTrailingWhitespaces": 0
},
"firstArg": {
"for": [ "FunctionExpression" , "ArrayExpression", "ObjectExpression", "Literal"],
"allowArgPrecedingWhitespaces": 0
},
"lastArg": {
"for": [ "FunctionExpression", , "ArrayExpression", "ObjectExpression", "Literal" ],
"allowArgTrailingWhitespaces": 0
}
},
"ifNesting": false
}
};
logger = sniffer.getTestResults( code, OPTIONS, modifiers );
console.log(logger.getMessages());
logger.getMessages().length.should.not.be.ok;
});
});
if I put ifNesting on false, it doesn't matter anymore how the arguments of _self.normal(input, options); are formatted. If I add the proposed options to ifNesting, I get a failing test whatever I choose and it fails on _self.normal.
from jscodesniffer.
Following case shows the usage of ifNesting
it(" must accept ArgumentsSpacing ifNesting modifiers", function () {
var code = "foo( 1, bar(1,1) )",
modifiers = {
"ArgumentsSpacing": {
"allowArgPrecedingWhitespaces": 1,
"allowArgTrailingWhitespaces": 1,
"ifNesting": {
"allowArgPrecedingWhitespaces": 0,
"allowArgTrailingWhitespaces": 0
}
}
};
logger = sniffer.getTestResults( code, OPTIONS, modifiers );
logger.getMessages().length.should.not.be.ok;
});
from jscodesniffer.
Related Issues (20)
- Have the same exception possibilities of arguments on arrays. HOT 5
- ArrayLiteralSpacing > Exceptions > firstElement > allowElementPrecedingWhitespaces fails. HOT 2
- VariableDeclarationPerScopeConventions -> requireInTheBeginning reports functions without any variables HOT 1
- ArrayLiteralSpacing Strange Behavior HOT 3
- Windows - Maximum call stack size exceeded HOT 1
- Gulp plugin HOT 2
- Spaces around function declarations vs. function invocation parens HOT 5
- Add sniff for whitespace around control flow statements HOT 3
- ArgumentsSpacing Exception isn't working HOT 3
- Relax indentation rule(s) for JSDoc comments HOT 1
- Support for something like .jshintignore HOT 1
- Support for inline silencing of certain errors HOT 2
- Wrong EmptyConstructsSpacing validation HOT 1
- Custom standart as path
- Missing a colon in "readme documentation"
- ES6 support HOT 1
- ArgumentsSpacing Exception (firstArg > allowArgPrecedingWhitespaces) doesn't seem to work. HOT 8
- Certain keywords preceded or followed by a new line. HOT 2
- Enable the same options for parameterspacing as for argumentspacing. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jscodesniffer.