eslint-plugin-ember
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -125,3 +125,3 @@ 'use strict'; | ||
function isInjectedServiceProp(node) { | ||
return isPropOfType(node, 'service'); | ||
return isPropOfType(node, 'service') || isPropOfType(node, 'inject'); | ||
} | ||
@@ -128,0 +128,0 @@ |
{ | ||
"name": "eslint-plugin-ember", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"description": "Eslint plugin for Ember.js apps", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -84,2 +84,18 @@ // ------------------------------------------------------------------------------ | ||
{ | ||
code: ` | ||
import { inject } from '@ember/service'; | ||
export default Component.extend({ | ||
abc: inject(), | ||
def: inject.service(), | ||
ghi: service(), | ||
role: "sloth", | ||
levelOfHappiness: computed("attitude", "health", () => { | ||
}) | ||
}); | ||
`, | ||
parserOptions: { ecmaVersion: 6, sourceType: 'module' }, | ||
}, | ||
{ | ||
code: `export default Component.extend({ | ||
@@ -468,2 +484,16 @@ role: "sloth", | ||
{ | ||
code: ` | ||
import { inject } from '@ember/service'; | ||
export default Component.extend({ | ||
vehicle: alias("car"), | ||
i18n: inject() | ||
}); | ||
`, | ||
parserOptions: { ecmaVersion: 6, sourceType: 'module' }, | ||
errors: [{ | ||
message: 'The "i18n" service injection should be above the "vehicle" single-line function on line 4', | ||
line: 5, | ||
}], | ||
}, | ||
{ | ||
code: `export default Component.extend({ | ||
@@ -470,0 +500,0 @@ levelOfHappiness: observer("attitude", "health", () => { |
@@ -33,4 +33,16 @@ // ------------------------------------------------------------------------------ | ||
code: `export default Controller.extend({ | ||
currentUser: inject(), | ||
queryParams: [], | ||
customProp: "test", | ||
actions: {}, | ||
_customAction() {}, | ||
_customAction2: function() {}, | ||
tSomeTask: task(function* () {}) | ||
});`, | ||
parserOptions: { ecmaVersion: 6, sourceType: 'module' }, | ||
}, | ||
{ | ||
code: `export default Controller.extend({ | ||
queryParams: [], | ||
customProp: "test", | ||
comp: computed("test", function() {}), | ||
@@ -98,2 +110,13 @@ obs: observer("asd", function() {}), | ||
code: `export default Controller.extend({ | ||
queryParams: [], | ||
currentUser: inject() | ||
});`, | ||
parserOptions: { ecmaVersion: 6, sourceType: 'module' }, | ||
errors: [{ | ||
message: 'The "currentUser" service injection should be above the "queryParams" property on line 2', | ||
line: 3, | ||
}], | ||
}, | ||
{ | ||
code: `export default Controller.extend({ | ||
currentUser: service(), | ||
@@ -100,0 +123,0 @@ customProp: "test", |
@@ -38,5 +38,22 @@ // ------------------------------------------------------------------------------ | ||
code: `export default Route.extend({ | ||
currentUser: inject(), | ||
queryParams: {}, | ||
customProp: "test", | ||
vehicle: alias("car"), | ||
levelOfHappiness: computed("attitude", "health", () => { | ||
}), | ||
model() {}, | ||
beforeModel() {}, | ||
actions: {}, | ||
_customAction() {}, | ||
_customAction2: function() {}, | ||
tSomeTask: task(function* () {}) | ||
});`, | ||
parserOptions: { ecmaVersion: 6, sourceType: 'module' }, | ||
}, | ||
{ | ||
code: `export default Route.extend({ | ||
levelOfHappiness: computed("attitude", "health", () => { | ||
}), | ||
model() {}, | ||
actions: { | ||
@@ -116,3 +133,23 @@ test() { return this._customAction() } | ||
code: `export default Route.extend({ | ||
queryParams: {}, | ||
currentUser: inject(), | ||
customProp: "test", | ||
model() {}, | ||
beforeModel() {}, | ||
vehicle: alias("car"), | ||
actions: {}, | ||
_customAction() {} | ||
});`, | ||
parserOptions: { ecmaVersion: 6, sourceType: 'module' }, | ||
errors: [{ | ||
message: 'The "currentUser" service injection should be above the inherited "queryParams" property on line 2', | ||
line: 3, | ||
}, { | ||
message: 'The "vehicle" single-line function should be above the "model" hook on line 5', | ||
line: 7, | ||
}], | ||
}, | ||
{ | ||
code: `export default Route.extend({ | ||
customProp: "test", | ||
queryParams: {}, | ||
@@ -119,0 +156,0 @@ model() {}, |
@@ -219,2 +219,5 @@ 'use strict'; | ||
expect(emberUtils.isInjectedServiceProp(node)).toBeTruthy(); | ||
node = parse('inject()'); | ||
expect(emberUtils.isInjectedServiceProp(node)).toBeTruthy(); | ||
}); | ||
@@ -221,0 +224,0 @@ }); |
300317
5402