Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tslint-microsoft-contrib

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tslint-microsoft-contrib - npm Package Compare versions

Comparing version 2.0.10 to 2.0.11

insecureRandomRule.js

2

exportNameRule.js

@@ -52,3 +52,3 @@ "use strict";

var _this = this;
var singleExport = Utils_1.Utils.filter(node.statements, function (element) {
var singleExport = node.statements.filter(function (element) {
return element.kind === SyntaxKind_1.SyntaxKind.current().ExportAssignment;

@@ -55,0 +55,0 @@ });

@@ -37,2 +37,3 @@ "use strict";

var FUNC_BODY_LENGTH = 'func-body-length';
var FUNC_EXPRESSION_BODY_LENGTH = 'func-express-body-length';
var ARROW_BODY_LENGTH = 'arrow-body-length';

@@ -76,2 +77,6 @@ var METHOD_BODY_LENGTH = 'method-body-length';

};
MaxFunctionBodyLengthRuleWalker.prototype.visitFunctionExpression = function (node) {
this.validate(node);
_super.prototype.visitFunctionExpression.call(this, node);
};
MaxFunctionBodyLengthRuleWalker.prototype.visitConstructorDeclaration = function (node) {

@@ -134,2 +139,3 @@ this.validate(node);

_this.maxFuncBodyLength = opt[FUNC_BODY_LENGTH];
_this.maxFuncExpressionBodyLength = opt[FUNC_EXPRESSION_BODY_LENGTH];
_this.maxArrowBodyLength = opt[ARROW_BODY_LENGTH];

@@ -158,4 +164,6 @@ _this.maxMethodBodyLength = opt[METHOD_BODY_LENGTH];

var funcTypeText = this.getFuncTypeText(node.kind);
if (node.kind === SyntaxKind_1.SyntaxKind.current().MethodDeclaration || node.kind === SyntaxKind_1.SyntaxKind.current().FunctionDeclaration) {
return " in " + funcTypeText + " " + node.name.text + "()";
if (node.kind === SyntaxKind_1.SyntaxKind.current().MethodDeclaration ||
node.kind === SyntaxKind_1.SyntaxKind.current().FunctionDeclaration ||
node.kind === SyntaxKind_1.SyntaxKind.current().FunctionExpression) {
return " in " + funcTypeText + " " + (node.name || { text: '' }).text + "()";
}

@@ -171,2 +179,5 @@ else if (node.kind === SyntaxKind_1.SyntaxKind.current().Constructor) {

}
else if (nodeKind === SyntaxKind_1.SyntaxKind.current().FunctionExpression) {
return 'function expression';
}
else if (nodeKind === SyntaxKind_1.SyntaxKind.current().MethodDeclaration) {

@@ -190,2 +201,5 @@ return 'method';

}
else if (nodeKind === SyntaxKind_1.SyntaxKind.current().FunctionExpression) {
result = this.maxFuncExpressionBodyLength;
}
else if (nodeKind === SyntaxKind_1.SyntaxKind.current().MethodDeclaration) {

@@ -192,0 +206,0 @@ result = this.maxMethodBodyLength;

@@ -22,3 +22,3 @@ "use strict";

type: 'maintainability',
description: 'Do not invoke Mocha\'s describe.only or it.only functions.',
description: 'Do not invoke Mocha\'s describe.only, it.only or context.only functions.',
options: null,

@@ -33,2 +33,3 @@ issueClass: 'Non-SDL',

Rule.FAILURE_STRING_DESCRIBE = 'Do not commit Mocha describe.only function call';
Rule.FAILURE_STRING_CONTEXT = 'Do not commit Mocha context.only function call';
return Rule;

@@ -59,2 +60,5 @@ }(Lint.Rules.AbstractRule));

}
else if (node.expression.getText() === 'context.only') {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING_CONTEXT));
}
}

@@ -61,0 +65,0 @@ }

