eslint-plugin-ember
Advanced tools
Comparing version 7.3.0 to 7.4.0
@@ -0,1 +1,19 @@ | ||
## v7.4.0 (2019-11-06) | ||
#### :rocket: Enhancement | ||
* [#561](https://github.com/ember-cli/eslint-plugin-ember/pull/561) Add `octane` configuration (experimental) ([@patocallaghan](https://github.com/patocallaghan)) | ||
* [#562](https://github.com/ember-cli/eslint-plugin-ember/pull/562) Add new rule `no-test-module-for` ([@NullVoxPopuli](https://github.com/NullVoxPopuli)) | ||
* [#565](https://github.com/ember-cli/eslint-plugin-ember/pull/565) Add `ignoreNestedPaths` option (default true) to `no-get` rule ([@bmish](https://github.com/bmish)) | ||
* [#564](https://github.com/ember-cli/eslint-plugin-ember/pull/564) Update `no-new-mixins` rule to handle native classes ([@bmish](https://github.com/bmish)) | ||
#### :house: Internal | ||
* [#570](https://github.com/ember-cli/eslint-plugin-ember/pull/570) Simplify some tests by setting `parserOptions` globally instead of in each individual test case ([@bmish](https://github.com/bmish)) | ||
* [#568](https://github.com/ember-cli/eslint-plugin-ember/pull/568) Add tests to ensure plugin exports correct configurations ([@bmish](https://github.com/bmish)) | ||
* [#563](https://github.com/ember-cli/eslint-plugin-ember/pull/563) Lint against unnecessary template literals internally ([@bmish](https://github.com/bmish)) | ||
#### Committers: 3 | ||
- Bryan Mishkin ([@bmish](https://github.com/bmish)) | ||
- L. Preston Sego III ([@NullVoxPopuli](https://github.com/NullVoxPopuli)) | ||
- Pat O'Callaghan ([@patocallaghan](https://github.com/patocallaghan)) | ||
## v7.3.0 (2019-10-30) | ||
@@ -2,0 +20,0 @@ |
@@ -44,2 +44,3 @@ 'use strict'; | ||
'no-test-import-export': require('./rules/no-test-import-export'), | ||
'no-test-module-for': require('./rules/no-test-module-for'), | ||
'no-unnecessary-index-route': require('./rules/no-unnecessary-index-route'), | ||
@@ -67,2 +68,3 @@ 'no-unnecessary-route-path-option': require('./rules/no-unnecessary-route-path-option'), | ||
recommended: require('./config/recommended'), | ||
octane: require('./config/octane'), | ||
}, | ||
@@ -69,0 +71,0 @@ utils: { |
@@ -47,2 +47,3 @@ /* | ||
"ember/no-test-import-export": "off", | ||
"ember/no-test-module-for": "off", | ||
"ember/no-unnecessary-index-route": "off", | ||
@@ -49,0 +50,0 @@ "ember/no-unnecessary-route-path-option": "error", |
@@ -18,2 +18,3 @@ const ERROR_MESSAGE_INIT_IN_NON_CLASSIC = | ||
recommended: false, | ||
octane: true, | ||
url: | ||
@@ -20,0 +21,0 @@ 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/classic-decorator-hooks.md', |
@@ -30,2 +30,3 @@ const disallowedMethods = [ | ||
recommended: false, | ||
octane: true, | ||
url: | ||
@@ -32,0 +33,0 @@ 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/classic-decorator-no-classic-methods.md', |
@@ -13,2 +13,3 @@ const ember = require('../utils/ember'); | ||
recommended: false, | ||
octane: true, | ||
}, | ||
@@ -15,0 +16,0 @@ fixable: null, // or "code" or "whitespace" |
@@ -29,2 +29,3 @@ 'use strict'; | ||
recommended: false, | ||
octane: true, | ||
}, | ||
@@ -31,0 +32,0 @@ fixable: null, // or "code" or "whitespace" |
@@ -12,2 +12,3 @@ 'use strict'; | ||
recommended: false, | ||
octane: true, | ||
url: | ||
@@ -14,0 +15,0 @@ 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/no-classic-components.md', |
@@ -5,3 +5,4 @@ 'use strict'; | ||
const ERROR_MESSAGE = `Don't use computed properties with native classes. Use getters or @tracked properties instead.`; | ||
const ERROR_MESSAGE = | ||
"Don't use computed properties with native classes. Use getters or @tracked properties instead."; | ||
@@ -34,2 +35,3 @@ /** | ||
recommended: false, | ||
octane: true, | ||
url: | ||
@@ -36,0 +38,0 @@ 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/no-computed-properties-in-native-classes.md', |
@@ -22,2 +22,3 @@ 'use strict'; | ||
recommended: false, | ||
octane: true, | ||
}, | ||
@@ -32,2 +33,6 @@ schema: [ | ||
}, | ||
ignoreNestedPaths: { | ||
type: 'boolean', | ||
default: true, | ||
}, | ||
}, | ||
@@ -41,2 +46,3 @@ additionalProperties: false, | ||
const ignoreGetProperties = context.options[0] && context.options[0].ignoreGetProperties; | ||
const ignoreNestedPaths = !context.options[0] || context.options[0].ignoreNestedPaths; | ||
@@ -57,3 +63,3 @@ return { | ||
types.isStringLiteral(node.arguments[0]) && | ||
!node.arguments[0].value.includes('.') | ||
(!node.arguments[0].value.includes('.') || !ignoreNestedPaths) | ||
) { | ||
@@ -70,3 +76,3 @@ // Example: this.get('foo'); | ||
types.isStringLiteral(node.arguments[1]) && | ||
!node.arguments[1].value.includes('.') | ||
(!node.arguments[1].value.includes('.') || !ignoreNestedPaths) | ||
) { | ||
@@ -90,3 +96,3 @@ // Example: get(this, 'foo'); | ||
node.callee.property.name === 'getProperties' && | ||
validateGetPropertiesArguments(node.arguments) | ||
validateGetPropertiesArguments(node.arguments, ignoreNestedPaths) | ||
) { | ||
@@ -101,3 +107,3 @@ // Example: this.getProperties('foo', 'bar'); | ||
types.isThisExpression(node.arguments[0]) && | ||
validateGetPropertiesArguments(node.arguments.slice(1)) | ||
validateGetPropertiesArguments(node.arguments.slice(1), ignoreNestedPaths) | ||
) { | ||
@@ -112,8 +118,11 @@ // Example: getProperties(this, 'foo', 'bar'); | ||
function validateGetPropertiesArguments(args) { | ||
function validateGetPropertiesArguments(args, ignoreNestedPaths) { | ||
if (args.length === 1 && types.isArrayExpression(args[0])) { | ||
return validateGetPropertiesArguments(args[0].elements); | ||
return validateGetPropertiesArguments(args[0].elements, ignoreNestedPaths); | ||
} | ||
// We can only handle string arguments without nested property paths. | ||
return args.every(argument => types.isStringLiteral(argument) && !argument.value.includes('.')); | ||
return args.every( | ||
argument => | ||
types.isStringLiteral(argument) && (!argument.value.includes('.') || !ignoreNestedPaths) | ||
); | ||
} |
@@ -20,2 +20,3 @@ 'use strict'; | ||
recommended: false, | ||
octane: true, | ||
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/no-jquery.md', | ||
@@ -22,0 +23,0 @@ }, |
@@ -30,4 +30,10 @@ 'use strict'; | ||
}, | ||
ClassDeclaration(node) { | ||
if (ember.isEmberMixin(context, node)) { | ||
context.report(node, ERROR_MESSAGE); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
@@ -417,3 +417,3 @@ 'use strict'; | ||
node, | ||
message: `Use of undeclared dependencies in computed property: {{undeclaredKeys}}`, | ||
message: 'Use of undeclared dependencies in computed property: {{undeclaredKeys}}', | ||
data: { undeclaredKeys: undeclaredKeys.join(', ') }, | ||
@@ -420,0 +420,0 @@ fix(fixer) { |
@@ -95,2 +95,3 @@ 'use strict'; | ||
recommended: false, | ||
octane: true, | ||
url: | ||
@@ -97,0 +98,0 @@ 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/require-tagless-components.md', |
@@ -14,2 +14,3 @@ 'use strict'; | ||
isExpressionStatement, | ||
isFunctionDeclaration, | ||
isFunctionExpression, | ||
@@ -144,2 +145,12 @@ isIdentifier, | ||
/** | ||
* Check whether or not a node is a FunctionDeclaration | ||
* | ||
* @param {Object} node The node to check. | ||
* @returns {boolean} Whether or not the node is a FunctionDeclaration | ||
*/ | ||
function isFunctionDeclaration(node) { | ||
return node !== undefined && node.type === 'FunctionDeclaration'; | ||
} | ||
/** | ||
* Check whether or not a node is an FunctionExpression. | ||
@@ -146,0 +157,0 @@ * |
{ | ||
"name": "eslint-plugin-ember", | ||
"version": "7.3.0", | ||
"version": "7.4.0", | ||
"description": "Eslint plugin for Ember.js apps", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -49,2 +49,3 @@ # eslint-plugin-ember | ||
- [plugin:ember/recommended](https://github.com/ember-cli/eslint-plugin-ember/blob/master/lib/config/recommended.js) - extends base configuration with recommended rules' settings | ||
- :warning: [plugin:ember/octane](https://github.com/ember-cli/eslint-plugin-ember/blob/master/lib/config/octane.js) - extends recommended configuration with octane rules' settings. This ruleset is currently considered **unstable and experiemental** as rules may be added and removed until the final ruleset is settled upon. | ||
@@ -78,2 +79,4 @@ #### Use plain plugin: | ||
The `plugin:ember/octane` config contains both Octane rules with a red car :car: in addition to the rules in the `plugin:ember/recommended` config. | ||
The `--fix` option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below. | ||
@@ -93,5 +96,5 @@ | ||
| :white_check_mark: | [no-function-prototype-extensions](./docs/rules/no-function-prototype-extensions.md) | Prevents usage of Ember's `function` prototype extensions | | ||
| | [no-get](./docs/rules/no-get.md) | Require ES5 getters instead of Ember's `get` / `getProperties` functions | | ||
| :car: | [no-get](./docs/rules/no-get.md) | Require ES5 getters instead of Ember's `get` / `getProperties` functions | | ||
| :white_check_mark: | [no-global-jquery](./docs/rules/no-global-jquery.md) | Prevents usage of global jQuery object | | ||
| | [no-jquery](./docs/rules/no-jquery.md) | Disallow any usage of jQuery | | ||
| :car: | [no-jquery](./docs/rules/no-jquery.md) | Disallow any usage of jQuery | | ||
| :white_check_mark: | [no-new-mixins](./docs/rules/no-new-mixins.md) | Prevents creation of new mixins | | ||
@@ -116,4 +119,4 @@ | :white_check_mark: | [no-observers](./docs/rules/no-observers.md) | Prevents usage of observers | | ||
| :white_check_mark: | [avoid-leaking-state-in-ember-objects](./docs/rules/avoid-leaking-state-in-ember-objects.md) | Avoids state leakage | | ||
| | [classic-decorator-hooks](./docs/rules/classic-decorator-hooks.md) | Ensure correct hooks are used for both classic and non-classic classes | | ||
| | [classic-decorator-no-classic-methods](./docs/rules/classic-decorator-no-classic-methods.md) | Prevent usage of classic APIs such as get/set in classes that aren't explicitly decorated with @classic | | ||
| :car: | [classic-decorator-hooks](./docs/rules/classic-decorator-hooks.md) | Ensure correct hooks are used for both classic and non-classic classes | | ||
| :car: | [classic-decorator-no-classic-methods](./docs/rules/classic-decorator-no-classic-methods.md) | Prevent usage of classic APIs such as get/set in classes that aren't explicitly decorated with @classic | | ||
| | [computed-property-getters](./docs/rules/computed-property-getters.md) | Enforce the consistent use of getters in computed properties | | ||
@@ -149,7 +152,7 @@ | | [no-proxies](./docs/rules/no-proxies.md) | Disallows using array or object proxies | | ||
|:---|:--------|:------------| | ||
| | [no-actions-hash](./docs/rules/no-actions-hash.md) | Disallows the actions hash in components, controllers and routes | | ||
| | [no-classic-classes](./docs/rules/no-classic-classes.md) | Disallow "classic" classes in favor of native JS classes | | ||
| | [no-classic-components](./docs/rules/no-classic-components.md) | Enforces Glimmer components | | ||
| | [no-computed-properties-in-native-classes](./docs/rules/no-computed-properties-in-native-classes.md) | Disallows using computed properties in native classes | | ||
| | [require-tagless-components](./docs/rules/require-tagless-components.md) | Disallows using the wrapper element of a Component | | ||
| :car: | [no-actions-hash](./docs/rules/no-actions-hash.md) | Disallows the actions hash in components, controllers and routes | | ||
| :car: | [no-classic-classes](./docs/rules/no-classic-classes.md) | Disallow "classic" classes in favor of native JS classes | | ||
| :car: | [no-classic-components](./docs/rules/no-classic-components.md) | Enforces Glimmer components | | ||
| :car: | [no-computed-properties-in-native-classes](./docs/rules/no-computed-properties-in-native-classes.md) | Disallows using computed properties in native classes | | ||
| :car: | [require-tagless-components](./docs/rules/require-tagless-components.md) | Disallows using the wrapper element of a Component | | ||
@@ -172,2 +175,3 @@ | ||
| | [no-test-import-export](./docs/rules/no-test-import-export.md) | Disallow importing of "-test.js" in a test file and exporting from a test file. | | ||
| | [no-test-module-for](./docs/rules/no-test-module-for.md) | Disallow use of moduleFor, moduleForComponent, etc | | ||
@@ -174,0 +178,0 @@ |
269068
74
5714
223