Skip to content
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

Fix JSCS rule (getTokenPosByRangeStart was removed upstream). #10747

Merged
merged 4 commits into from
Mar 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,10 @@ module.exports.prototype = {
check: function(file, errors) {
var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace;
var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace;
var tokens = file.getTokens();

file.iterateNodesByType(['FunctionDeclaration'], function(node) {
var nodeBeforeRoundBrace = node;
// named function
if (node.id) {
nodeBeforeRoundBrace = node.id;
}

var functionTokenPos = file.getTokenPosByRangeStart(nodeBeforeRoundBrace.range[0]);
var functionToken = tokens[functionTokenPos];

var nextTokenPos = file.getTokenPosByRangeStart(functionToken.range[1]);
var nextToken = tokens[nextTokenPos];
var functionToken = file.getFirstNodeToken(node.id || node);
var nextToken = file.getNextToken(functionToken);

if (beforeOpeningRoundBrace) {
if (nextToken) {
Expand All @@ -56,8 +46,8 @@ module.exports.prototype = {
}
}

var tokenBeforeBodyPos = file.getTokenPosByRangeStart(node.body.range[0] - 1);
var tokenBeforeBody = tokens[tokenBeforeBodyPos];
// errors if no token is found unless `includeComments` is passed
var tokenBeforeBody = file.getPrevToken(node.body, { includeComments: true });

if (beforeOpeningCurlyBrace) {
if (tokenBeforeBody) {
Expand Down
2 changes: 1 addition & 1 deletion packages/container/lib/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Registry.prototype = {
@property _defaultContainer
@type Container
*/
_defaultContainer: null,
_defaultContainer: null,

/**
Creates a container based on this registry.
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/lib/helpers/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ export function collectionHelper(params, hash, options, env) {
if (inverse) {
emptyViewClass = get(collectionPrototype, 'emptyViewClass');
emptyViewClass = emptyViewClass.extend({
template: inverse,
tagName: itemHash.tagName
template: inverse,
tagName: itemHash.tagName
});
} else if (hash.emptyViewClass) {
emptyViewClass = readViewFactory(hash.emptyViewClass, container);
Expand Down
5 changes: 2 additions & 3 deletions packages/ember-htmlbars/tests/attr_nodes/boolean_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function appendView(view) {
run(function() { view.appendTo('#qunit-fixture'); });
}

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: boolean attribute", {
teardown() {
Expand Down Expand Up @@ -94,6 +94,5 @@ QUnit.test("disabled attribute preserves a blank string value", function() {
'boolean property is set false');
});


// jscs:enable validateIndentation
}
// jscs:enable validateIndentation
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/tests/attr_nodes/class_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ if (Ember.FEATURES.isEnabled('ember-htmlbars-inline-if-helper')) {
isInlineIfEnabled = true;
}

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: class attribute", {
teardown() {
Expand Down Expand Up @@ -151,5 +151,5 @@ QUnit.test("class attribute stays in order", function() {
ok(view.element.firstChild.className, 'r b a c', 'classes are in the right order');
});

// jscs:enable validateIndentation
}
// jscs:enable validateIndentation
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/tests/attr_nodes/href_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function appendView(view) {
run(function() { view.appendTo('#qunit-fixture'); });
}

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: href attribute", {
teardown() {
Expand All @@ -31,5 +31,5 @@ QUnit.test("href is set", function() {
"attribute is output");
});

// jscs:enable validateIndentation
}
// jscs:enable validateIndentation
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/tests/attr_nodes/property_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function canSetFalsyMaxLength() {
return input.maxLength === 0;
}

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: property", {
teardown() {
Expand Down Expand Up @@ -69,5 +69,5 @@ QUnit.test("array value can be set as property", function() {
ok(true, "no legacy assertion prohibited setting an array");
});

// jscs:enable validateIndentation
}
// jscs:enable validateIndentation
9 changes: 5 additions & 4 deletions packages/ember-htmlbars/tests/attr_nodes/sanitized_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ QUnit.module("ember-htmlbars: sanitized attribute", {
}
});

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
// jscs:disable disallowTrailingWhitespace
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {

var badTags = [
{ tag: 'a', attr: 'href',
Expand All @@ -28,12 +28,12 @@ var badTags = [
unquotedTemplate: compile("<base href={{url}} />"),
quotedTemplate: compile("<base href='{{url}}'/>"),
multipartTemplate: compile("<base href='{{protocol}}{{path}}'/>") },

{ tag: 'embed', attr: 'src',
unquotedTemplate: compile("<embed src={{url}} />"),
quotedTemplate: compile("<embed src='{{url}}'/>"),
multipartTemplate: compile("<embed src='{{protocol}}{{path}}'/>") },

{ tag: 'body', attr: 'background',
unquotedTemplate: compile("<body background={{url}}></body>"),
quotedTemplate: compile("<body background='{{url}}'></body>"),
Expand Down Expand Up @@ -123,5 +123,6 @@ for (var i=0, l=badTags.length; i<l; i++) {
})(); //jshint ignore:line
}

// jscs:enable validateIndentation
}
// jscs:enable disallowTrailingWhitespace
// jscs:enable validateIndentation
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/tests/attr_nodes/style_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ QUnit.module("ember-htmlbars: style attribute", {
}
});

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {

if (!EmberDev.runningProdBuild) {
QUnit.test('specifying `<div style={{userValue}}></div>` generates a warning', function() {
Expand Down Expand Up @@ -75,5 +75,5 @@ QUnit.test('specifying `<div style={{userValue}}></div>` works properly with a S
deepEqual(warnings, [ ]);
});

// jscs:enable validateIndentation
}
// jscs:enable validateIndentation
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/tests/attr_nodes/svg_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function appendView(view) {
run(function() { view.appendTo('#qunit-fixture'); });
}

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: svg attribute", {
teardown() {
Expand Down Expand Up @@ -75,5 +75,5 @@ QUnit.test("class is output", function() {
equalInnerHTML(view.element, '<svg class="red tall"></svg>', "attribute is output");
});

// jscs:enable validateIndentation
}
// jscs:enable validateIndentation
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/tests/attr_nodes/value_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ function appendView(view) {
run(function() { view.appendTo('#qunit-fixture'); });
}

if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {

QUnit.module("ember-htmlbars: value attribute", {
teardown() {
Expand Down Expand Up @@ -55,5 +55,5 @@ QUnit.test("blank property is output", function() {
'property is set true');
});

// jscs:enable validateIndentation
}
// jscs:enable validateIndentation
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/tests/helpers/collection_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ QUnit.test("collection helper should try to use container to resolve view", func
var container = registry.container();

var ACollectionView = CollectionView.extend({
tagName: 'ul',
content: A(['foo', 'bar', 'baz'])
tagName: 'ul',
content: A(['foo', 'bar', 'baz'])
});

registry.register('view:collectionTest', ACollectionView);
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-htmlbars/tests/helpers/each_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ QUnit.test("it supports {{itemViewClass=}} via container", function() {
QUnit.test("it supports {{itemViewClass=}} with tagName (DEPRECATED)", function() {
runDestroy(view);
view = EmberView.create({
template: templateFor('{{each view.people itemViewClass=MyView tagName="ul"}}'),
people: people
template: templateFor('{{each view.people itemViewClass=MyView tagName="ul"}}'),
people: people
});

expectDeprecation(/Supplying a tagName to Metamorph views is unreliable and is deprecated./);
Expand Down
16 changes: 8 additions & 8 deletions packages/ember-routing/tests/location/hash_location_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ function mockBrowserLocation(path) {
var pathname = (tmp.pathname.match(/^\//)) ? tmp.pathname : '/' + tmp.pathname;

return {
hash: tmp.hash,
host: tmp.host || 'localhost',
hostname: tmp.hostname || 'localhost',
href: tmp.href,
pathname: pathname,
port: tmp.port || '',
protocol: protocol,
search: tmp.search
hash: tmp.hash,
host: tmp.host || 'localhost',
hostname: tmp.hostname || 'localhost',
href: tmp.href,
pathname: pathname,
port: tmp.port || '',
protocol: protocol,
search: tmp.search
};
}

Expand Down
16 changes: 8 additions & 8 deletions packages/ember-routing/tests/location/history_location_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ function mockBrowserLocation(path) {
var pathname = (tmp.pathname.match(/^\//)) ? tmp.pathname : '/' + tmp.pathname;

return {
hash: tmp.hash,
host: tmp.host || 'localhost',
hostname: tmp.hostname || 'localhost',
href: tmp.href,
pathname: pathname,
port: tmp.port || '',
protocol: protocol,
search: tmp.search
hash: tmp.hash,
host: tmp.host || 'localhost',
hostname: tmp.hostname || 'localhost',
href: tmp.href,
pathname: pathname,
port: tmp.port || '',
protocol: protocol,
search: tmp.search
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ember-routing/tests/system/dsl_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ QUnit.test("should retain resource namespace if nested with routes", function()
ok(router.router.recognizer.names['bleep.bloop.blork'], 'parent name was used as base of nested routes');
});

if (Ember.FEATURES.isEnabled("ember-routing-named-substates")) {
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled("ember-routing-named-substates")) {

QUnit.test("should add loading and error routes if _isRouterMapResult is true", function() {
Router.map(function() {
Expand Down Expand Up @@ -107,5 +107,5 @@ QUnit.test("should not add loading and error routes if _isRouterMapResult is fal
ok(!router.router.recognizer.names['blork_error'], 'error route was not added');
});

// jscs:enable validateIndentation
}
// jscs:enable validateIndentation
4 changes: 2 additions & 2 deletions packages/ember-runtime/lib/ext/rsvp.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ RSVP.configure('async', function(callback, promise) {

if (Ember.testing && async) { asyncStart(); }

run.backburner.schedule('actions', function(){
run.backburner.schedule('actions', function() {
if (Ember.testing && async) { asyncEnd(); }
callback(promise);
});
});

RSVP.Promise.prototype.fail = function(callback, label){
RSVP.Promise.prototype.fail = function(callback, label) {
Ember.deprecate('RSVP.Promise.fail has been renamed as RSVP.Promise.catch');
return this['catch'](callback, label);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,18 +634,18 @@ QUnit.module('computedSetDiff', {
QUnit.test("it throws an error if given fewer or more than two dependent properties", function() {
throws(function () {
EmberObject.createWithMixins({
array: Ember.A([1,2,3,4,5,6,7]),
array2: Ember.A([3,4,5]),
diff: computedSetDiff('array')
array: Ember.A([1,2,3,4,5,6,7]),
array2: Ember.A([3,4,5]),
diff: computedSetDiff('array')
});
}, /requires exactly two dependent arrays/, "setDiff requires two dependent arrays");

throws(function () {
EmberObject.createWithMixins({
array: Ember.A([1,2,3,4,5,6,7]),
array2: Ember.A([3,4,5]),
array3: Ember.A([7]),
diff: computedSetDiff('array', 'array2', 'array3')
array: Ember.A([1,2,3,4,5,6,7]),
array2: Ember.A([3,4,5]),
array3: Ember.A([7]),
diff: computedSetDiff('array', 'array2', 'array3')
});
}, /requires exactly two dependent arrays/, "setDiff requires two dependent arrays");
});
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-runtime/tests/computed/reduce_computed_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ QUnit.test("on first retrieval, array computed properties dependent on nested ob

QUnit.test("after the first retrieval, array computed properties observe additions to dependent arrays", function() {
var numbers = get(obj, 'numbers');
// set up observers
// set up observers
var evenNumbers = get(obj, 'evenNumbers');

run(function() {
Expand All @@ -137,7 +137,7 @@ QUnit.test("after the first retrieval, array computed properties observe additio

QUnit.test("after the first retrieval, array computed properties observe removals from dependent arrays", function() {
var numbers = get(obj, 'numbers');
// set up observers
// set up observers
var evenNumbers = get(obj, 'evenNumbers');

run(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ QUnit.test("should observe the changes within the nested begin / end property ch
equal(ObjectA.prop, "propValue");
ObjectA.endPropertyChanges();

//end inner nest
//end inner nest
ObjectA.set('prop', 'changePropValue');
equal(ObjectA.newFoo, "newFooValue");

Expand Down
6 changes: 3 additions & 3 deletions packages/ember-runtime/tests/legacy_1x/system/binding_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ QUnit.module("propertyNameBinding with longhand", {
});

TestNamespace.toObject = EmberObject.createWithMixins({
valueBinding: Binding.from('TestNamespace.fromObject.value'),
localValue: "originalLocal",
relativeBinding: Binding.from('localValue')
valueBinding: Binding.from('TestNamespace.fromObject.value'),
localValue: "originalLocal",
relativeBinding: Binding.from('localValue')
});
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var fooBindingModuleOpts = {
teardown() {
Ember.lookup = originalLookup;
TestObject = fromObject = extraObject = null;
// delete TestNamespace;
// delete TestNamespace;
}

};
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-runtime/tests/legacy_1x/system/set_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ QUnit.test("should ignore removing an object not in the set", function() {
});

QUnit.module("Set.pop + Set.copy", {
// generate a set with every type of object, but none of the specific
// ones we add in the tests below...
// generate a set with every type of object, but none of the specific
// ones we add in the tests below...
setup() {
ignoreDeprecation(function() {
set = new Set(Ember.A([
Expand Down
Loading