@@ -87,3 +87,3 @@ "use strict";

}
var allDones = Utils_1.Utils.filter(node.parameters, function (parameter) {
var allDones = node.parameters.filter(function (parameter) {
if (parameter.type != null && parameter.type.getText() === 'MochaDone') {

@@ -90,0 +90,0 @@ return true;

@@ -86,7 +86,7 @@ "use strict";

var kinds = SyntaxKind_1.SyntaxKind.current();
var parent;
while ((parent = node.parent)) {
var kind = parent.kind;
while ((node.parent != null)) {
var parent_1 = node.parent;
var kind = parent_1.kind;
if (kind === kinds.CallExpression) {
var callExpression = parent;
var callExpression = parent_1;
return { callInfo: { callExpression: callExpression, argIndex: callExpression.arguments.indexOf(node) } };

@@ -103,3 +103,3 @@ }

}
node = parent;
node = parent_1;
}

@@ -106,0 +106,0 @@ };

{
"name": "tslint-microsoft-contrib",
"version": "2.0.10",
"version": "2.0.11",
"description": "TSLint Rules for Microsoft",

@@ -27,3 +27,3 @@ "repository": {

},
"main": "package.json",
"main": "tslint.json",
"keywords": [

@@ -30,0 +30,0 @@ "tslint",

@@ -7,2 +7,3 @@ "use strict";

};
var ts = require('typescript');
var Lint = require('tslint/lib/lint');

@@ -32,3 +33,8 @@ var ErrorTolerantWalker_1 = require('./utils/ErrorTolerantWalker');

Rule.prototype.apply = function (sourceFile) {
return this.applyWithWalker(new ReactIframeMissingSandboxRuleWalker(sourceFile, this.getOptions()));
if (sourceFile.languageVariant === ts.LanguageVariant.JSX) {
return this.applyWithWalker(new ReactIframeMissingSandboxRuleWalker(sourceFile, this.getOptions()));
}
else {
return [];
}
};

@@ -40,3 +46,3 @@ Rule.metadata = {

options: null,
issueClass: 'Non-SDL',
issueClass: 'SDL',
issueType: 'Error',

@@ -43,0 +49,0 @@ severity: 'Critical',

@@ -7,2 +7,3 @@ "use strict";

};
var ts = require('typescript');
var Lint = require('tslint/lib/lint');

@@ -20,3 +21,8 @@ var ErrorTolerantWalker_1 = require('./utils/ErrorTolerantWalker');

Rule.prototype.apply = function (sourceFile) {
return this.applyWithWalker(new ReactUnusedPropsAndStateRuleWalker(sourceFile, this.getOptions()));
if (sourceFile.languageVariant === ts.LanguageVariant.JSX) {
return this.applyWithWalker(new ReactUnusedPropsAndStateRuleWalker(sourceFile, this.getOptions()));
}
else {
return [];
}
};

@@ -23,0 +29,0 @@ Rule.metadata = {

@@ -11,16 +11,12 @@ [![npm version](https://badge.fury.io/js/tslint-microsoft-contrib.svg)](https://badge.fury.io/js/tslint-microsoft-contrib)

Version 2.0.10
Version 2.0.11 (Stable)
-------------
The project has been in use for at least several months on multiple projects. Please report any bugs or false positives you might find!
The project has been in use for over a year on multiple projects. Please report any bugs or false positives you might find!
See our [Release Notes](https://github.com/Microsoft/tslint-microsoft-contrib/wiki/Release-Notes) to find the latest new rules.
#### TSLint and corresponding tslint-microsoft-contrib version
Version 2.0.12 (In-Development)
-------------
The [Latest Development Version](https://github.com/Microsoft/tslint-microsoft-contrib/tree/releases) is available online.
| TSLint version | tslint-microsoft-contrib version |
| --- | --- |
| **>= 3.2.x** | 2.x |
| **3.1.x** | unsupported |
| **3.0.x** | unsupported |
| **2.x** | 1.x |
Installation

@@ -33,5 +29,14 @@ ------------

* [Latest Development Version](https://github.com/Microsoft/tslint-microsoft-contrib/tree/releases)
* [2.0.9](https://github.com/Microsoft/tslint-microsoft-contrib/tree/npm-2.0.9)
* [2.0.10](https://github.com/Microsoft/tslint-microsoft-contrib/tree/npm-2.0.10)
#### TSLint and corresponding tslint-microsoft-contrib version
| TSLint version | tslint-microsoft-contrib version |
| --- | --- |
| **>= 3.2.x** | 2.x |
| **3.1.x** | unsupported |
| **3.0.x** | unsupported |
| **2.x** | 1.x |
Configuration

@@ -74,8 +79,9 @@ -------------

`function-name` | Applies a naming convention to function names and method names. You can configure the naming convention by passing parameters. Please note, the private-method-regex does take precedence over the static-method-regex, so a private static method must match the private-method-regex. The default values are: <br> [ true, { <br> "method-regex": "^[a-z][\\w\\d]+$",<br> "private-method-regex": "^[a-z][\\w\\d]+$",<br> "static-method-regex": "^[A-Z_\\d]+$",<br> "function-regex": "^[a-z][\\w\\d]+$"<br> }] | 2.0.7
`import-name` | The name of the imported module must match the name of the thing being imported. For example, it is valid to name imported modules the same as the module name: `import Service = require('x/y/z/Service')` and `import Service from 'x/y/z/Service'`. But it is invalid to change the name being imported, such as: `import MyCoolService = require('x/y/z/Service')` and `import MyCoolService from 'x/y/z/Service'`. Since version 2.0.9 it is possible to configure this rule with a list of exceptions. For example, to allow underscore to be imported as _, add this configuration: `'import-name': [ true, { 'underscore': '_' }]`| 2.0.5
`insecure-random` | Do not use insecure sources for random bytes. Use a secure random number generator instead. Bans all uses of Math.random and crypto.pseudoRandomBytes. Better alternatives are crypto.randomBytes and window.crypto.getRandomValues.<br/>References:<br/>* [CWE 330](https://cwe.mitre.org/data/definitions/330.html)<br/>* [MDN Math.random](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)<br/>* [Node.js crypto.randomBytes()](http://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback)<br/>* [window.crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues)<br/> | 2.0.11
`import-name` | The name of the imported module must match the name of the thing being imported. For example, it is valid to name imported modules the same as the module name: `import Service = require('x/y/z/Service')` and `import Service from 'x/y/z/Service'`. But it is invalid to change the name being imported, such as: `import MyCoolService = require('x/y/z/Service')` and `import MyCoolService from 'x/y/z/Service'`. Since version 2.0.9 it is possible to configure this rule with a list of exceptions. For example, to allow `underscore` to be imported as `_`, add this configuration: `'import-name': [ true, { 'underscore': '_' }]`| 2.0.5
`jquery-deferred-must-complete` | When a JQuery Deferred instance is created, then either reject() or resolve() must be called on it within all code branches in the scope. For more examples see the [feature request](https://github.com/Microsoft/tslint-microsoft-contrib/issues/26). | 1.0
`max-func-body-length` | Avoid long functions. The line count of a function body must not exceed the value configured within this rule's options. <br>You can setup a general max function body length applied for every function/method/arrow function e.g. \[true, 30\] or set different maximum length for every type e.g. \[true, \{ "func-body-length": 10 , "arrow-body-length": 5, "method-body-length": 15, "ctor-body-length": 5 \}\]. To specify a function name whose parameters you can ignore for this rule, pass a regular expression as a string(this can be useful for Mocha users to ignore the describe() function). Since version 2.0.9, you can also ignore single- and multi-line comments from the total function length, eg. \[true, \{ "ignore-comments": true \}\] | 2.0.3
`max-func-body-length` | Avoid long functions. The line count of a function body must not exceed the value configured within this rule's options. <br>You can setup a general max function body length applied for every function/method/arrow function e.g. \[true, 30\] or set different maximum length for every type e.g. \[true, \{ "func-body-length": 10 , "func-expression-body-length": 10 , "arrow-body-length": 5, "method-body-length": 15, "ctor-body-length": 5 \}\]. To specify a function name whose parameters you can ignore for this rule, pass a regular expression as a string(this can be useful for Mocha users to ignore the describe() function). Since version 2.0.9, you can also ignore single- and multi-line comments from the total function length, eg. \[true, \{ "ignore-comments": true \}\] | 2.0.3
`missing-jsdoc` | All files must have a top level [JSDoc](http://usejsdoc.org/) comment. A JSDoc comment starts with /** (not one more or one less asterisk) and a JSDoc at the 'top-level' appears without leading spaces. Trailing spaces are acceptable but not recommended. | 1.0
`missing-optional-annotation` | Deprecated - This rule is now enforced by the TypeScript compiler. A parameter that follows one or more parameters marked as optional is not itself marked optional | 0.0.1
`mocha-avoid-only` | Do not invoke Mocha's describe.only or it.only functions. These functions are useful ways to run a single unit test or a single test case during your build, but please be careful to not push these methods calls to your version control repositiory because it will turn off any of the other tests.| 1.0
`mocha-avoid-only` | Do not invoke Mocha's describe.only, it.only or context.only functions. These functions are useful ways to run a single unit test or a single test case during your build, but please be careful to not push these methods calls to your version control repositiory because it will turn off any of the other tests.| 1.0
`mocha-no-side-effect-code` | All test logic in a Mocha test case should be within Mocha lifecycle method and not defined statically to execute when the module loads. Put all assignments and initialization statements in a before(), beforeEach(), after(), afterEach(), or it() function. Code executed outside of these lifecycle methods can throw exceptions before the test runner is initialized and can result in errors or even test runner crashes. This rule can be configured with a regex to ignore certain initializations. For example, to ignore any calls to `RestDataFactory` configure the rule with: `[true, { ignore: '^RestDataFactory\\..*' }]`| 2.0.10

@@ -118,2 +124,3 @@ `mocha-unneeded-done` | A function declares a MochaDone parameter but only resolves it synchronously in the main function. The MochaDone parameter can be safely removed from the parameter list.| 2.0.10

`no-string-based-set-timeout` | Do not use the version of setTimeout that accepts code as a string argument. However, it is acceptable to use the version of setTimeout where a direct reference to a function is provided as the callback argument | 0.0.1
`no-suspicious-comment` | Do not use suspicious comments, such as BUG, HACK, FIXME, LATER, LATER2, TODO. We recommend that you run this rule before each release as a quality checkpoint. Reference: [CWE-546 Suspicious Comment](https://cwe.mitre.org/data/definitions/546.html) | 2.0.11
`no-typeof-undefined` | Do not use the idiom `typeof x === 'undefined'`. You can safely use the simpler `x === undefined` or perhaps `x == null` if you want to check for either null or undefined. | 2.0.8

@@ -130,2 +137,3 @@ `no-unexternalized-strings` | Ensures that double quoted strings are passed to a localize call to provide proper strings for different locales. The rule can be configured using an object literal as document in the [feature request](https://github.com/Microsoft/tslint-microsoft-contrib/issues/95#issuecomment-173149989)| 2.0.1

`no-var-self` | Do not use `var self = this`; instead, manage scope with arrow functions/lambdas. Self variables are a common practice in JavaScript but can be avoided in TypeScript. By default the rule bans any assignments of the `this` reference. If you want to enforce a naming convention or allow some usages then configure the rule with a regex. By default the rule is configured with `(?!)` which matches nothing. You can pass `^self$` to allow variables named self or pass `^(?!self$)` to allow anything other than self, for example| 2.0.8
`possible-timing-attack` | Avoid timing attacks by not making direct string comparisons to sensitive data. Do not compare against variables named password, secret, api, apiKey, token, auth, pass, or hash. For more info see [Using Node.js Event Loop for Timing Attacks](https://snyk.io/blog/node-js-timing-attack-ccc-ctf/) | 2.0.11
`prefer-array-literal` | Use array literal syntax when declaring or instantiating array types. For example, prefer the Javascript form of string[] to the TypeScript form Array<string>. Prefer '[]' to 'new Array()'. Prefer '[4, 5]' to 'new Array(4, 5)'. Prefer '[undefined, undefined]' to 'new Array(4)'. Since 2.0.10, this rule can be configured to allow Array type parameters. To ignore type parameters, configure the rule with the values: `[ true, { 'allow-type-parameters': true } ]`| 1.0, 2.0.10

@@ -136,2 +144,17 @@ `prefer-const` | Use `const` to declare variables if they are only assigned a value once. | 2.0.6

`react-iframe-missing-sandbox` | React iframes must specify a sandbox attribute. If specified as an empty string, this attribute enables extra restrictions on the content that can appear in the inline frame. The value of the attribute can either be an empty string (all the restrictions are applied), or a space-separated list of tokens that lift particular restrictions. You many not use both allow-scripts and allow-same-origin at the same time, as that allows the embedded document to programmatically remove the sandbox attribute in some scenarios. | 2.0.10
`react-a11y-aria-unsupported-elements` | For accessibility of your website, enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | 2.0.11
`react-a11y-event-has-role` | For accessibility of your website, Elements with event handlers must have explicit role or implicit role.<br/>References:<br/>[WCAG Rule 94](http://oaa-accessibility.org/wcag20/rule/94/)<br/>[Using the button role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role) | 2.0.11
`react-a11y-image-button-has-alt` | For accessibility of your website, enforce that inputs element with `type="image"` must have non-empty alt attribute. | 2.0.11
`react-a11y-img-has-alt` | Enforce that an `img` element contains the `alt` attribute or `role='presentation'` for a decorative image. All images must have `alt` text to convey their purpose and meaning to **screen reader users**. Besides, the `alt` attribute specifies an alternate text for an image, if the image cannot be displayed. This rule accepts as a parameter a string array for tag names other than img to also check. For example, if you use a custom tag named 'Image' then configure the rule with: `[true, ['Image']]`<br/>References:<br/>[Web Content Accessibility Guidelines 1.0](https://www.w3.org/TR/WCAG10/wai-pageauth.html#tech-text-equivalent)<br/>[ARIA Presentation Role](https://www.w3.org/TR/wai-aria/roles#presentation)<br/>[WCAG Rule 31: If an image has an alt or title attribute, it should not have a presentation role](http://oaa-accessibility.org/wcag20/rule/31/) | 2.0.11
`react-a11y-lang` | For accessibility of your website, HTML elements must have a lang attribute and the attribute must be a valid language code.<br/>References:<br/>* [H58: Using language attributes to identify changes in the human language](https://www.w3.org/TR/WCAG20-TECHS/H58.html)<br/>* [lang attribute must have a valid value](https://dequeuniversity.com/rules/axe/1.1/valid-lang)<br/>[List of ISO 639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) | 2.0.11
`react-a11y-anchors` | For accessibility of your website, anchor element link text should be at least 4 characters long. Links with the same HREF should have the same link text. Links that point to different HREFs should have different link text. Links with images and text content, the alt attribute should be unique to the text content or empty. An an anchor element's href prop value must not be just #. <br/>References:<br/>[WCAG Rule 38: Link text should be as least four 4 characters long](http://oaa-accessibility.org/wcag20/rule/38/)<br/>[WCAG Rule 39: Links with the same HREF should have the same link text](http://oaa-accessibility.org/wcag20/rule/39/)<br/>[WCAG Rule 41: Links that point to different HREFs should have different link text](http://oaa-accessibility.org/wcag20/rule/41/)<br/>[WCAG Rule 43: Links with images and text content, the alt attribute should be unique to the text content or empty](http://oaa-accessibility.org/wcag20/rule/43/)<br/> | 2.0.11
`react-a11y-meta` | For accessibility of your website, HTML meta elements must not have http-equiv="refresh". | 2.0.11
`react-a11y-props` | For accessibility of your website, enforce all `aria-*` attributes are valid. Elements cannot use an invalid `aria-*` attribute. This rule will fail if it finds an `aria-*` attribute that is not listed in [WAI-ARIA states and properties](https://www.w3.org/TR/wai-aria/states_and_properties#state_prop_def). | 2.0.11
`react-a11y-proptypes` | For accessibility of your website, enforce the type of aria state and property values are correct. | 2.0.11
`react-a11y-role-has-required-aria-props` | For accessibility of your website, elements with aria roles must have all required attributes according to the role. <br/>References:<br/>[ARIA Definition of Roles](https://www.w3.org/TR/wai-aria/roles#role_definitions)<br/>[WCAG Rule 90: Required properties and states should be defined](http://oaa-accessibility.org/wcag20/rule/90/)<br/>[WCAG Rule 91: Required properties and states must not be empty](http://oaa-accessibility.org/wcag20/rule/91/)<br/>| 2.0.11
`react-a11y-role-supports-aria-props` | For accessibility of your website, enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`. Many aria attributes (states and properties) can only be used on elements with particular roles. Some elements have implicit roles, such as `<a href='hrefValue' />`, which will be resolved to `role='link'`. A reference for the implicit roles can be found at [Default Implicit ARIA Semantics](https://www.w3.org/TR/html-aria/#sec-strong-native-semantics). <br/>References: <br/>* [ARIA attributes can only be used with certain roles](http://oaa-accessibility.org/wcag20/rule/87/)<br/>* [Check aria properties and states for valid roles and properties](http://oaa-accessibility.org/wcag20/rule/84/)<br/>* [Check that 'ARIA-' attributes are valid properties and states](http://oaa-accessibility.org/wcag20/rule/93/)| 2.0.11
`react-a11y-role` | For accessibility of your website, elements with aria roles must use a **valid**, **non-abstract** aria role. A reference to role defintions can be found at [WAI-ARIA roles](https://www.w3.org/TR/wai-aria/roles#role_definitions). References:<br/>* [WCAG Rule 92: Role value must be valid](http://oaa-accessibility.org/wcag20/rule/92/)| 2.0.11
`react-a11y-tabindex-no-positive` | For accessibility of your website, enforce tabindex value is **not greater than zero**. Avoid positive tabindex attribute values to synchronize the flow of the page with keyboard tab order.<br/>References:<br/>[WCAG 2.4.3 - Focus Order](https://www.w3.org/TR/2008/REC-WCAG20-20081211/#navigation-mechanisms-focus-order)<br/>[Audit Rules - tabindex-usage](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#tabindex-usage)<br/>[Avoid positive integer values for tabIndex](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_focus_03) | 2.0.11
`react-a11y-titles` | For accessibility of your website, HTML title elements must not be empty, must be more than one word, and must not be more than 60 characters long.<br/>References:<br/>* [WCAG 2.0 - Requirement 2.4.2 Page Titled (Level A)](http://www.w3.org/TR/WCAG20/#navigation-mechanisms-title)<br/>* [OAA-Accessibility Rule 13: Title element should not be empty](http://oaa-accessibility.org/wcag20/rule/13/)<br/>* [OAA-Accessibility Rule 24: Title content should be concise](http://oaa-accessibility.org/wcag20/rule/24/)<br/>* [OAA-Accessibility Rule 25: Title text must contain more than one word](http://oaa-accessibility.org/wcag20/rule/25/)<br/> | 2.0.11
`react-anchor-blank-noopener` | For security reasons, anchor tags with target="_blank" should also include rel="noopener noreferrer". In order to restrict the behavior window.opener access, the original page needs to add a rel="noopener" attribute to any link that has target="_blank". However, Firefox does not support that tag, so you should actually use rel="noopener noreferrer" for full coverage. For more info see: [The target="_blank" vulnerability by example](https://dev.to/ben/the-targetblank-vulnerability-by-example)| 2.0.11
`react-no-dangerous-html` | Do not use React's dangerouslySetInnerHTML API. This rule finds usages of the dangerouslySetInnerHTML API (but not any JSX references). For more info see the [react-no-dangerous-html Rule wiki page](https://github.com/Microsoft/tslint-microsoft-contrib/wiki/react-no-dangerous-html-Rule). | 0.0.2

@@ -162,5 +185,3 @@ `react-this-binding-issue` | Several errors can occur when using React and React.Component subclasses. When using React components you must be careful to correctly bind the 'this' reference on any methods that you pass off to child components as callbacks. For example, it is common to define a private method called 'onClick' and then specify `onClick={this.onClick}` as a JSX attribute. If you do this then the 'this' reference will be undefined when your private method is invoked. The React documentation suggests that you bind the 'this' reference on all of your methods within the constructor: `this.onClick = this.onClick.bind(this);`. This rule will create a violation if 1) a method reference is passed to a JSX attribute without being bound in the constructor. And 2) a method is bound multiple times in the constructor. Another issue that can occur is binding the 'this' reference to a function within the render() method. For example, many people will create an anonymous lambda within the JSX attribute to avoid the 'this' binding issue: `onClick={() => { this.onClick(); }}`. The problem with this is that a new instance of an anonymous function is created every time render() is invoked. When React compares virutal DOM properties within shouldComponentUpdate() then the onClick property will look like a new property and force a re-render. You should avoid this pattern because creating function instances within render methods breaks any logic within shouldComponentUpdate() methods. This rule creates violations if 1) an anonymous function is passed as a JSX attribute. And 2) if a function instantiated in local scope is passed as a JSX attribute. This rule can be configured via the "allow-anonymous-listeners" parameter. If you want to suppress violations for the anonymous listener scenarios then configure that rule like this: `"react-this-binding-issue": [ true, { 'allow-anonymous-listeners': true } ]` | 2.0.8, 2.0.9

git config --global core.autocrlf input
git config --global core.eol lf
git clone git@github.com:Microsoft/tslint-microsoft-contrib.git
git clone git@github.com:Microsoft/tslint-microsoft-contrib.git --config core.autocrlf=input --config core.eol=lf
cd tslint-microsoft-contrib

@@ -171,4 +192,2 @@ npm install

The repo requires you to use linefeed as a line ending, and asks that you checkout the code with linefeed endings enabled. This does change your global config, so please make a note of your previous values and revert them after the checkout if necessary.
Debug code

@@ -175,0 +194,0 @@ -----------

@@ -12,2 +12,3 @@ /**

*/
"insecure-random": true,
"no-banned-terms": true,

@@ -30,2 +31,4 @@ "no-cookies": true,

"no-string-based-set-timeout": true,
"possible-timing-attack": true,
"react-anchor-blank-noopener": true,
"react-iframe-missing-sandbox": true,

@@ -119,2 +122,3 @@ "react-no-dangerous-html": true,

"no-shadowed-variable": true,
"no-suspicious-comment": true,
"no-typeof-undefined": true,

@@ -138,2 +142,21 @@ "no-unnecessary-field-initialization": true,

/**
* Accessibility. The following rules should be turned on to guarantee the best user
* experience for keyboard and screen reader users.
*/
"react-a11y-anchors": true,
"react-a11y-aria-unsupported-elements": true,
"react-a11y-event-has-role": true,
"react-a11y-image-button-has-alt": true,
"react-a11y-img-has-alt": true,
"react-a11y-lang": true,
"react-a11y-meta": true,
"react-a11y-props": true,
"react-a11y-proptypes": true,
"react-a11y-role": true,
"react-a11y-role-has-required-aria-props": true,
"react-a11y-role-supports-aria-props": true,
"react-a11y-tabindex-no-positive": true,
"react-a11y-titles": true,
/**
* Whitespace related rules. The only recommended whitespace strategy is to pick a single format and

@@ -140,0 +163,0 @@ * be consistent.

@@ -5,2 +5,3 @@ "use strict";

var chai = require('chai');
var ErrorTolerantWalker_1 = require('../src/utils/ErrorTolerantWalker');
var TestHelper;

@@ -43,2 +44,4 @@ (function (TestHelper) {

};
var debug = ErrorTolerantWalker_1.ErrorTolerantWalker.DEBUG;
ErrorTolerantWalker_1.ErrorTolerantWalker.DEBUG = true;
var result;

@@ -61,2 +64,3 @@ if (inputFileOrScript.match(/.*\.ts(x)?$/)) {

}
ErrorTolerantWalker_1.ErrorTolerantWalker.DEBUG = debug;
return result;

@@ -79,3 +83,3 @@ }

var errorMessage = "Wrong # of failures: \n" + JSON.stringify(actualFailures, null, 2);
chai.assert.equal(expectedFailures.length, actualFailures.length, errorMessage);
chai.assert.equal(actualFailures.length, expectedFailures.length, errorMessage);
expectedFailures.forEach(function (expected, index) {

@@ -82,0 +86,0 @@ var actual = actualFailures[index];

{
"rules": {
"insecure-random": true,
"no-banned-terms": true,

@@ -24,2 +25,4 @@ "no-cookies": true,

"no-string-based-set-timeout": true,
"possible-timing-attack": true,
"react-anchor-blank-noopener": true,
"react-iframe-missing-sandbox": true,

@@ -123,2 +126,3 @@ "react-no-dangerous-html": true,

"no-shadowed-variable": true,
"no-suspicious-comment": true,
"no-typeof-undefined": true,

@@ -148,2 +152,16 @@ "no-unnecessary-field-initialization": true,

"variable-name": true,
"react-a11y-anchors": true,
"react-a11y-aria-unsupported-elements": true,
"react-a11y-event-has-role": true,
"react-a11y-image-button-has-alt": true,
"react-a11y-img-has-alt": true,
"react-a11y-lang": true,
"react-a11y-meta": true,
"react-a11y-props": true,
"react-a11y-proptypes": true,
"react-a11y-role": true,
"react-a11y-role-has-required-aria-props": true,
"react-a11y-role-supports-aria-props": true,
"react-a11y-tabindex-no-positive": true,
"react-a11y-titles": true,
"align": [

@@ -150,0 +168,0 @@ true,

@@ -18,4 +18,3 @@ "use strict";

var expressionText = call.expression.getText();
return expressionText === 'describe' || expressionText === 'describe.only'
|| expressionText === 'describe.skip' || expressionText === 'describe.timeout';
return isDescribe(expressionText) || isContext(expressionText);
}

@@ -26,3 +25,11 @@ }

MochaUtils.isStatementDescribeCall = isStatementDescribeCall;
function isDescribe(callText) {
return callText === 'describe' || callText === 'describe.only'
|| callText === 'describe.skip' || callText === 'describe.timeout';
}
function isContext(callText) {
return callText === 'context' || callText === 'context.only'
|| callText === 'context.skip' || callText === 'context.timeout';
}
})(MochaUtils = exports.MochaUtils || (exports.MochaUtils = {}));
//# sourceMappingURL=MochaUtils.js.map

@@ -16,12 +16,2 @@ "use strict";

Utils.exists = exists;
function reduce(list, predicate, initialValue) {
var result = initialValue;
if (list != null) {
list.forEach(function (element) {
result = predicate(result, element);
});
}
return result;
}
Utils.reduce = reduce;
function contains(list, element) {

@@ -40,3 +30,3 @@ return exists(list, function (item) {

}
return filter(source, function (sourceElement) {
return source.filter(function (sourceElement) {
return !contains(elementsToRemove, sourceElement);

@@ -50,14 +40,2 @@ });

Utils.remove = remove;
function filter(list, predicate) {
if (list == null || list.length === 0) {
return [];
}
return reduce(list, function (memo, sourceElement) {
if (predicate(sourceElement)) {
memo.push(sourceElement);
}
return memo;
}, []);
}
Utils.filter = filter;
function trimTo(source, maxLength) {

@@ -64,0 +42,0 @@ if (source == null) {

@@ -10,3 +10,2 @@ "use strict";

var SyntaxKind_1 = require('./utils/SyntaxKind');
var Utils_1 = require('./utils/Utils');
var Rule = (function (_super) {

@@ -60,3 +59,3 @@ __extends(Rule, _super);

var closestMatch = 99999999;
return Utils_1.Utils.reduce(Rule.VALID_TERMS, function (closestTerm, thisTerm) {
return Rule.VALID_TERMS.reduce(function (closestTerm, thisTerm) {
var distance = _this.levenshteinDistance(term, thisTerm);

@@ -63,0 +62,0 @@ if (distance < closestMatch) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc