Skip to content

Commit

Permalink
Merge pull request #1301 from bmish/rules-type-jsdoc
Browse files Browse the repository at this point in the history
Add jsdoc `type` annotation to rules
  • Loading branch information
lin-ll committed Sep 20, 2021
2 parents d1b533d + 3fd8ab7 commit ddaa2d8
Show file tree
Hide file tree
Showing 87 changed files with 261 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/alias-model-in-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const ember = require('../utils/ember');
// Controllers - Alias your model
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/avoid-leaking-state-in-ember-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function isAllowed(value) {
// (Don't use arrays or objects as default props)
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/avoid-using-needs-in-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const ember = require('../utils/ember');
// Ember object rule - Avoid using needs in controllers
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/classic-decorator-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const ERROR_MESSAGE_DESTROY_IN_NON_CLASSIC =
const ERROR_MESSAGE_CONSTRUCTOR_IN_CLASSIC =
'You cannot use the constructor in a classic class. If the class can be converted, you can convert it to remove all classic APIs and remove the @classic decorator, then switch to the constructor.';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE_INIT_IN_NON_CLASSIC,
ERROR_MESSAGE_DESTROY_IN_NON_CLASSIC,
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/classic-decorator-no-classic-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ function disallowedMethodErrorMessage(name) {
return `The this.${name}() method is a classic ember object method, and can't be used in octane classes. You can refactor this usage to use a utility version instead (e.g. get(this, 'foo')), or to use native/modern syntax instead. Alternatively, you can add the @classic decorator to this class to continue using classic APIs.`;
}

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
disallowedMethodErrorMessage,

Expand Down
3 changes: 3 additions & 0 deletions lib/rules/closure-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const types = require('../utils/types');

const ERROR_MESSAGE = 'Use closure actions';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/computed-property-getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const PREVENT_GETTER_MESSAGE = 'Do not use a getter inside computed properties.'
const ALWAYS_WITH_SETTER_MESSAGE =
'Always define a getter inside computed properties when using a setter.';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/jquery-ember-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const EMBER_RUNLOOP_FUNCTIONS = [
'throttle',
];

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/named-functions-in-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const types = require('../utils/types');
// General rule - Use named functions defined on objects to handle promises
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/new-module-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const GLOBALS = MAPPING.reduce((memo, exportDefinition) => {
// General rule - Use "New Module Imports" from Ember RFC #176
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-actions-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const utils = require('../utils/utils');

const ERROR_MESSAGE = 'Use the @action decorator instead of declaring an actions hash';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE,
meta: {
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-arrow-function-computed-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const { getImportIdentifier } = require('../utils/import');

const ERROR_MESSAGE = 'Do not use arrow functions in computed properties';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class Stack {
}
}

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-attrs-in-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const ERROR_MESSAGE = 'Do not use `this.attrs`';
// General rule - Don't use this.attrs
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-attrs-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const hasAttrsSnapShot = function (node) {
return (methodName === 'didReceiveAttrs' || methodName === 'didUpdateAttrs') && hasParams;
};

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-capital-letters-in-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const types = require('../utils/types');
// Routing - No capital letters in routes
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-classic-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function isEmberImport(classImportedFrom) {
// Rule Definition
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE_NO_CLASSIC_CLASSES,

Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-classic-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const assert = require('assert');
const ERROR_MESSAGE =
'Use Glimmer components(@glimmer/component) instead of classic components(@ember/component)';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-component-lifecycle-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const report = (context, node) => {
context.report(node, ERROR_MESSAGE_NO_COMPONENT_LIFECYCLE_HOOKS);
};

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE_NO_COMPONENT_LIFECYCLE_HOOKS,
meta: {
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-computed-properties-in-native-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ function findComputedNodes(nodeBody) {
// General rule - Do not use computed properties in native classes
//----------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-controller-access-in-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const ERROR_MESSAGE =
// Routing - No controller access in routes
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const assert = require('assert');

const ERROR_MESSAGE = 'Avoid using controllers except for specifying `queryParams`';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE,
meta: {
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-current-route-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

const ERROR_MESSAGE = 'Use currentURL() instead of currentRouteName()';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-deeply-nested-dependent-keys-with-each.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const { getImportIdentifier } = require('../utils/import');
const ERROR_MESSAGE =
'Dependent keys containing `@each` only work one level deep. You cannot use nested forms like: `todos.@each.owner.name`. Please create an intermediary computed property instead.';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-duplicate-dependent-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const ERROR_MESSAGE = 'Dependent keys should not be repeated';
// Rule Definition
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-ember-super-in-es-classes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-ember-testing-in-module-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const ERROR_MESSAGES = [
'Can not use destructuring to reference Ember.testing',
];

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-empty-attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const ember = require('../utils/ember');
// Ember Data - Be explicit with Ember data attribute types
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-empty-glimmer-component-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const ERROR_MESSAGE = 'Do not create empty backing classes for Glimmer component
// Rule Definition
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-function-prototype-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const types = require('../utils/types');
// General rule - Don't use Ember's function prototype extensions like .property() or .observe()
//----------------------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-get-with-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const { getImportIdentifier } = require('../utils/import');

const ERROR_MESSAGE = 'Use `||` or the ternary operator instead of `getWithDefault()`';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE,
meta: {
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ function fixGet({
return fixer.replaceText(node, `${objectTextSafe}${objectPathSeparator}${replacementPath}`);
}

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE_GET,
ERROR_MESSAGE_GET_PROPERTIES,
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-global-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const ERROR_MESSAGE = 'Do not use global `$` or `jQuery`';
// Rule Definition
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-html-safe.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const { getImportIdentifier } = require('../utils/import');
// Rule Definition
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-implicit-service-injection-argument.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const { getImportIdentifier } = require('../utils/import');

const ERROR_MESSAGE = "Don't omit the argument for the injected service name.";

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const functionRules = [

const allDedupingRunMethodNames = new Set(functionRules.map((rule) => rule.importName));

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
ERROR_MESSAGE,

Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-incorrect-computed-macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const types = require('../utils/types');

const ERROR_MESSAGE_AND_OR = 'Computed property macro should be used with 2+ arguments';

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-invalid-debug-function-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const ERROR_MESSAGE =

const DEBUG_FUNCTIONS = ['assert', 'deprecate', 'warn'];

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-invalid-dependent-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ function hasMiddleBrackets(str) {
return str.includes('[].');
}

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'problem',
Expand Down
3 changes: 3 additions & 0 deletions lib/rules/no-invalid-test-waiters.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function isDirectVariableDeclaration(node) {
return node.parent.type === 'VariableDeclarator';
}

/**
* @type {import('eslint').Rule.RuleModule}
*/
module.exports = {
meta: {
type: 'suggestion',
Expand Down

0 comments on commit ddaa2d8

Please sign in to comment.