Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: @typescript-eslint/eslint-plugin @ 1.5.0 .. 1.7.0

CHANGELOG.md

@@ -3,6 +3,38 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+# [1.7.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.6.0...v1.7.0) (2019-04-20)
+
+### Bug Fixes
+
+- **eslint-plugin:** indent: fix false positive on type parameters ([#385](https://github.com/typescript-eslint/typescript-eslint/issues/385)) ([d476f15](https://github.com/typescript-eslint/typescript-eslint/commit/d476f15))
+- **eslint-plugin:** no-object-literal-type-assertion: fix `as const` is reported ([#390](https://github.com/typescript-eslint/typescript-eslint/issues/390)) ([2521b85](https://github.com/typescript-eslint/typescript-eslint/commit/2521b85))
+- **eslint-plugin:** support BigInt in restrict-plus-operands rule ([#344](https://github.com/typescript-eslint/typescript-eslint/issues/344)) ([eee6d49](https://github.com/typescript-eslint/typescript-eslint/commit/eee6d49)), closes [#309](https://github.com/typescript-eslint/typescript-eslint/issues/309)
+
+### Features
+
+- **eslint-plugin:** [member-accessibility] add more options ([#322](https://github.com/typescript-eslint/typescript-eslint/issues/322)) ([4b3d820](https://github.com/typescript-eslint/typescript-eslint/commit/4b3d820))
+- **eslint-plugin:** add prefer-for-of rule ([#338](https://github.com/typescript-eslint/typescript-eslint/issues/338)) ([3e26ab6](https://github.com/typescript-eslint/typescript-eslint/commit/3e26ab6))
+- **eslint-plugin:** add prefer-includes rule ([#294](https://github.com/typescript-eslint/typescript-eslint/issues/294)) ([01c4dae](https://github.com/typescript-eslint/typescript-eslint/commit/01c4dae)), closes [#284](https://github.com/typescript-eslint/typescript-eslint/issues/284)
+- **eslint-plugin:** add prefer-string-starts-ends-with rule ([#289](https://github.com/typescript-eslint/typescript-eslint/issues/289)) ([5592a2c](https://github.com/typescript-eslint/typescript-eslint/commit/5592a2c)), closes [#285](https://github.com/typescript-eslint/typescript-eslint/issues/285)
+- **eslint-plugin:** added new rule await-promise ([#192](https://github.com/typescript-eslint/typescript-eslint/issues/192)) ([5311342](https://github.com/typescript-eslint/typescript-eslint/commit/5311342))
+- **eslint-plugin:** added new rule unbound-method ([#204](https://github.com/typescript-eslint/typescript-eslint/issues/204)) ([6718906](https://github.com/typescript-eslint/typescript-eslint/commit/6718906))
+- **eslint-plugin:** support type assertions in no-extra-parens rule ([#311](https://github.com/typescript-eslint/typescript-eslint/issues/311)) ([116ca75](https://github.com/typescript-eslint/typescript-eslint/commit/116ca75))
+
+# [1.6.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.5.0...v1.6.0) (2019-04-03)
+
+### Bug Fixes
+
+- **eslint-plugin:** explicit-function-return-type: ensure class arrow methods are validated ([#377](https://github.com/typescript-eslint/typescript-eslint/issues/377)) ([643a223](https://github.com/typescript-eslint/typescript-eslint/commit/643a223)), closes [#348](https://github.com/typescript-eslint/typescript-eslint/issues/348)
+- **eslint-plugin:** Fix `allowExpressions` false positives in explicit-function-return-type and incorrect documentation ([#388](https://github.com/typescript-eslint/typescript-eslint/issues/388)) ([f29d1c9](https://github.com/typescript-eslint/typescript-eslint/commit/f29d1c9)), closes [#387](https://github.com/typescript-eslint/typescript-eslint/issues/387)
+- **eslint-plugin:** member-naming false flagging constructors ([#376](https://github.com/typescript-eslint/typescript-eslint/issues/376)) ([ad0f2be](https://github.com/typescript-eslint/typescript-eslint/commit/ad0f2be)), closes [#359](https://github.com/typescript-eslint/typescript-eslint/issues/359)
+- **eslint-plugin:** no-type-alias: fix typeof alias erroring ([#380](https://github.com/typescript-eslint/typescript-eslint/issues/380)) ([cebcfe6](https://github.com/typescript-eslint/typescript-eslint/commit/cebcfe6))
+
+### Features
+
+- change TypeScript version range to >=3.2.1 <3.5.0 ([#399](https://github.com/typescript-eslint/typescript-eslint/issues/399)) ([a4f95d3](https://github.com/typescript-eslint/typescript-eslint/commit/a4f95d3))
+- **eslint-plugin:** allow explicit variable type with arrow functions ([#260](https://github.com/typescript-eslint/typescript-eslint/issues/260)) ([bea6b92](https://github.com/typescript-eslint/typescript-eslint/commit/bea6b92)), closes [#149](https://github.com/typescript-eslint/typescript-eslint/issues/149)
+
# [1.5.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.4.2...v1.5.0) (2019-03-20)
### Bug Fixes

dist/rules/await-thenable.js

@@ -0,0 +1,48 @@
+"use strict";
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+ result["default"] = mod;
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const tsutils = __importStar(require("tsutils"));
+const ts = __importStar(require("typescript"));
+const util = __importStar(require("../util"));
+exports.default = util.createRule({
+ name: 'await-thenable',
+ meta: {
+ docs: {
+ description: 'Disallows awaiting a value that is not a Thenable',
+ category: 'Best Practices',
+ recommended: 'error',
+ tslintName: 'await-thenable',
+ },
+ messages: {
+ await: 'Unexpected `await` of a non-Promise (non-"Thenable") value.',
+ },
+ schema: [],
+ type: 'problem',
+ },
+ defaultOptions: [],
+ create(context) {
+ const parserServices = util.getParserServices(context);
+ const checker = parserServices.program.getTypeChecker();
+ return {
+ AwaitExpression(node) {
+ const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node);
+ const type = checker.getTypeAtLocation(originalNode.expression);
+ if (!tsutils.isTypeFlagSet(type, ts.TypeFlags.Any) &&
+ !tsutils.isTypeFlagSet(type, ts.TypeFlags.Unknown) &&
+ !tsutils.isThenableType(checker, originalNode.expression, type)) {
+ context.report({
+ messageId: 'await',
+ node,
+ });
+ }
+ },
+ };
+ },
+});
+//# sourceMappingURL=await-thenable.js.map
\ No newline at end of file

dist/rules/await-thenable.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"await-thenable.js","sourceRoot":"","sources":["../../src/rules/await-thenable.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iDAAmC;AACnC,+CAAiC;AAEjC,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;YAChE,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,OAAO;YACpB,UAAU,EAAE,gBAAgB;SAC7B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,6DAA6D;SACrE;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAChB;IACD,cAAc,EAAE,EAAE;IAElB,MAAM,CAAC,OAAO;QACZ,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAExD,OAAO;YACL,eAAe,CAAC,IAAI;gBAClB,MAAM,YAAY,GAAG,cAAc,CAAC,qBAAqB,CAAC,GAAG,CAC3D,IAAI,CACiB,CAAC;gBACxB,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;gBAEhE,IACE,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC;oBAC9C,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;oBAClD,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,EAC/D;oBACA,OAAO,CAAC,MAAM,CAAC;wBACb,SAAS,EAAE,OAAO;wBAClB,IAAI;qBACL,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/explicit-function-return-type.js

@@ -28,6 +28,9 @@
allowExpressions: {
type: 'boolean',
},
+ allowTypedFunctionExpressions: {
+ type: 'boolean',
+ },
},
additionalProperties: false,
},
@@ -35,30 +38,46 @@
},
defaultOptions: [
{
- allowExpressions: true,
+ allowExpressions: false,
+ allowTypedFunctionExpressions: false,
},
],
create(context, [options]) {
/**
- * Checks if the parent of a function expression is a constructor.
- * @param parent The parent of a function expression node
+ * Checks if a node is a constructor.
+ * @param node The node to check
*/
- function isConstructor(parent) {
- return (parent.type === typescript_estree_1.AST_NODE_TYPES.MethodDefinition &&
- parent.kind === 'constructor');
+ function isConstructor(node) {
+ return (node.type === typescript_estree_1.AST_NODE_TYPES.MethodDefinition &&
+ node.kind === 'constructor');
}
/**
- * Checks if the parent of a function expression is a setter.
- * @param parent The parent of a function expression node
+ * Checks if a node is a setter.
+ * @param parent The node to check
*/
- function isSetter(parent) {
- return (parent.type === typescript_estree_1.AST_NODE_TYPES.MethodDefinition && parent.kind === 'set');
+ function isSetter(node) {
+ return (node.type === typescript_estree_1.AST_NODE_TYPES.MethodDefinition && node.kind === 'set');
+ }
+ /**
+ * Checks if a node is a variable declarator with a type annotation.
+ * @param node The node to check
+ */
+ function isVariableDeclaratorWithTypeAnnotation(node) {
+ return (node.type === typescript_estree_1.AST_NODE_TYPES.VariableDeclarator &&
+ !!node.id.typeAnnotation);
}
/**
* Checks if a function declaration/expression has a return type.
* @param node The node representing a function.
*/
function checkFunctionReturnType(node) {
+ if (options.allowExpressions &&
+ node.type !== typescript_estree_1.AST_NODE_TYPES.FunctionDeclaration &&
+ node.parent &&
+ node.parent.type !== typescript_estree_1.AST_NODE_TYPES.VariableDeclarator &&
+ node.parent.type !== typescript_estree_1.AST_NODE_TYPES.MethodDefinition) {
+ return;
+ }
if (!node.returnType &&
node.parent &&
!isConstructor(node.parent) &&
@@ -75,10 +94,9 @@
* @param {ASTNode} node The node representing a function.
*/
function checkFunctionExpressionReturnType(node) {
- if (options.allowExpressions &&
+ if (options.allowTypedFunctionExpressions &&
node.parent &&
- node.parent.type !== typescript_estree_1.AST_NODE_TYPES.VariableDeclarator &&
- node.parent.type !== typescript_estree_1.AST_NODE_TYPES.MethodDefinition) {
+ isVariableDeclaratorWithTypeAnnotation(node.parent)) {
return;
}
checkFunctionReturnType(node);

dist/rules/explicit-function-return-type.js.map

@@ -1 +1 @@
-{"version":3,"file":"explicit-function-return-type.js","sourceRoot":"","sources":["../../src/rules/explicit-function-return-type.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAChF,8CAAgC;AAShC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,8DAA8D;YAChE,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,MAAM;SACpB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,kCAAkC;SACtD;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,gBAAgB,EAAE;wBAChB,IAAI,EAAE,SAAS;qBAChB;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD,cAAc,EAAE;QACd;YACE,gBAAgB,EAAE,IAAI;SACvB;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC;QACvB;;;WAGG;QACH,SAAS,aAAa,CAAC,MAAqB;YAC1C,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,kCAAc,CAAC,gBAAgB;gBAC/C,MAAM,CAAC,IAAI,KAAK,aAAa,CAC9B,CAAC;QACJ,CAAC;QAED;;;WAGG;QACH,SAAS,QAAQ,CAAC,MAAqB;YACrC,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,kCAAc,CAAC,gBAAgB,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CACzE,CAAC;QACJ,CAAC;QAED;;;WAGG;QACH,SAAS,uBAAuB,CAC9B,IAG+B;YAE/B,IACE,CAAC,IAAI,CAAC,UAAU;gBAChB,IAAI,CAAC,MAAM;gBACX,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC3B,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;gBACtB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAC5C;gBACA,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CAAC;aACJ;QACH,CAAC;QAED;;;WAGG;QACH,SAAS,iCAAiC,CACxC,IAG+B;YAE/B,IACE,OAAO,CAAC,gBAAgB;gBACxB,IAAI,CAAC,MAAM;gBACX,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kCAAc,CAAC,kBAAkB;gBACtD,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kCAAc,CAAC,gBAAgB,EACpD;gBACA,OAAO;aACR;YAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QAED,OAAO;YACL,uBAAuB,EAAE,iCAAiC;YAC1D,mBAAmB,EAAE,uBAAuB;YAC5C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file
+{"version":3,"file":"explicit-function-return-type.js","sourceRoot":"","sources":["../../src/rules/explicit-function-return-type.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAChF,8CAAgC;AAUhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,8DAA8D;YAChE,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,MAAM;SACpB;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,kCAAkC;SACtD;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,gBAAgB,EAAE;wBAChB,IAAI,EAAE,SAA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AC;gBACtB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAC5C;gBACA,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CAAC;aACJ;QACH,CAAC;QAED;;;WAGG;QACH,SAAS,iCAAiC,CACxC,IAG+B;YAE/B,IACE,OAAO,CAAC,6BAA6B;gBACrC,IAAI,CAAC,MAAM;gBACX,sCAAsC,CAAC,IAAI,CAAC,MAAM,CAAC,EACnD;gBACA,OAAO;aACR;YAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QAED,OAAO;YACL,uBAAuB,EAAE,iCAAiC;YAC1D,mBAAmB,EAAE,uBAAuB;YAC5C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/explicit-member-accessibility.js

@@ -7,7 +7,9 @@
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
+const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
const util = __importStar(require("../util"));
+const accessibilityLevel = { enum: ['explicit', 'no-public', 'off'] };
exports.default = util.createRule({
name: 'explicit-member-accessibility',
meta: {
@@ -20,47 +22,127 @@
},
messages: {
missingAccessibility: 'Missing accessibility modifier on {{type}} {{name}}.',
+ unwantedPublicAccessibility: 'Public accessibility modifier on {{type}} {{name}}.',
},
- schema: [],
+ schema: [
+ {
+ type: 'object',
+ properties: {
+ accessibility: accessibilityLevel,
+ overrides: {
+ type: 'object',
+ properties: {
+ accessors: accessibilityLevel,
+ constructors: accessibilityLevel,
+ methods: accessibilityLevel,
+ properties: accessibilityLevel,
+ parameterProperties: accessibilityLevel,
},
- defaultOptions: [],
- create(context) {
+ additionalProperties: false,
+ },
+ },
+ additionalProperties: false,
+ },
+ ],
+ },
+ defaultOptions: [{ accessibility: 'explicit' }],
+ create(context, [option]) {
const sourceCode = context.getSourceCode();
+ const baseCheck = option.accessibility || 'explicit';
+ const overrides = option.overrides || {};
+ const ctorCheck = overrides.constructors || baseCheck;
+ const accessorCheck = overrides.accessors || baseCheck;
+ const methodCheck = overrides.methods || baseCheck;
+ const propCheck = overrides.properties || baseCheck;
+ const paramPropCheck = overrides.parameterProperties || baseCheck;
/**
- * Checks if a method declaration has an accessibility modifier.
- * @param methodDefinition The node representing a MethodDefinition.
+ * Generates the report for rule violations
*/
- function checkMethodAccessibilityModifier(methodDefinition) {
- if (!methodDefinition.accessibility &&
- util.isTypeScriptFile(context.getFilename())) {
+ function reportIssue(messageId, nodeType, node, nodeName) {
context.report({
- node: methodDefinition,
- messageId: 'missingAccessibility',
+ node: node,
+ messageId: messageId,
data: {
- type: 'method definition',
- name: util.getNameFromClassMember(methodDefinition, sourceCode),
+ type: nodeType,
+ name: nodeName,
},
});
}
+ /**
+ * Checks if a method declaration has an accessibility modifier.
+ * @param methodDefinition The node representing a MethodDefinition.
+ */
+ function checkMethodAccessibilityModifier(methodDefinition) {
+ let nodeType = 'method definition';
+ let check = baseCheck;
+ switch (methodDefinition.kind) {
+ case 'method':
+ check = methodCheck;
+ break;
+ case 'constructor':
+ check = ctorCheck;
+ break;
+ case 'get':
+ case 'set':
+ check = accessorCheck;
+ nodeType = `${methodDefinition.kind} property accessor`;
+ break;
+ }
+ if (check === 'off') {
+ return;
+ }
+ if (util.isTypeScriptFile(context.getFilename())) {
+ // const methodName = util.getNameFromPropertyName(methodDefinition.key);
+ const methodName = util.getNameFromClassMember(methodDefinition, sourceCode);
+ if (check === 'no-public' &&
+ methodDefinition.accessibility === 'public') {
+ reportIssue('unwantedPublicAccessibility', nodeType, methodDefinition, methodName);
+ }
+ else if (check === 'explicit' && !methodDefinition.accessibility) {
+ reportIssue('missingAccessibility', nodeType, methodDefinition, methodName);
+ }
+ }
}
/**
* Checks if property has an accessibility modifier.
* @param classProperty The node representing a ClassProperty.
*/
function checkPropertyAccessibilityModifier(classProperty) {
- if (!classProperty.accessibility &&
- util.isTypeScriptFile(context.getFilename())) {
- context.report({
- node: classProperty,
- messageId: 'missingAccessibility',
- data: {
- type: 'class property',
- name: util.getNameFromPropertyName(classProperty.key),
- },
- });
+ const nodeType = 'class property';
+ if (util.isTypeScriptFile(context.getFilename())) {
+ const propertyName = util.getNameFromPropertyName(classProperty.key);
+ if (propCheck === 'no-public' &&
+ classProperty.accessibility === 'public') {
+ reportIssue('unwantedPublicAccessibility', nodeType, classProperty, propertyName);
+ }
+ else if (propCheck === 'explicit' && !classProperty.accessibility) {
+ reportIssue('missingAccessibility', nodeType, classProperty, propertyName);
+ }
+ }
+ }
+ /**
+ * Checks that the parameter property has the desired accessibility modifiers set.
+ * @param {TSESTree.TSParameterProperty} node The node representing a Parameter Property
+ */
+ function checkParameterPropertyAccessibilityModifier(node) {
+ const nodeType = 'parameter property';
+ if (util.isTypeScriptFile(context.getFilename())) {
+ // HAS to be an identifier or assignment or TSC will throw
+ if (node.parameter.type !== typescript_estree_1.AST_NODE_TYPES.Identifier &&
+ node.parameter.type !== typescript_estree_1.AST_NODE_TYPES.AssignmentPattern) {
+ return;
+ }
+ const nodeName = node.parameter.type === typescript_estree_1.AST_NODE_TYPES.Identifier
+ ? node.parameter.name
+ : // has to be an Identifier or TSC will throw an error
+ node.parameter.left.name;
+ if (paramPropCheck === 'no-public' && node.accessibility === 'public') {
+ reportIssue('unwantedPublicAccessibility', nodeType, node, nodeName);
+ }
}
}
return {
+ TSParameterProperty: checkParameterPropertyAccessibilityModifier,
ClassProperty: checkPropertyAccessibilityModifier,
MethodDefinition: checkMethodAccessibilityModifier,
};

dist/rules/explicit-member-accessibility.js.map

@@ -1 +1 @@
-{"version":3,"file":"explicit-member-accessibility.js","sourceRoot":"","sources":["../../src/rules/explicit-member-accessibility.ts"],"names":[],"mappings":";;;;;;;;;AACA,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,SAA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"version":3,"file":"explicit-member-accessibility.js","sourceRoot":"","sources":["../../src/rules/explicit-member-accessibility.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAChF,8CAAgC;AAsBhC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;AAEtE,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,+BAA+B;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,0EAA0E;YAC5E,cAAc,EAAE,eAAe;YAC/B,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,oBAAoB,EAClB,sDAAsD;YACxD,2BAA2B,EACzB,qDAAqD;SACxD;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE,kBAAkB;oBACjC,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,SAAS,EAAE,kBAAkB;4BAC7B,YAAY,EAAE,kBAAkB;4BAChC,OAAO,EAAE,kBAAkB;4BAC3B,UAAU,EAAE,kBAAkB;4BAC9B,mBAAmB,EAAE,kBAAkB;yBACxC;wBACD,oBAAoB,EAAE,KAAK;qBAC5B;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD,cAAc,EAAE,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;IAC/C,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC;QACtB,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAuB,MAAM,CAAC,aAAa,IAAI,UAAU,CAAC;QACzE,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC;QACzC,MAAM,SAAS,GA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,CAAC,SAAS,CAAC,IAAI,KAAK,kCAAc,CAAC,UAAU;oBAC/C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI;oBACrB,CAAC,CAAC,qDAAqD;wBACpD,IAAI,CAAC,SAAS,CAAC,IAA4B,CAAC,IAAI,CAAC;gBAExD,IAAI,cAAc,KAAK,WAAW,IAAI,IAAI,CAAC,aAAa,KAAK,QAAQ,EAAE;oBACrE,WAAW,CAAC,6BAA6B,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;iBACtE;aACF;QACH,CAAC;QAED,OAAO;YACL,mBAAmB,EAAE,2CAA2C;YAChE,aAAa,EAAE,kCAAkC;YACjD,gBAAgB,EAAE,gCAAgC;SACnD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/indent.js

@@ -79,6 +79,7 @@
typescript_estree_1.AST_NODE_TYPES.TSTypeOperator,
typescript_estree_1.AST_NODE_TYPES.TSTypeParameter,
typescript_estree_1.AST_NODE_TYPES.TSTypeParameterDeclaration,
+ typescript_estree_1.AST_NODE_TYPES.TSTypeParameterInstantiation,
typescript_estree_1.AST_NODE_TYPES.TSTypeReference,
typescript_estree_1.AST_NODE_TYPES.TSUnionType,
]);

dist/rules/indent.js.map

@@ -1 +1 @@
-{"version":3,"file":"indent.js","sourceRoot":"","sources":["../../src/rules/indent.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;AAEH,4EAAgF;AAChF,qEAA+C;AAC/C,8CAAgC;AAKhC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,qDAAqD;IACrD,kCAAc,CAAC,aAAa;IAE5B,cAAc;IACd,kCAAc,CAAC,iBAAiB;IAChC,kCAAc,CAAC,YAAY;IAC3B,kCAAc,CAAC,gBAAgB;IAC/B,kCAAc,CAAC,cAAc;IAC7B,kCAAc,CAAC,eAAe;IAC9B,kCAAc,CAAC,eAAe;IAC9B,kCAAc,CAAC,eAAe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;oBAE3B,gBAAgB;oBAChB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;iBACd,CAAC,CAAC;YACL,CAAC;YAED,WAAW,CAAC,IAA0B;gBACpC,qCAAqC;gBACrC,OAAO,KAAK,CAAC,+BAA+B,CAAC,CAAC;oBAC5C,IAAI,EAAE,kCAAc,CAAC,eAAe;oBACpC,QAAQ,EAAE,IAAI,CAAC,YAAmB;oBAElC,gBAAgB;oBAChB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;iBACd,CAAC,CAAC;YACL,CAAC;YAED,0BAA0B,CAAC,IAAyC;gBAClE,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;gBAE1C,iEAAiE;gBACjE,iCAAiC;gBACjC,OAAO,KAAK,CAAC,iBAAiB,CAAC;oBAC7B,IAAI,EAAE,kCAAc,CAAC,iBAAiB;oBACtC,WAAW,EAAE,KAAK;oBAClB,IAAI,EAAE,IAAW;oBACjB,UAAU,EAAE,UAAiB;oBAE7B,gBAAgB;oBAChB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;iBACd,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/member-naming.js

@@ -63,6 +63,9 @@
const name = util.getNameFromClassMember(node, sourceCode);
const accessibility = node.accessibility || 'public';
const convention = conventions[accessibility];
+ const method = node;
+ if (method.kind === 'constructor')
+ return;
if (!convention || convention.test(name))
return;
context.report({

dist/rules/member-naming.js.map

@@ -1 +1 @@
-{"version":3,"file":"member-naming.js","sourceRoot":"","sources":["../../src/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C,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAC3D,MAAM,aAAa,GAAc,IAAI,CAAC,aAAa,IAAI,QAAQ,CAAC;YAChE,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;YAE9C,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;gBAAE,OAAO;YAEjD,OAAO,CAAC,MAAM,CAAC;gBACb,IAAI,EAAE,IAAI,CAAC,GAAG;gBACd,SAAS,EAAE,eAAe;gBAC1B,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,EAAE;aAC1C,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,gBAAgB,EAAE,YAAY;YAC9B,aAAa,EAAE,YAAY;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file
+{"version":3,"file":"member-naming.js","sourceRoot":"","sources":["../../src/rules/member-naming.ts"],"names":[],"mappings":";;;;;;;;;AACA,8CAAgC;AAWhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,8DAA8D;YAChE,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,aAAa,EACX,kEAAkE;SACrE;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;wBACd,SAAS,EAAE,CAAC;wBACZ,MAAM,EAAE,OAAO;qBAChB;oBACD,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,SAAS,EAAE,CAAC;wBACZ,MAAM,EAAE,OAAO;qBAChB;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;wBACd,SAAS,EAAE,CAAC;wBACZ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rules/no-extra-parens.js

@@ -0,0 +1,41 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+ result["default"] = mod;
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
+const no_extra_parens_1 = __importDefault(require("eslint/lib/rules/no-extra-parens"));
+const util = __importStar(require("../util"));
+exports.default = util.createRule({
+ name: 'no-extra-parens',
+ meta: {
+ type: 'layout',
+ docs: {
+ description: 'disallow unnecessary parentheses',
+ category: 'Possible Errors',
+ recommended: false,
+ },
+ fixable: 'code',
+ schema: no_extra_parens_1.default.meta.schema,
+ messages: no_extra_parens_1.default.meta.messages,
+ },
+ defaultOptions: ['all'],
+ create(context) {
+ const rules = no_extra_parens_1.default.create(context);
+ return Object.assign({}, rules, {
+ MemberExpression(node) {
+ if (node.object.type !== typescript_estree_1.AST_NODE_TYPES.TSAsExpression) {
+ return rules.MemberExpression(node);
+ }
+ },
+ });
+ },
+});
+//# sourceMappingURL=no-extra-parens.js.map
\ No newline at end of file

dist/rules/no-extra-parens.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"no-extra-parens.js","sourceRoot":"","sources":["../../src/rules/no-extra-parens.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4EAAgF;AAChF,uFAAwD;AACxD,8CAAgC;AAKhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,iBAAiB;YAC3B,WAAW,EAAE,KAAK;SACnB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,yBAAQ,CAAC,IAAI,CAAC,MAAM;QAC5B,QAAQ,EAAE,yBAAQ,CAAC,IAAI,CAAC,QAAQ;KACjC;IACD,cAAc,EAAE,CAAC,KAAK,CAAC;IACvB,MAAM,CAAC,OAAO;QACZ,MAAM,KAAK,GAAG,yBAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEvC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE;YAC9B,gBAAgB,CAAC,IAA+B;gBAC9C,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kCAAc,CAAC,cAAc,EAAE;oBACtD,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;iBACrC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/no-object-literal-type-assertion.js

@@ -49,6 +49,10 @@
case typescript_estree_1.AST_NODE_TYPES.TSAnyKeyword:
case typescript_estree_1.AST_NODE_TYPES.TSUnknownKeyword:
return false;
+ case typescript_estree_1.AST_NODE_TYPES.TSTypeReference:
+ // Ignore `as const` and `<const>` (#166)
+ return (node.typeName.type === typescript_estree_1.AST_NODE_TYPES.Identifier &&
+ node.typeName.name !== 'const');
default:
return true;
}

dist/rules/no-object-literal-type-assertion.js.map

@@ -1 +1 @@
-{"version":3,"file":"no-object-literal-type-assertion.js","sourceRoot":"","sources":["../../src/rules/no-object-literal-type-assertion.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAChF,8CAAgC;AAShC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,kCAAkC;IACxC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,oEAAoE;YACtE,cAAc,EAAE,kCAAkC;YAClD,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,uBAAuB,EACrB,gFAAgF;SACnF;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,gBAAgB,EAAE;wBAChB,IAAI,EAAE,SAAS;qBAChB;iBACF;aACF;SACF;KACF;IACD,cAAc,EAAE;QACd;YACE,gBAAgB,EAAE,KAAK;SACxB;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAC;QACpC;;;WAGG;QACH,SAAS,SAAS,CAAC,IAAuB;YACxC,QAAQ,IAAI,CAAC,IAAI,EAAE;gBACjB,KAAK,kCAAc,CAAC,YAAY,CAAC;gBACjC,KAAK,kCAAc,CAAC,gBAAgB;oBAClC,OAAO,KAAK,CAAC;gBACf;oBACE,OAAO,IAAI,CAAC;aACf;QACH,CAAC;QAED,OAAO;YACL,iCAAiC,CAC/B,IAAwD;gBAExD,IACE,gBAAgB;oBAChB,IAAI,CAAC,MAAM;oBACX,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kCAAc,CAAC,aAAa;wBAChD,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kCAAc,CAAC,cAAc,CAAC,EACrD;oBACA,OAAO;iBACR;gBAED,IACE,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC;oBAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,kCAAc,CAAC,gBAAgB,EACxD;oBACA,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,yBAAyB;qBACrC,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file
+{"version":3,"file":"no-object-literal-type-assertion.js","sourceRoot":"","sources":["../../src/rules/no-object-literal-type-assertion.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAChF,8CAAgC;AAShC,kBAAe,IAAI,CAAC,UAAU,CAAsB;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CAAC;oBAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,kCAAc,CAAC,gBAAgB,EACxD;oBACA,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,yBAAyB;qBACrC,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/no-type-alias.js

@@ -86,6 +86,7 @@
typescript_estree_1.AST_NODE_TYPES.TSArrayType,
typescript_estree_1.AST_NODE_TYPES.TSTypeReference,
typescript_estree_1.AST_NODE_TYPES.TSLiteralType,
+ typescript_estree_1.AST_NODE_TYPES.TSTypeQuery,
];
/**
* Determines if the given node is a union or an intersection.

dist/rules/no-type-alias.js.map

@@ -1 +1 @@
-{"version":3,"file":"no-type-alias.js","sourceRoot":"","sources":["../../src/rules/no-type-alias.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAEhF,8CAAgC;AA2BhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,kCAAkC;YAC/C,cAAc,EAAE,6BAA6B;YAC7C,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,iCAAiC;YAC9C,kBAAkB,EAChB,4DAA4D;SAC/D;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,YAAY,EAAE;wBACZ,IAAI,EAAE;4BACJ,QAAQ;4BACR,OAAO;4BACP,WAAW;4BACX,kBAAkB;4BAClB,6BAA6B;yBAC9B;qBACF;oBACD,cAAc,EAAE;wBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;qBAC1B;oBACD,aAAa,EAAE;wBACb,IAAI,EAAE;4BACJ,QAAQ;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AE,UAAU,CAAC,CAAC,CAAC;aAC/D;QACH,CAAC;QAED;;WAEG;QACH,SAAS,oBAAoB,CAAC,IAAqB;YACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;oBACvB,oBAAoB,CAAC,IAAI,CAAC,CAAC;iBAC5B;qBAAM;oBACL,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC7C;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,sBAAsB,CAAC,IAAI;gBACzB,IAAI,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;oBACtC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;iBAC3C;qBAAM;oBACL,mBAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;iBAChD;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file
+{"version":3,"file":"no-type-alias.js","sourceRoot":"","sources":["../../src/rules/no-type-alias.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAEhF,8CAAgC;AA2BhC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,kCAAkC;YAC/C,cAAc,EAAE,6BAA6B;YAC7C,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,iCAAiC;YAC9C,kBAAkB,EAChB,4DAA4D;SAC/D;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,YAAY,EAAE;wBACZ,IAAI,EAAE;4BACJ,QAAQ;4BACR,OAAO;4BACP,WAA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AAa,CAAC,EACnE;oBACA,OAAO,CAAC,MAAM,CACZ,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,CAAC,CACzD,CAAC;iBACH;aACF;iBAAM;gBACL,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC;aAC/D;QACH,CAAC;QAED;;WAEG;QACH,SAAS,oBAAoB,CAAC,IAAqB;YACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;oBACvB,oBAAoB,CAAC,IAAI,CAAC,CAAC;iBAC5B;qBAAM;oBACL,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC7C;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,sBAAsB,CAAC,IAAI;gBACzB,IAAI,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;oBACtC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;iBAC3C;qBAAM;oBACL,mBAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;iBAChD;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/prefer-for-of.js

@@ -0,0 +1,166 @@
+"use strict";
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+ result["default"] = mod;
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
+const util = __importStar(require("../util"));
+exports.default = util.createRule({
+ name: 'prefer-for-of',
+ meta: {
+ type: 'suggestion',
+ docs: {
+ description: 'Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated.',
+ category: 'Stylistic Issues',
+ recommended: false,
+ tslintName: 'prefer-for-of',
+ },
+ messages: {
+ preferForOf: 'Expected a `for-of` loop instead of a `for` loop with this simple iteration',
+ },
+ schema: [],
+ },
+ defaultOptions: [],
+ create(context) {
+ function isSingleVariableDeclaration(node) {
+ return (node !== null &&
+ node.type === typescript_estree_1.AST_NODE_TYPES.VariableDeclaration &&
+ node.kind !== 'const' &&
+ node.declarations.length === 1);
+ }
+ function isLiteral(node, value) {
+ return node.type === typescript_estree_1.AST_NODE_TYPES.Literal && node.value === value;
+ }
+ function isZeroInitialized(node) {
+ return node.init !== null && isLiteral(node.init, 0);
+ }
+ function isMatchingIdentifier(node, name) {
+ return node.type === typescript_estree_1.AST_NODE_TYPES.Identifier && node.name === name;
+ }
+ function isLessThanLengthExpression(node, name) {
+ if (node !== null &&
+ node.type === typescript_estree_1.AST_NODE_TYPES.BinaryExpression &&
+ node.operator === '<' &&
+ isMatchingIdentifier(node.left, name) &&
+ node.right.type === typescript_estree_1.AST_NODE_TYPES.MemberExpression &&
+ isMatchingIdentifier(node.right.property, 'length')) {
+ return node.right.object;
+ }
+ return null;
+ }
+ function isIncrement(node, name) {
+ if (!node) {
+ return false;
+ }
+ switch (node.type) {
+ case typescript_estree_1.AST_NODE_TYPES.UpdateExpression:
+ // x++ or ++x
+ return (node.operator === '++' && isMatchingIdentifier(node.argument, name));
+ case typescript_estree_1.AST_NODE_TYPES.AssignmentExpression:
+ if (isMatchingIdentifier(node.left, name)) {
+ if (node.operator === '+=') {
+ // x += 1
+ return isLiteral(node.right, 1);
+ }
+ else if (node.operator === '=') {
+ // x = x + 1 or x = 1 + x
+ const expr = node.right;
+ return (expr.type === typescript_estree_1.AST_NODE_TYPES.BinaryExpression &&
+ expr.operator === '+' &&
+ ((isMatchingIdentifier(expr.left, name) &&
+ isLiteral(expr.right, 1)) ||
+ (isLiteral(expr.left, 1) &&
+ isMatchingIdentifier(expr.right, name))));
+ }
+ }
+ }
+ return false;
+ }
+ function contains(outer, inner) {
+ return (outer.range[0] <= inner.range[0] && outer.range[1] >= inner.range[1]);
+ }
+ function isAssignee(node) {
+ const parent = node.parent;
+ if (!parent) {
+ return false;
+ }
+ // a[i] = 1, a[i] += 1, etc.
+ if (parent.type === typescript_estree_1.AST_NODE_TYPES.AssignmentExpression &&
+ parent.left === node) {
+ return true;
+ }
+ // delete a[i]
+ if (parent.type === typescript_estree_1.AST_NODE_TYPES.UnaryExpression &&
+ parent.operator === 'delete' &&
+ parent.argument === node) {
+ return true;
+ }
+ // a[i]++, --a[i], etc.
+ if (parent.type === typescript_estree_1.AST_NODE_TYPES.UpdateExpression &&
+ parent.argument === node) {
+ return true;
+ }
+ // [a[i]] = [0]
+ if (parent.type === typescript_estree_1.AST_NODE_TYPES.ArrayPattern) {
+ return true;
+ }
+ // [...a[i]] = [0]
+ if (parent.type === typescript_estree_1.AST_NODE_TYPES.RestElement) {
+ return true;
+ }
+ // ({ foo: a[i] }) = { foo: 0 }
+ if (parent.type === typescript_estree_1.AST_NODE_TYPES.Property &&
+ parent.parent !== undefined &&
+ parent.parent.type === typescript_estree_1.AST_NODE_TYPES.ObjectExpression &&
+ parent.value === node &&
+ isAssignee(parent.parent)) {
+ return true;
+ }
+ return false;
+ }
+ function isIndexOnlyUsedWithArray(body, indexVar, arrayExpression) {
+ const sourceCode = context.getSourceCode();
+ const arrayText = sourceCode.getText(arrayExpression);
+ return indexVar.references.every(reference => {
+ const id = reference.identifier;
+ const node = id.parent;
+ return (!contains(body, id) ||
+ (node !== undefined &&
+ node.type === typescript_estree_1.AST_NODE_TYPES.MemberExpression &&
+ node.property === id &&
+ sourceCode.getText(node.object) === arrayText &&
+ !isAssignee(node)));
+ });
+ }
+ return {
+ 'ForStatement:exit'(node) {
+ if (!isSingleVariableDeclaration(node.init)) {
+ return;
+ }
+ const [declarator] = node.init.declarations;
+ if (!isZeroInitialized(declarator) ||
+ declarator.id.type !== typescript_estree_1.AST_NODE_TYPES.Identifier) {
+ return;
+ }
+ const indexName = declarator.id.name;
+ const arrayExpression = isLessThanLengthExpression(node.test, indexName);
+ if (!arrayExpression) {
+ return;
+ }
+ const [indexVar] = context.getDeclaredVariables(node.init);
+ if (isIncrement(node.update, indexName) &&
+ isIndexOnlyUsedWithArray(node.body, indexVar, arrayExpression)) {
+ context.report({
+ node,
+ messageId: 'preferForOf',
+ });
+ }
+ },
+ };
+ },
+});
+//# sourceMappingURL=prefer-for-of.js.map
\ No newline at end of file

dist/rules/prefer-for-of.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"prefer-for-of.js","sourceRoot":"","sources":["../../src/rules/prefer-for-of.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAChF,8CAAgC;AAGhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EACT,iHAAiH;YACnH,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EAAE,KAAK;YAClB,UAAU,EAAE,eAAe;SAC5B;QACD,QAAQ,EAAE;YACR,WAAW,EACT,6EAA6E;SAChF;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,SAAS,2BAA2B,CAClC,IAA0B;YAE1B,OAAO,CACL,IAAI,KAAK,IAAI;gBACb,IAAI,CAAC,IAAI,KAAK,kCAAc,CAAC,mBAAmB;gBAChD,IAAI,CAAC,IAAI,KAAK,OAAO;gBACrB,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,CAC/B,CAAC;QACJ,CAAC;QAED,SAAS,SAAS,CAAC,IAAyB,EAAE,KAAa;YACzD,OAAO,IAAI,CAAC,IAAI,KAAK,kCAAc,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC;QACtE,CAAC;QAED,SAAS,iBAAi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,kCAAc,CAAC,gBAAgB;wBAC7C,IAAI,CAAC,QAAQ,KAAK,EAAE;wBACpB,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,SAAS;wBAC7C,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CACrB,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,mBAAmB,CAAC,IAA2B;gBAC7C,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBAC3C,OAAO;iBACR;gBAED,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC5C,IACE,CAAC,iBAAiB,CAAC,UAAU,CAAC;oBAC9B,UAAU,CAAC,EAAE,CAAC,IAAI,KAAK,kCAAc,CAAC,UAAU,EAChD;oBACA,OAAO;iBACR;gBAED,MAAM,SAAS,GAAG,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC;gBACrC,MAAM,eAAe,GAAG,0BAA0B,CAChD,IAAI,CAAC,IAAI,EACT,SAAS,CACV,CAAC;gBACF,IAAI,CAAC,eAAe,EAAE;oBACpB,OAAO;iBACR;gBAED,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC3D,IACE,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;oBACnC,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,CAAC,EAC9D;oBACA,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,aAAa;qBACzB,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/prefer-includes.js

@@ -0,0 +1,170 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const eslint_utils_1 = require("eslint-utils");
+const regexpp_1 = require("regexpp");
+const typescript_1 = __importDefault(require("typescript"));
+const util_1 = require("../util");
+exports.default = util_1.createRule({
+ name: 'prefer-includes',
+ defaultOptions: [],
+ meta: {
+ type: 'suggestion',
+ docs: {
+ description: 'Enforce `includes` method over `indexOf` method',
+ category: 'Best Practices',
+ recommended: false,
+ },
+ fixable: 'code',
+ messages: {
+ preferIncludes: "Use 'includes()' method instead.",
+ preferStringIncludes: 'Use `String#includes()` method with a string instead.',
+ },
+ schema: [],
+ },
+ create(context) {
+ const globalScope = context.getScope();
+ const services = util_1.getParserServices(context);
+ const types = services.program.getTypeChecker();
+ function isNumber(node, value) {
+ const evaluated = eslint_utils_1.getStaticValue(node, globalScope);
+ return evaluated !== null && evaluated.value === value;
+ }
+ function isPositiveCheck(node) {
+ switch (node.operator) {
+ case '!==':
+ case '!=':
+ case '>':
+ return isNumber(node.right, -1);
+ case '>=':
+ return isNumber(node.right, 0);
+ default:
+ return false;
+ }
+ }
+ function isNegativeCheck(node) {
+ switch (node.operator) {
+ case '===':
+ case '==':
+ case '<=':
+ return isNumber(node.right, -1);
+ case '<':
+ return isNumber(node.right, 0);
+ default:
+ return false;
+ }
+ }
+ function hasSameParameters(nodeA, nodeB) {
+ if (!typescript_1.default.isFunctionLike(nodeA) || !typescript_1.default.isFunctionLike(nodeB)) {
+ return false;
+ }
+ const paramsA = nodeA.parameters;
+ const paramsB = nodeB.parameters;
+ if (paramsA.length !== paramsB.length) {
+ return false;
+ }
+ for (let i = 0; i < paramsA.length; ++i) {
+ const paramA = paramsA[i];
+ const paramB = paramsB[i];
+ // Check name, type, and question token once.
+ if (paramA.getText() !== paramB.getText()) {
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * Parse a given node if it's a `RegExp` instance.
+ * @param node The node to parse.
+ */
+ function parseRegExp(node) {
+ const evaluated = eslint_utils_1.getStaticValue(node, globalScope);
+ if (evaluated == null || !(evaluated.value instanceof RegExp)) {
+ return null;
+ }
+ const { pattern, flags } = regexpp_1.parseRegExpLiteral(evaluated.value);
+ if (pattern.alternatives.length !== 1 ||
+ flags.ignoreCase ||
+ flags.global) {
+ return null;
+ }
+ // Check if it can determine a unique string.
+ const chars = pattern.alternatives[0].elements;
+ if (!chars.every(c => c.type === 'Character')) {
+ return null;
+ }
+ // To string.
+ return String.fromCodePoint(...chars.map(c => c.value));
+ }
+ return {
+ "BinaryExpression > CallExpression.left > MemberExpression.callee[property.name='indexOf'][computed=false]"(node) {
+ // Check if the comparison is equivalent to `includes()`.
+ const callNode = node.parent;
+ const compareNode = callNode.parent;
+ const negative = isNegativeCheck(compareNode);
+ if (!negative && !isPositiveCheck(compareNode)) {
+ return;
+ }
+ // Get the symbol of `indexOf` method.
+ const tsNode = services.esTreeNodeToTSNodeMap.get(node.property);
+ const indexofMethodSymbol = types.getSymbolAtLocation(tsNode);
+ if (indexofMethodSymbol == null ||
+ indexofMethodSymbol.declarations.length === 0) {
+ return;
+ }
+ // Check if every declaration of `indexOf` method has `includes` method
+ // and the two methods have the same parameters.
+ for (const instanceofMethodDecl of indexofMethodSymbol.declarations) {
+ const typeDecl = instanceofMethodDecl.parent;
+ const type = types.getTypeAtLocation(typeDecl);
+ const includesMethodSymbol = type.getProperty('includes');
+ if (includesMethodSymbol == null ||
+ !includesMethodSymbol.declarations.some(includesMethodDecl => hasSameParameters(includesMethodDecl, instanceofMethodDecl))) {
+ return;
+ }
+ }
+ // Report it.
+ context.report({
+ node: compareNode,
+ messageId: 'preferIncludes',
+ *fix(fixer) {
+ if (negative) {
+ yield fixer.insertTextBefore(callNode, '!');
+ }
+ yield fixer.replaceText(node.property, 'includes');
+ yield fixer.removeRange([callNode.range[1], compareNode.range[1]]);
+ },
+ });
+ },
+ // /bar/.test(foo)
+ 'CallExpression > MemberExpression.callee[property.name="test"][computed=false]'(node) {
+ const callNode = node.parent;
+ const text = callNode.arguments.length === 1 ? parseRegExp(node.object) : null;
+ if (text == null) {
+ return;
+ }
+ context.report({
+ node: callNode,
+ messageId: 'preferStringIncludes',
+ *fix(fixer) {
+ const argNode = callNode.arguments[0];
+ const needsParen = argNode.type !== 'Literal' &&
+ argNode.type !== 'TemplateLiteral' &&
+ argNode.type !== 'Identifier' &&
+ argNode.type !== 'MemberExpression' &&
+ argNode.type !== 'CallExpression';
+ yield fixer.removeRange([callNode.range[0], argNode.range[0]]);
+ if (needsParen) {
+ yield fixer.insertTextBefore(argNode, '(');
+ yield fixer.insertTextAfter(argNode, ')');
+ }
+ yield fixer.insertTextAfter(argNode, `.includes(${JSON.stringify(text)}`);
+ },
+ });
+ },
+ };
+ },
+});
+//# sourceMappingURL=prefer-includes.js.map
\ No newline at end of file

dist/rules/prefer-includes.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"prefer-includes.js","sourceRoot":"","sources":["../../src/rules/prefer-includes.ts"],"names":[],"mappings":";;;;;AACA,+CAA8C;AAC9C,qCAA+D;AAC/D,4DAA4B;AAC5B,kCAAwD;AAExD,kBAAe,iBAAU,CAAC;IACxB,IAAI,EAAE,iBAAiB;IACvB,cAAc,EAAE,EAAE;IAElB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;YAC9D,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,KAAK;SACnB;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,cAAc,EAAE,kCAAkC;YAClD,oBAAoB,EAClB,uDAAuD;SAC1D;QACD,MAAM,EAAE,EAAE;KACX;IAED,MAAM,CAAC,OAAO;QACZ,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,wBAAiB,CAAC,OAAO,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAEhD,SAAS,QAAQ,C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CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;4BAC3C,MAAM,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;yBAC3C;wBACD,MAAM,KAAK,CAAC,eAAe,CACzB,OAAO,EACP,aAAa,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CACpC,CAAC;oBACJ,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/prefer-string-starts-ends-with.js

@@ -0,0 +1,482 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const eslint_utils_1 = require("eslint-utils");
+const regexpp_1 = require("regexpp");
+const typescript_1 = __importDefault(require("typescript"));
+const util_1 = require("../util");
+const EQ_OPERATORS = /^[=!]=/;
+const regexpp = new regexpp_1.RegExpParser();
+exports.default = util_1.createRule({
+ name: 'prefer-string-starts-ends-with',
+ defaultOptions: [],
+ meta: {
+ type: 'suggestion',
+ docs: {
+ description: 'enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings',
+ category: 'Best Practices',
+ recommended: false,
+ },
+ messages: {
+ preferStartsWith: "Use 'String#startsWith' method instead.",
+ preferEndsWith: "Use the 'String#endsWith' method instead.",
+ },
+ schema: [],
+ fixable: 'code',
+ },
+ create(context) {
+ const globalScope = context.getScope();
+ const sourceCode = context.getSourceCode();
+ const service = util_1.getParserServices(context);
+ const types = service.program.getTypeChecker();
+ /**
+ * Get the type name of a given type.
+ * @param type The type to get.
+ */
+ function getTypeName(type) {
+ // It handles `string` and string literal types as string.
+ if ((type.flags & typescript_1.default.TypeFlags.StringLike) !== 0) {
+ return 'string';
+ }
+ // If the type is a type parameter which extends primitive string types,
+ // but it was not recognized as a string like. So check the constraint
+ // type of the type parameter.
+ if ((type.flags & typescript_1.default.TypeFlags.TypeParameter) !== 0) {
+ // `type.getConstraint()` method doesn't return the constraint type of
+ // the type parameter for some reason. So this gets the constraint type
+ // via AST.
+ const node = type.symbol.declarations[0];
+ if (node.constraint != null) {
+ return getTypeName(types.getTypeFromTypeNode(node.constraint));
+ }
+ }
+ // If the type is a union and all types in the union are string like,
+ // return `string`. For example:
+ // - `"a" | "b"` is string.
+ // - `string | string[]` is not string.
+ if (type.isUnion() &&
+ type.types.map(getTypeName).every(t => t === 'string')) {
+ return 'string';
+ }
+ // If the type is an intersection and a type in the intersection is string
+ // like, return `string`. For example: `string & {__htmlEscaped: void}`
+ if (type.isIntersection() &&
+ type.types.map(getTypeName).some(t => t === 'string')) {
+ return 'string';
+ }
+ return types.typeToString(type);
+ }
+ /**
+ * Check if a given node is a string.
+ * @param node The node to check.
+ */
+ function isStringType(node) {
+ const objectType = types.getTypeAtLocation(service.esTreeNodeToTSNodeMap.get(node));
+ const typeName = getTypeName(objectType);
+ return typeName === 'string';
+ }
+ /**
+ * Check if a given node is a `Literal` node that is null.
+ * @param node The node to check.
+ */
+ function isNull(node) {
+ const evaluated = eslint_utils_1.getStaticValue(node, globalScope);
+ return evaluated != null && evaluated.value === null;
+ }
+ /**
+ * Check if a given node is a `Literal` node that is a given value.
+ * @param node The node to check.
+ * @param value The expected value of the `Literal` node.
+ */
+ function isNumber(node, value) {
+ const evaluated = eslint_utils_1.getStaticValue(node, globalScope);
+ return evaluated != null && evaluated.value === value;
+ }
+ /**
+ * Check if a given node is a `Literal` node that is a character.
+ * @param node The node to check.
+ * @param kind The method name to get a character.
+ */
+ function isCharacter(node) {
+ const evaluated = eslint_utils_1.getStaticValue(node, globalScope);
+ return (evaluated != null &&
+ typeof evaluated.value === 'string' &&
+ evaluated.value[0] === evaluated.value);
+ }
+ /**
+ * Check if a given node is `==`, `===`, `!=`, or `!==`.
+ * @param node The node to check.
+ */
+ function isEqualityComparison(node) {
+ return (node.type === 'BinaryExpression' && EQ_OPERATORS.test(node.operator));
+ }
+ /**
+ * Check if two given nodes are the same meaning.
+ * @param node1 A node to compare.
+ * @param node2 Another node to compare.
+ */
+ function isSameTokens(node1, node2) {
+ const tokens1 = sourceCode.getTokens(node1);
+ const tokens2 = sourceCode.getTokens(node2);
+ if (tokens1.length !== tokens2.length) {
+ return false;
+ }
+ for (let i = 0; i < tokens1.length; ++i) {
+ const token1 = tokens1[i];
+ const token2 = tokens2[i];
+ if (token1.type !== token2.type || token1.value !== token2.value) {
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * Check if a given node is the expression of the length of a string.
+ *
+ * - If `length` property access of `expectedObjectNode`, it's `true`.
+ * E.g., `foo` → `foo.length` / `"foo"` → `"foo".length`
+ * - If `expectedObjectNode` is a string literal, `node` can be a number.
+ * E.g., `"foo"` → `3`
+ *
+ * @param node The node to check.
+ * @param expectedObjectNode The node which is expected as the receiver of `length` property.
+ */
+ function isLengthExpression(node, expectedObjectNode) {
+ if (node.type === 'MemberExpression') {
+ return (eslint_utils_1.getPropertyName(node, globalScope) === 'length' &&
+ isSameTokens(node.object, expectedObjectNode));
+ }
+ const evaluatedLength = eslint_utils_1.getStaticValue(node, globalScope);
+ const evaluatedString = eslint_utils_1.getStaticValue(expectedObjectNode, globalScope);
+ return (evaluatedLength != null &&
+ evaluatedString != null &&
+ typeof evaluatedLength.value === 'number' &&
+ typeof evaluatedString.value === 'string' &&
+ evaluatedLength.value === evaluatedString.value.length);
+ }
+ /**
+ * Check if a given node is the expression of the last index.
+ *
+ * E.g. `foo.length - 1`
+ *
+ * @param node The node to check.
+ * @param expectedObjectNode The node which is expected as the receiver of `length` property.
+ */
+ function isLastIndexExpression(node, expectedObjectNode) {
+ return (node.type === 'BinaryExpression' &&
+ node.operator === '-' &&
+ isLengthExpression(node.left, expectedObjectNode) &&
+ isNumber(node.right, 1));
+ }
+ /**
+ * Get the range of the property of a given `MemberExpression` node.
+ *
+ * - `obj[foo]` → the range of `[foo]`
+ * - `obf.foo` → the range of `.foo`
+ * - `(obj).foo` → the range of `.foo`
+ *
+ * @param node The member expression node to get.
+ */
+ function getPropertyRange(node) {
+ const dotOrOpenBracket = sourceCode.getTokenAfter(node.object, eslint_utils_1.isNotClosingParenToken);
+ return [dotOrOpenBracket.range[0], node.range[1]];
+ }
+ /**
+ * Parse a given `RegExp` pattern to that string if it's a static string.
+ * @param pattern The RegExp pattern text to parse.
+ * @param uFlag The Unicode flag of the RegExp.
+ */
+ function parseRegExpText(pattern, uFlag) {
+ // Parse it.
+ const ast = regexpp.parsePattern(pattern, undefined, undefined, uFlag);
+ if (ast.alternatives.length !== 1) {
+ return null;
+ }
+ // Drop `^`/`$` assertion.
+ const chars = ast.alternatives[0].elements;
+ const first = chars[0];
+ if (first.type === 'Assertion' && first.kind === 'start') {
+ chars.shift();
+ }
+ else {
+ chars.pop();
+ }
+ // Check if it can determine a unique string.
+ if (!chars.every(c => c.type === 'Character')) {
+ return null;
+ }
+ // To string.
+ return String.fromCodePoint(...chars.map(c => c.value));
+ }
+ /**
+ * Parse a given node if it's a `RegExp` instance.
+ * @param node The node to parse.
+ */
+ function parseRegExp(node) {
+ const evaluated = eslint_utils_1.getStaticValue(node, globalScope);
+ if (evaluated == null || !(evaluated.value instanceof RegExp)) {
+ return null;
+ }
+ const { source, flags } = evaluated.value;
+ const isStartsWith = source.startsWith('^');
+ const isEndsWith = source.endsWith('$');
+ if (isStartsWith === isEndsWith ||
+ flags.includes('i') ||
+ flags.includes('m')) {
+ return null;
+ }
+ const text = parseRegExpText(source, flags.includes('u'));
+ if (text == null) {
+ return null;
+ }
+ return { isEndsWith, isStartsWith, text };
+ }
+ /**
+ * Fix code with using the right operand as the search string.
+ * For example: `foo.slice(0, 3) === 'bar'` → `foo.startsWith('bar')`
+ * @param fixer The rule fixer.
+ * @param node The node which was reported.
+ * @param kind The kind of the report.
+ * @param negative The flag to fix to negative condition.
+ */
+ function* fixWithRightOperand(fixer, node, kind, negative) {
+ // left is CallExpression or MemberExpression.
+ const leftNode = (node.left.type === 'CallExpression'
+ ? node.left.callee
+ : node.left);
+ const propertyRange = getPropertyRange(leftNode);
+ if (negative) {
+ yield fixer.insertTextBefore(node, '!');
+ }
+ yield fixer.replaceTextRange([propertyRange[0], node.right.range[0]], `.${kind}sWith(`);
+ yield fixer.replaceTextRange([node.right.range[1], node.range[1]], ')');
+ }
+ /**
+ * Fix code with using the first argument as the search string.
+ * For example: `foo.indexOf('bar') === 0` → `foo.startsWith('bar')`
+ * @param fixer The rule fixer.
+ * @param node The node which was reported.
+ * @param kind The kind of the report.
+ * @param negative The flag to fix to negative condition.
+ */
+ function* fixWithArgument(fixer, node, kind, negative) {
+ const callNode = node.left;
+ const calleeNode = callNode.callee;
+ if (negative) {
+ yield fixer.insertTextBefore(node, '!');
+ }
+ yield fixer.replaceTextRange(getPropertyRange(calleeNode), `.${kind}sWith`);
+ yield fixer.removeRange([callNode.range[1], node.range[1]]);
+ }
+ return {
+ // foo[0] === "a"
+ // foo.charAt(0) === "a"
+ // foo[foo.length - 1] === "a"
+ // foo.charAt(foo.length - 1) === "a"
+ [String([
+ 'BinaryExpression > MemberExpression.left[computed=true]',
+ 'BinaryExpression > CallExpression.left > MemberExpression.callee[property.name="charAt"][computed=false]',
+ ])](node) {
+ let parentNode = node.parent;
+ let indexNode = null;
+ if (parentNode.type === 'CallExpression') {
+ if (parentNode.arguments.length === 1) {
+ indexNode = parentNode.arguments[0];
+ }
+ parentNode = parentNode.parent;
+ }
+ else {
+ indexNode = node.property;
+ }
+ if (indexNode == null ||
+ !isEqualityComparison(parentNode) ||
+ !isStringType(node.object)) {
+ return;
+ }
+ const isEndsWith = isLastIndexExpression(indexNode, node.object);
+ const isStartsWith = !isEndsWith && isNumber(indexNode, 0);
+ if (!isStartsWith && !isEndsWith) {
+ return;
+ }
+ const eqNode = parentNode;
+ context.report({
+ node: parentNode,
+ messageId: isStartsWith ? 'preferStartsWith' : 'preferEndsWith',
+ fix(fixer) {
+ // Don't fix if it can change the behavior.
+ if (!isCharacter(eqNode.right)) {
+ return null;
+ }
+ return fixWithRightOperand(fixer, eqNode, isStartsWith ? 'start' : 'end', eqNode.operator.startsWith('!'));
+ },
+ });
+ },
+ // foo.indexOf('bar') === 0
+ 'BinaryExpression > CallExpression.left > MemberExpression.callee[property.name="indexOf"][computed=false]'(node) {
+ const callNode = node.parent;
+ const parentNode = callNode.parent;
+ if (callNode.arguments.length !== 1 ||
+ !isEqualityComparison(parentNode) ||
+ parentNode.left !== callNode ||
+ !isNumber(parentNode.right, 0) ||
+ !isStringType(node.object)) {
+ return;
+ }
+ context.report({
+ node: parentNode,
+ messageId: 'preferStartsWith',
+ fix(fixer) {
+ return fixWithArgument(fixer, parentNode, 'start', parentNode.operator.startsWith('!'));
+ },
+ });
+ },
+ // foo.lastIndexOf('bar') === foo.length - 3
+ // foo.lastIndexOf(bar) === foo.length - bar.length
+ 'BinaryExpression > CallExpression.left > MemberExpression.callee[property.name="lastIndexOf"][computed=false]'(node) {
+ const callNode = node.parent;
+ const parentNode = callNode.parent;
+ if (callNode.arguments.length !== 1 ||
+ !isEqualityComparison(parentNode) ||
+ parentNode.left !== callNode ||
+ parentNode.right.type !== 'BinaryExpression' ||
+ parentNode.right.operator !== '-' ||
+ !isLengthExpression(parentNode.right.left, node.object) ||
+ !isLengthExpression(parentNode.right.right, callNode.arguments[0]) ||
+ !isStringType(node.object)) {
+ return;
+ }
+ context.report({
+ node: parentNode,
+ messageId: 'preferEndsWith',
+ fix(fixer) {
+ return fixWithArgument(fixer, parentNode, 'end', parentNode.operator.startsWith('!'));
+ },
+ });
+ },
+ // foo.match(/^bar/) === null
+ // foo.match(/bar$/) === null
+ 'BinaryExpression > CallExpression.left > MemberExpression.callee[property.name="match"][computed=false]'(node) {
+ const callNode = node.parent;
+ const parentNode = callNode.parent;
+ if (!isEqualityComparison(parentNode) ||
+ !isNull(parentNode.right) ||
+ !isStringType(node.object)) {
+ return;
+ }
+ const parsed = callNode.arguments.length === 1
+ ? parseRegExp(callNode.arguments[0])
+ : null;
+ if (parsed == null) {
+ return;
+ }
+ const { isStartsWith, text } = parsed;
+ context.report({
+ node: callNode,
+ messageId: isStartsWith ? 'preferStartsWith' : 'preferEndsWith',
+ *fix(fixer) {
+ if (!parentNode.operator.startsWith('!')) {
+ yield fixer.insertTextBefore(parentNode, '!');
+ }
+ yield fixer.replaceTextRange(getPropertyRange(node), `.${isStartsWith ? 'start' : 'end'}sWith`);
+ yield fixer.replaceText(callNode.arguments[0], JSON.stringify(text));
+ yield fixer.removeRange([callNode.range[1], parentNode.range[1]]);
+ },
+ });
+ },
+ // foo.slice(0, 3) === 'bar'
+ // foo.slice(-3) === 'bar'
+ // foo.slice(-3, foo.length) === 'bar'
+ // foo.substring(0, 3) === 'bar'
+ // foo.substring(foo.length - 3) === 'bar'
+ // foo.substring(foo.length - 3, foo.length) === 'bar'
+ [String([
+ 'CallExpression > MemberExpression.callee[property.name=slice][computed=false]',
+ 'CallExpression > MemberExpression.callee[property.name=substring][computed=false]',
+ ])](node) {
+ const callNode = node.parent;
+ const parentNode = callNode.parent;
+ if (!isEqualityComparison(parentNode) ||
+ parentNode.left !== callNode ||
+ !isStringType(node.object)) {
+ return;
+ }
+ const isEndsWith = callNode.arguments.length === 1 ||
+ (callNode.arguments.length === 2 &&
+ isLengthExpression(callNode.arguments[1], node.object));
+ const isStartsWith = !isEndsWith &&
+ callNode.arguments.length === 2 &&
+ isNumber(callNode.arguments[0], 0);
+ if (!isStartsWith && !isEndsWith) {
+ return;
+ }
+ const eqNode = parentNode;
+ const negativeIndexSupported = node.property.name === 'slice';
+ context.report({
+ node: parentNode,
+ messageId: isStartsWith ? 'preferStartsWith' : 'preferEndsWith',
+ fix(fixer) {
+ // Don't fix if it can change the behavior.
+ if (eqNode.operator.length === 2 &&
+ (eqNode.right.type !== 'Literal' ||
+ typeof eqNode.right.value !== 'string')) {
+ return null;
+ }
+ if (isStartsWith) {
+ if (!isLengthExpression(callNode.arguments[1], eqNode.right)) {
+ return null;
+ }
+ }
+ else {
+ const posNode = callNode.arguments[0];
+ const posNodeIsAbsolutelyValid = (posNode.type === 'BinaryExpression' &&
+ posNode.operator === '-' &&
+ isLengthExpression(posNode.left, node.object) &&
+ isLengthExpression(posNode.right, eqNode.right)) ||
+ (negativeIndexSupported &&
+ posNode.type === 'UnaryExpression' &&
+ posNode.operator === '-' &&
+ isLengthExpression(posNode.argument, eqNode.right));
+ if (!posNodeIsAbsolutelyValid) {
+ return null;
+ }
+ }
+ return fixWithRightOperand(fixer, parentNode, isStartsWith ? 'start' : 'end', parentNode.operator.startsWith('!'));
+ },
+ });
+ },
+ // /^bar/.test(foo)
+ // /bar$/.test(foo)
+ 'CallExpression > MemberExpression.callee[property.name="test"][computed=false]'(node) {
+ const callNode = node.parent;
+ const parsed = callNode.arguments.length === 1 ? parseRegExp(node.object) : null;
+ if (parsed == null) {
+ return;
+ }
+ const { isStartsWith, text } = parsed;
+ const messageId = isStartsWith ? 'preferStartsWith' : 'preferEndsWith';
+ const methodName = isStartsWith ? 'startsWith' : 'endsWith';
+ context.report({
+ node: callNode,
+ messageId,
+ *fix(fixer) {
+ const argNode = callNode.arguments[0];
+ const needsParen = argNode.type !== 'Literal' &&
+ argNode.type !== 'TemplateLiteral' &&
+ argNode.type !== 'Identifier' &&
+ argNode.type !== 'MemberExpression' &&
+ argNode.type !== 'CallExpression';
+ yield fixer.removeRange([callNode.range[0], argNode.range[0]]);
+ if (needsParen) {
+ yield fixer.insertTextBefore(argNode, '(');
+ yield fixer.insertTextAfter(argNode, ')');
+ }
+ yield fixer.insertTextAfter(argNode, `.${methodName}(${JSON.stringify(text)}`);
+ },
+ });
+ },
+ };
+ },
+});
+//# sourceMappingURL=prefer-string-starts-ends-with.js.map
\ No newline at end of file

dist/rules/prefer-string-starts-ends-with.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"prefer-string-starts-ends-with.js","sourceRoot":"","sources":["../../src/rules/prefer-string-starts-ends-with.ts"],"names":[],"mappings":";;;;;AACA,+CAIsB;AACtB,qCAAyD;AAEzD,4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AAC,CAAC;yBAC3C;wBACD,MAAM,KAAK,CAAC,eAAe,CACzB,OAAO,EACP,IAAI,UAAU,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CACzC,CAAC;oBACJ,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/restrict-plus-operands.js

@@ -54,7 +54,9 @@
return types.every(value => value === types[0]) ? types[0] : 'invalid';
}
const stringType = typeChecker.typeToString(type);
- if (stringType === 'number' || stringType === 'string') {
+ if (stringType === 'number' ||
+ stringType === 'string' ||
+ stringType === 'bigint') {
return stringType;
}
return 'invalid';

dist/rules/restrict-plus-operands.js.map

@@ -1 +1 @@
-{"version":3,"file":"restrict-plus-operands.js","sourceRoot":"","sources":["../../src/rules/restrict-plus-operands.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,4DAA4B;AAC5B,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,oFAAoF;YACtF,cAAc,EAAE,wBAAwB;YACxC,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,UAAU,EACR,wEAAwE;YAC1E,UAAU,EACR,2GAA2G;YAC7G,UAAU,EAAE,iDAAiD;SAC9D;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAIrD;;;;WAIG;QACH,SAAS,wBAAwB,CAAC,IAAa;YAC7C,IAAI,IAAI,CAAC,eAAe,EAAE,EA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K,SAAS,EACtB;oBACA,IAAI,QAAQ,KAAK,QAAQ,IAAI,SAAS,KAAK,QAAQ,EAAE;wBACnD,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,YAAY;yBACxB,CAAC,CAAC;qBACJ;yBAAM,IAAI,QAAQ,KAAK,QAAQ,IAAI,SAAS,KAAK,QAAQ,EAAE;wBAC1D,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,YAAY;yBACxB,CAAC,CAAC;qBACJ;yBAAM;wBACL,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,YAAY;yBACxB,CAAC,CAAC;qBACJ;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file
+{"version":3,"file":"restrict-plus-operands.js","sourceRoot":"","sources":["../../src/rules/restrict-plus-operands.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,4DAA4B;AAC5B,8CAAgC;AAEhC,kBAAe,IAAI,CAAC,UAAU,CAAC;IAC7B,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,oFAAoF;YACtF,cAAc,EAAE,wBAAwB;YACxC,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,KAAK;SACnB;QACD,QAAQ,EAAE;YACR,UAAU,EACR,wEAAwE;YAC1E,UAAU,EACR,2GAA2G;YAC7G,UAAU,EAAE,iDAAiD;SAC9D;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAEhD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAIrD;;;;WAIG;QACH,SAAS,wBAAwB,CAAC,IAAa;YA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QAAQ,KAAK,SAAS;oBACtB,SAAS,KAAK,SAAS;oBACvB,QAAQ,KAAK,SAAS,EACtB;oBACA,IAAI,QAAQ,KAAK,QAAQ,IAAI,SAAS,KAAK,QAAQ,EAAE;wBACnD,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,YAAY;yBACxB,CAAC,CAAC;qBACJ;yBAAM,IAAI,QAAQ,KAAK,QAAQ,IAAI,SAAS,KAAK,QAAQ,EAAE;wBAC1D,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,YAAY;yBACxB,CAAC,CAAC;qBACJ;yBAAM;wBACL,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,YAAY;yBACxB,CAAC,CAAC;qBACJ;iBACF;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
\ No newline at end of file

dist/rules/unbound-method.js

@@ -0,0 +1,98 @@
+"use strict";
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+ result["default"] = mod;
+ return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
+const tsutils = __importStar(require("tsutils"));
+const ts = __importStar(require("typescript"));
+const util = __importStar(require("../util"));
+exports.default = util.createRule({
+ name: 'unbound-method',
+ meta: {
+ docs: {
+ category: 'Best Practices',
+ description: 'Enforces unbound methods are called with their expected scope.',
+ tslintName: 'no-unbound-method',
+ recommended: 'error',
+ },
+ messages: {
+ unbound: 'Avoid referencing unbound methods which may cause unintentional scoping of `this`.',
+ },
+ schema: [
+ {
+ type: 'object',
+ properties: {
+ ignoreStatic: {
+ type: 'boolean',
+ },
+ },
+ additionalProperties: false,
+ },
+ ],
+ type: 'problem',
+ },
+ defaultOptions: [
+ {
+ ignoreStatic: false,
+ },
+ ],
+ create(context, [{ ignoreStatic }]) {
+ const parserServices = util.getParserServices(context);
+ const checker = parserServices.program.getTypeChecker();
+ return {
+ [typescript_estree_1.AST_NODE_TYPES.MemberExpression](node) {
+ if (isSafeUse(node)) {
+ return;
+ }
+ const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node);
+ const symbol = checker.getSymbolAtLocation(originalNode);
+ if (symbol && isDangerousMethod(symbol, ignoreStatic)) {
+ context.report({
+ messageId: 'unbound',
+ node,
+ });
+ }
+ },
+ };
+ },
+});
+function isDangerousMethod(symbol, ignoreStatic) {
+ const { valueDeclaration } = symbol;
+ switch (valueDeclaration.kind) {
+ case ts.SyntaxKind.MethodDeclaration:
+ case ts.SyntaxKind.MethodSignature:
+ return !(ignoreStatic &&
+ tsutils.hasModifier(valueDeclaration.modifiers, ts.SyntaxKind.StaticKeyword));
+ }
+ return false;
+}
+function isSafeUse(node) {
+ const parent = node.parent;
+ switch (parent.type) {
+ case typescript_estree_1.AST_NODE_TYPES.IfStatement:
+ case typescript_estree_1.AST_NODE_TYPES.ForStatement:
+ case typescript_estree_1.AST_NODE_TYPES.MemberExpression:
+ case typescript_estree_1.AST_NODE_TYPES.UpdateExpression:
+ case typescript_estree_1.AST_NODE_TYPES.WhileStatement:
+ return true;
+ case typescript_estree_1.AST_NODE_TYPES.CallExpression:
+ return parent.callee === node;
+ case typescript_estree_1.AST_NODE_TYPES.ConditionalExpression:
+ return parent.test === node;
+ case typescript_estree_1.AST_NODE_TYPES.LogicalExpression:
+ return parent.operator !== '||';
+ case typescript_estree_1.AST_NODE_TYPES.TaggedTemplateExpression:
+ return parent.tag === node;
+ case typescript_estree_1.AST_NODE_TYPES.TSNonNullExpression:
+ case typescript_estree_1.AST_NODE_TYPES.TSAsExpression:
+ case typescript_estree_1.AST_NODE_TYPES.TSTypeAssertion:
+ return isSafeUse(parent);
+ }
+ return false;
+}
+//# sourceMappingURL=unbound-method.js.map
\ No newline at end of file

dist/rules/unbound-method.js.map

@@ -0,0 +1 @@
+{"version":3,"file":"unbound-method.js","sourceRoot":"","sources":["../../src/rules/unbound-method.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4EAAgF;AAChF,iDAAmC;AACnC,+CAAiC;AAEjC,8CAAgC;AAchC,kBAAe,IAAI,CAAC,UAAU,CAAsB;IAClD,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EACT,gEAAgE;YAClE,UAAU,EAAE,mBAAmB;YAC/B,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,OAAO,EACL,oFAAoF;SACvF;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,YAAY,EAAE;wBACZ,IAAI,EAAE,SAAS;qBAChB;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,IAAI,EAAE,SAAS;KAChB;IACD,cAAc,EAAE;QACd;YACE,YAAY,EAAE,KAAK;SACpB;KACF;IACD,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC;QAChC,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAExD,OAAO;YACL,CAAC,kCAAc,CAAC,gBAAgB,CAAC,CAAC,IAA+B;gBAC/D,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE;oBACnB,OAAO;iBACR;gBAED,MAAM,YAAY,GAAG,cAAc,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACpE,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;gBAEzD,IAAI,MAAM,IAAI,iBAAiB,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE;oBACrD,OAAO,CAAC,MAAM,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K,kCAAc,CAAC,cAAc,CAAC;QACnC,KAAK,kCAAc,CAAC,eAAe;YACjC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;KAC5B;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
\ No newline at end of file

docs/rules/await-thenable.md

@@ -0,0 +1,33 @@
+# Disallows awaiting a value that is not a Promise (await-thenable)
+
+This rule disallows awaiting a value that is not a "Thenable" (an object which has `then` method, such as a Promise).
+While it is valid JavaScript to await a non-`Promise`-like value (it will resolve immediately), this pattern is often a programmer error, such as forgetting to add parenthesis to call a function that returns a Promise.
+
+## Rule Details
+
+Examples of **incorrect** code for this rule:
+
+```ts
+await 'value';
+
+const createValue = () => 'value';
+await createValue();
+```
+
+Examples of **correct** code for this rule:
+
+```ts
+await Promise.resolve('value');
+
+const createValue = async () => 'value';
+await createValue();
+```
+
+## When Not To Use It
+
+If you want to allow code to `await` non-Promise values.
+This is generally not preferred, but can sometimes be useful for visual consistency.
+
+## Related to
+
+- TSLint: ['await-promise'](https://palantir.github.io/tslint/rules/await-promise)

docs/rules/ban-types.md

@@ -46,7 +46,7 @@
"fixWith": "string"
}
}
- }
+ }]
}
```

docs/rules/explicit-function-return-type.md

@@ -62,9 +62,11 @@
The rule accepts an options object with the following properties:
- `allowExpressions` if true, only functions which are part of a declaration will be checked
+- `allowTypedFunctionExpressions` if true, type annotations are also allowed on the variable
+ of a function expression rather than on the function directly.
-By default, `allowExpressions: false` is used, meaning all declarations and
-expressions _must_ have a return type.
+By default, `allowExpressions: false` and `allowTypedFunctionExpressions: false` are used,
+meaning all declarations and expressions _must_ have a return type.
### allowExpressions
@@ -84,6 +86,20 @@
const foo = arr.map(i => i * i);
```
+### allowTypedFunctionExpressions
+
+Examples of additional **correct** code for this rule with `{ allowTypedFunctionExpressions: true }`:
+
+```ts
+type FuncType = () => string;
+
+let arrowFn: FuncType = () => 'test';
+
+let funcExpr: FuncType = function() {
+ return 'test';
+};
+```
+
## When Not To Use It
If you don't wish to prevent calling code from using function return values in unexpected ways, then

docs/rules/explicit-member-accessibility.md

@@ -10,28 +10,247 @@
This rule aims to make code more readable and explicit about who can use
which properties.
-The following patterns are considered warnings:
+## Options
+
+```ts
+type AccessibilityLevel =
+ | 'explicit' // require an accessor (including public)
+ | 'no-public' // don't require public
+ | 'off'; // don't check
+
+interface Config {
+ accessibility?: AccessibilityLevel;
+ overrides?: {
+ accessors?: AccessibilityLevel;
+ constructors?: AccessibilityLevel;
+ methods?: AccessibilityLevel;
+ properties?: AccessibilityLevel;
+ parameterProperties?: AccessibilityLevel;
+ };
+}
+```
+
+Default config:
+
+```JSON
+{ "accessibility": "explicit" }
+```
+
+This rule in it's default state requires no configuration and will enforce that every class member has an accessibility modifier. If you would like to allow for some implicit public members then you have the following options:
+A possible configuration could be:
+
+```ts
+{
+ accessibility: 'explicit',
+ overrides {
+ accessors: 'explicit',
+ constructors: 'no-public',
+ methods: 'explicit',
+ properties: 'off',
+ parameterProperties: 'explicit'
+ }
+}
+```
+
+The following patterns are considered incorrect code if no options are provided:
+
+```ts
+class Animal {
+ constructor(name) {
+ // No accessibility modifier
+ this.animalName = name;
+ }
+ animalName: string; // No accessibility modifier
+ get name(): string {
+ // No accessibility modifier
+ return this.animalName;
+ }
+ set name(value: string) {
+ // No accessibility modifier
+ this.animalName = value;
+ }
+ walk() {
+ // method
+ }
+}
+```
+
+The following patterns are considered correct with the default options `{ accessibility: 'explicit' }`:
+
+```ts
+class Animal {
+ public constructor(public breed, animalName) {
+ // Parameter property and constructor
+ this.animalName = name;
+ }
+ private animalName: string; // Property
+ get name(): string {
+ // get accessor
+ return this.animalName;
+ }
+ set name(value: string) {
+ // set accessor
+ this.animalName = value;
+ }
+ public walk() {
+ // method
+ }
+}
+```
+
+The following patterns are considered incorrect with the accessibility set to **no-public** `[{ accessibility: 'no-public' }]`:
+
+```ts
+class Animal {
+ public constructor(public breed, animalName) {
+ // Parameter property and constructor
+ this.animalName = name;
+ }
+ public animalName: string; // Property
+ public get name(): string {
+ // get accessor
+ return this.animalName;
+ }
+ public set name(value: string) {
+ // set accessor
+ this.animalName = value;
+ }
+ public walk() {
+ // method
+ }
+}
+```
+
+The following patterns are considered correct with the accessibility set to **no-public** `[{ accessibility: 'no-public' }]`:
+
+```ts
+class Animal {
+ constructor(protected breed, animalName) {
+ // Parameter property and constructor
+ this.name = name;
+ }
+ private animalName: string; // Property
+ get name(): string {
+ // get accessor
+ return this.animalName;
+ }
+ private set name(value: string) {
+ // set accessor
+ this.animalName = value;
+ }
+ protected walk() {
+ // method
+ }
+}
+```
+
+### Overrides
+
+There are three ways in which an override can be used.
+
+- To disallow the use of public on a given member.
+- To enforce explicit member accessibility when the root has allowed implicit public accessibility
+- To disable any checks on given member type
+
+#### Disallow the use of public on a given member
+
+e.g. `[ { overrides: { constructor: 'no-public' } } ]`
+
+The following patterns are considered incorrect with the example override
+
+```ts
+class Animal {
+ public constructor(protected animalName) {}
+ public get name() {
+ return this.animalName;
+ }
+}
+```
+
+The following patterns are considered correct with the example override
+
+```ts
+class Animal {
+ constructor(protected animalName) {}
+ public get name() {
+ return this.animalName;
+ }
+}
+```
+
+#### Require explicit accessibility for a given member
+
+e.g. `[ { accessibility: 'no-public', overrides: { properties: 'explicit' } } ]`
+
+The following patterns are considered incorrect with the example override
+
+```ts
+class Animal {
+ constructor(protected animalName) {}
+ get name() {
+ return this.animalName;
+ }
+ protected set name(value: string) {
+ this.animalName = value;
+ }
+ legs: number;
+ private hasFleas: boolean;
+}
+```
+
+The following patterns are considered correct with the example override
+
+```ts
+class Animal {
+ constructor(protected animalName) {}
+ get name() {
+ return this.animalName;
+ }
+ protected set name(value: string) {
+ this.animalName = value;
+ }
+ public legs: number;
+ private hasFleas: boolean;
+}
+```
+
+#### Disable any checks on given member type
+
+e.g. `[{ overrides: { accessors : 'off' } } ]`
+
+As no checks on the overridden member type are performed all permutations of visibility are permitted for that member type
+
+The follow pattern is considered incorrect for the given configuration
```ts
class Animal {
- name: string; // No accessibility modifier
- getName(): string {} // No accessibility modifier
+ constructor(protected animalName) {}
+ public get name() {
+ return this.animalName;
+ }
+ get legs() {
+ return this.legCount;
+ }
}
```
-The following patterns are not warnings:
+The following patterns are considered correct with the example override
```ts
class Animal {
- private name: string; // explicit accessibility modifier
- public getName(): string {} // explicit accessibility modifier
+ public constructor(protected animalName) {}
+ public get name() {
+ return this.animalName;
+ }
+ get legs() {
+ return this.legCount;
+ }
}
```
## When Not To Use It
-If you think defaulting to public is a good default, then you will not need
-this rule.
+If you think defaulting to public is a good default, then you should consider using the `no-public` setting. If you want to mix implicit and explicit public members then disable this rule.
## Further Reading

docs/rules/member-naming.md

@@ -4,7 +4,9 @@
## Rule Details
-This rule allows you to enforce conventions for class property names by their visibility. By default, it enforces nothing.
+This rule allows you to enforce conventions for class property and method names by their visibility. By default, it enforces nothing.
+
+> Note: constructors are explicitly ignored regardless of the the regular expression options provided
## Options

docs/rules/no-extra-parens.md

@@ -0,0 +1,22 @@
+# disallow unnecessary parentheses (no-extra-parens)
+
+This rule restricts the use of parentheses to only where they are necessary.
+
+## Rule Details
+
+This rule extends the base [eslint/no-extra-parens](https://eslint.org/docs/rules/no-extra-parens) rule.
+It supports all options and features of the base rule plus TS type assertions.
+
+## How to use
+
+```cjson
+{
+ // note you must disable the base rule as it can report incorrect errors
+ "no-extra-parens": "off",
+ "@typescript-eslint/no-extra-parens": ["error"]
+}
+```
+
+## Options
+
+See [eslint/no-extra-parens options](https://eslint.org/docs/rules/no-extra-parens#options).

docs/rules/no-object-literal-type-assertion.md

@@ -1,6 +1,6 @@
# Forbids an object literal to appear in a type assertion expression (no-object-literal-type-assertion)
-Always prefer `const x: T = { ... };` to `const x = { ... } as T;`. Casting to `any` and `unknown` is still allowed.
+Always prefer `const x: T = { ... };` to `const x = { ... } as T;`. Casting to `any` and `unknown` is still allowed, and const assertions (`as const`) are still allowed.
## Rule Details

docs/rules/prefer-for-of.md

@@ -0,0 +1,41 @@
+# Use for-of loops instead of standard for loops over arrays (prefer-for-of)
+
+This rule recommends a for-of loop when the loop index is only used to read from an array that is being iterated.
+
+## Rule Details
+
+For cases where the index is only used to read from the array being iterated, a for-of loop is easier to read and write.
+
+Examples of **incorrect** code for this rule:
+
+```js
+for (let i = 0; i < arr.length; i++) {
+ console.log(arr[i]);
+}
+```
+
+Examples of **correct** code for this rule:
+
+```js
+for (const x of arr) {
+ console.log(x);
+}
+
+for (let i = 0; i < arr.length; i++) {
+ // i is used to write to arr, so for-of could not be used.
+ arr[i] = 0;
+}
+
+for (let i = 0; i < arr.length; i++) {
+ // i is used independent of arr, so for-of could not be used.
+ console.log(i, arr[i]);
+}
+```
+
+## When Not To Use It
+
+If you transpile for browsers that do not support for-of loops, you may wish to use traditional for loops that produce more compact code.
+
+## Related to
+
+- TSLint: ['prefer-for-of'](https://palantir.github.io/tslint/rules/prefer-for-of/)

docs/rules/prefer-includes.md

@@ -0,0 +1,71 @@
+# Enforce `includes` method over `indexOf` method (@typescript-eslint/prefer-includes)
+
+Until ES5, we were using `String#indexOf` method to check whether a string contains an arbitrary substring or not.
+Until ES2015, we were using `Array#indexOf` method to check whether an array contains an arbitrary value or not.
+
+ES2015 has added `String#includes` and ES2016 has added `Array#includes`.
+It makes code more understandable if we use those `includes` methods for the purpose.
+
+## Rule Details
+
+This rule is aimed at suggesting `includes` method if `indexOf` method was used to check whether an object contains an arbitrary value or not.
+
+If the receiver object of the `indexOf` method call has `includes` method and the two methods have the same parameters, this rule does suggestion.
+There are such types: `String`, `Array`, `ReadonlyArray`, and typed arrays.
+
+Additionally, this rule reports the tests of simple regular expressions in favor of `String#includes`.
+
+Examples of **incorrect** code for this rule:
+
+```ts
+let str: string;
+let array: any[];
+let readonlyArray: ReadonlyArray<any>;
+let typedArray: UInt8Array;
+let userDefined: {
+ indexOf(x: any): number;
+ includes(x: any): boolean;
+};
+
+str.indexOf(value) !== -1;
+array.indexOf(value) !== -1;
+readonlyArray.indexOf(value) === -1;
+typedArray.indexOf(value) > -1;
+userDefined.indexOf(value) >= 0;
+
+// simple RegExp test
+/foo/.test(str);
+```
+
+Examples of **correct** code for this rule:
+
+```ts
+let array: any[];
+let readonlyArray: ReadonlyArray<any>;
+let typedArray: UInt8Array;
+let userDefined: {
+ indexOf(x: any): number;
+ includes(x: any): boolean;
+};
+let mismatchExample: {
+ indexOf(x: any, fromIndex?: number): number;
+ includes(x: any): boolean;
+};
+
+str.includes(value);
+array.includes(value);
+readonlyArray.includes(value);
+typedArray.includes(value);
+userDefined.includes(value);
+
+// the two methods have different parameters.
+mismatchExample.indexOf(value) >= 0;
+```
+
+## Options
+
+There are no options.
+
+## When Not To Use It
+
+If you don't want to suggest `includes`, you can safely turn this rule off.

docs/rules/prefer-string-starts-ends-with.md

@@ -0,0 +1,54 @@
+# Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings (prefer-string-starts-ends-with)
+
+There are multiple ways to verify if a string starts or ends with a specific string, such as `foo.indexOf('bar') === 0`.
+
+Since ES2015 has added `String#startsWith` and `String#endsWith`, this rule reports other ways to be consistent.
+
+## Rule Details
+
+This rule is aimed at enforcing a consistent way to check whether a string starts or ends with a specific string.
+
+Examples of **incorrect** code for this rule:
+
+```ts
+let foo: string;
+
+// starts with
+foo[0] === 'b';
+foo.charAt(0) === 'b';
+foo.indexOf('bar') === 0;
+foo.slice(0, 3) === 'bar';
+foo.substring(0, 3) === 'bar';
+foo.match(/^bar/) != null;
+/^bar/.test(foo);
+
+// ends with
+foo[foo.length - 1] === 'b';
+foo.charAt(foo.length - 1) === 'b';
+foo.lastIndexOf('bar') === foo.length - 3;
+foo.slice(-3) === 'bar';
+foo.substring(foo.length - 3) === 'bar';
+foo.match(/bar$/) != null;
+/bar$/.test(foo);
+```
+
+Examples of **correct** code for this rule:
+
+```ts
+foo.startsWith('bar');
+foo.endsWith('bar');
+```
+
+## Options
+
+There are no options.
+
+```JSON
+{
+ "@typescript-eslint/prefer-string-starts-ends-with": "error"
+}
+```
+
+## When Not To Use It
+
+If you don't mind that style, you can turn this rule off safely.

docs/rules/unbound-method.md

@@ -0,0 +1,92 @@
+# Enforces unbound methods are called with their expected scope (unbound-method)
+
+Warns when a method is used outside of a method call.
+
+Class functions don't preserve the class scope when passed as standalone variables.
+
+## Rule Details
+
+Examples of **incorrect** code for this rule
+
+```ts
+class MyClass {
+ public log(): void {
+ console.log(this);
+ }
+}
+
+const instance = new MyClass();
+
+// This logs the global scope (`window`/`global`), not the class instance
+const myLog = instance.log;
+myLog();
+
+// This log might later be called with an incorrect scope
+const { log } = instance;
+```
+
+Examples of **correct** code for this rule
+
+```ts
+class MyClass {
+ public logUnbound(): void {
+ console.log(this);
+ }
+
+ public logBound = () => console.log(this);
+}
+
+const instance = new MyClass();
+
+// logBound will always be bound with the correct scope
+const { logBound } = instance;
+logBound();
+
+// .bind and lambdas will also add a correct scope
+const dotBindLog = instance.log.bind(instance);
+const innerLog = () => instance.log();
+```
+
+## Options
+
+The rule accepts an options object with the following property:
+
+- `ignoreStatic` to not check whether `static` methods are correctly bound
+
+### `ignoreStatic`
+
+Examples of **correct** code for this rule with `{ ignoreStatic: true }`:
+
+```ts
+class OtherClass {
+ static log() {
+ console.log(OtherClass);
+ }
+}
+
+// With `ignoreStatic`, statics are assumed to not rely on a particular scope
+const { log } = OtherClass;
+
+log();
+```
+
+### Example
+
+```json
+{
+ "@typescript-eslint/unbound-method": [
+ "error",
+ {
+ "ignoreStatic": true
+ }
+ ]
+}
+```
+
+## When Not To Use It
+
+If your code intentionally waits to bind methods after use, such as by passing a `scope: this` along with the method, you can disable this rule.
+
+## Related To
+
+- TSLint: [no-unbound-method](https://palantir.github.io/tslint/rules/no-unbound-method/)

docs/rules/unified-signatures.md

@@ -30,4 +30,4 @@
## Related to
-- TSLint: ['unified-signatures`](https://palantir.github.io/tslint/rules/unified-signatures/)
+- TSLint: [`unified-signatures`](https://palantir.github.io/tslint/rules/unified-signatures/)

package.json

@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
- "version": "1.5.0",
+ "version": "1.7.0",
"description": "TypeScript plugin for ESLint",
"keywords": [
"eslint",
@@ -35,8 +35,10 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
- "@typescript-eslint/parser": "1.5.0",
- "@typescript-eslint/typescript-estree": "1.5.0",
+ "@typescript-eslint/parser": "1.7.0",
+ "@typescript-eslint/typescript-estree": "1.7.0",
+ "eslint-utils": "^1.3.1",
+ "regexpp": "^2.0.1",
"requireindex": "^1.2.0",
"tsutils": "^3.7.0"
},
@@ -47,5 +49,5 @@
"eslint": "^5.0.0",
"typescript": "*"
},
- "gitHead": "c7db5942054e52d8e2cef3be662d98ffe3cc6454"
+ "gitHead": "24a0d1e2d5f85b1115dffe4ee5cadb27e7f02869"
}

README.md

@@ -105,53 +105,56 @@
<!-- Please run `npm run docs` to update this section -->
<!-- begin rule list -->
-**Key**: :heavy_check_mark: = recommended, :wrench: = fixable
+**Key**: :heavy_check_mark: = recommended, :wrench: = fixable, :thought_balloon: = requires type information
<!-- prettier-ignore -->
-| Name | Description | :heavy_check_mark: | :wrench: |
-| --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- |
-| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array<T>` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/ban-ts-ignore`](./docs/rules/ban-ts-ignore.md) | Bans “// @ts-ignore” comments from being used (`ban-ts-ignore` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | |
-| [`@typescript-eslint/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | |
-| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | |
-| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | |
+| Name | Description | :heavy_check_mark: | :wrench: | :thought_balloon: |
+| --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- | ----------------- |
+| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array<T>` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: | |
+| [`@typescript-eslint/await-thenable`](./docs/rules/await-thenable.md) | Disallow awaiting a value that is not a Promise (`await-promise` from TSLint) | :heavy_check_mark: | | :thought_balloon: |
+| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: | |
+| [`@typescript-eslint/ban-ts-ignore`](./docs/rules/ban-ts-ignore.md) | Bans “// @ts-ignore” comments from being used (`ban-ts-ignore` from TSLint) | | | |
+| [`@typescript-eslint/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | | |
+| [`@typescript-eslint/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | | |
+| [`@typescript-eslint/explicit-member-accessibility`](./docs/rules/explicit-member-accessibility.md) | Require explicit accessibility modifiers on class properties and methods (`member-access` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/generic-type-naming`](./docs/rules/generic-type-naming.md) | Enforces naming of generic type variables | | | |
+| [`@typescript-eslint/indent`](./docs/rules/indent.md) | Enforce consistent indentation (`indent` from TSLint) | :heavy_check_mark: | :wrench: | |
+| [`@typescript-eslint/interface-name-prefix`](./docs/rules/interface-name-prefix.md) | Require that interface names be prefixed with `I` (`interface-name` from TSLint) | :heavy_check_mark: | | |
| [`@typescript-eslint/member-delimiter-style`](./docs/rules/member-delimiter-style.md) | Require a specific member delimiter style for interfaces and type literals | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | |
-| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | |
-| [`@typescript-eslint/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `<Type>` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | |
-| [`@typescript-eslint/no-for-in-array`](./docs/rules/no-for-in-array.md) | Disallow iterating over an array with a for-in loop (`no-for-in-array` from TSLint) | | |
-| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` (`no-require-imports` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | |
-| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// <reference path="" />` comments (`no-reference` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | |
-| [`@typescript-eslint/no-unnecessary-qualifier`](./docs/rules/no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary (`no-unnecessary-qualifier` from TSLint) | | :wrench: |
-| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression (`no-unnecessary-type-assertion` from TSLint) | | :wrench: |
-| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | |
-| [`@typescript-eslint/no-useless-constructor`](./docs/rules/no-useless-constructor.md) | Disallow unnecessary constructors | | |
-| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Use function types instead of interfaces with call signatures (`callable-types` from TSLint) | | :wrench: |
-| [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async. (`promise-function-async` from TSLint) | :heavy_check_mark: | |
-| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | |
-| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: |
-| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Warns for any two overloads that could be unified into one. (`unified-signatures` from TSLint) | | |
+| [`@typescript-eslint/member-naming`](./docs/rules/member-naming.md) | Enforces naming conventions for class members by visibility. | | | |
+| [`@typescript-eslint/member-ordering`](./docs/rules/member-ordering.md) | Require a consistent member declaration order (`member-ordering` from TSLint) | | | |
+| [`@typescript-eslint/no-angle-bracket-type-assertion`](./docs/rules/no-angle-bracket-type-assertion.md) | Enforces the use of `as Type` assertions instead of `<Type>` assertions (`no-angle-bracket-type-assertion` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-array-constructor`](./docs/rules/no-array-constructor.md) | Disallow generic `Array` constructors | :heavy_check_mark: | :wrench: | |
+| [`@typescript-eslint/no-empty-interface`](./docs/rules/no-empty-interface.md) | Disallow the declaration of empty interfaces (`no-empty-interface` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-explicit-any`](./docs/rules/no-explicit-any.md) | Disallow usage of the `any` type (`no-any` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-extraneous-class`](./docs/rules/no-extraneous-class.md) | Forbids the use of classes as namespaces (`no-unnecessary-class` from TSLint) | | | |
+| [`@typescript-eslint/no-for-in-array`](./docs/rules/no-for-in-array.md) | Disallow iterating over an array with a for-in loop (`no-for-in-array` from TSLint) | | | :thought_balloon: |
+| [`@typescript-eslint/no-inferrable-types`](./docs/rules/no-inferrable-types.md) | Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (`no-inferrable-types` from TSLint) | :heavy_check_mark: | :wrench: | |
+| [`@typescript-eslint/no-misused-new`](./docs/rules/no-misused-new.md) | Enforce valid definition of `new` and `constructor`. (`no-misused-new` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-namespace`](./docs/rules/no-namespace.md) | Disallow the use of custom TypeScript modules and namespaces (`no-namespace` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` (`no-require-imports` from TSLint) | | | |
+| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | | |
+| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// <reference path="" />` comments (`no-reference` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | | |
+| [`@typescript-eslint/no-unnecessary-qualifier`](./docs/rules/no-unnecessary-qualifier.md) | Warns when a namespace qualifier is unnecessary (`no-unnecessary-qualifier` from TSLint) | | :wrench: | :thought_balloon: |
+| [`@typescript-eslint/no-unnecessary-type-assertion`](./docs/rules/no-unnecessary-type-assertion.md) | Warns if a type assertion does not change the type of an expression (`no-unnecessary-type-assertion` from TSLint) | | :wrench: | :thought_balloon: |
+| [`@typescript-eslint/no-unused-vars`](./docs/rules/no-unused-vars.md) | Disallow unused variables (`no-unused-variable` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | | |
+| [`@typescript-eslint/no-useless-constructor`](./docs/rules/no-useless-constructor.md) | Disallow unnecessary constructors | | | |
+| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | | |
+| [`@typescript-eslint/prefer-for-of`](./docs/rules/prefer-for-of.md) | Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated. | | | |
+| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Use function types instead of interfaces with call signatures (`callable-types` from TSLint) | | :wrench: | |
+| [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: | |
+| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: | |
+| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async. (`promise-function-async` from TSLint) | | | :thought_balloon: |
+| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | | :thought_balloon: |
+| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: | |
+| [`@typescript-eslint/unbound-method`](./docs/rules/unbound-method.md) | Enforces unbound methods are called with their expected scope. (`no-unbound-method` from TSLint) | :heavy_check_mark: | | :thought_balloon: |
+| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Warns for any two overloads that could be unified into one. (`unified-signatures` from TSLint) | | | |
<!-- end rule list -->