eslint-plugin-sonarjs
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -1,2 +0,2 @@ | ||
import { TSESLint } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESLint } from '@typescript-eslint/experimental-utils'; | ||
declare const sonarjsRuleModules: { | ||
@@ -3,0 +3,0 @@ [key: string]: any; |
@@ -7,3 +7,2 @@ "use strict"; | ||
'elseif-without-else', | ||
'generator-without-yield', | ||
'max-switch-cases', | ||
@@ -10,0 +9,0 @@ 'no-all-duplicated-branches', |
@@ -22,3 +22,2 @@ "use strict"; | ||
// https://sonarsource.github.io/rspec/#/rspec/S2201 | ||
const ts = require("typescript"); | ||
const parser_services_1 = require("../utils/parser-services"); | ||
@@ -215,2 +214,5 @@ const docs_url_1 = require("../utils/docs-url"); | ||
const typeNode = services.program.getTypeChecker().typeToTypeNode(type, undefined, undefined); | ||
// dynamically import 'typescript' as classic 'import' will fail if project not using 'typescript' parser | ||
// we are sure it's available as 'RequiredParserServices' are available here | ||
const ts = require('typescript'); | ||
return typeNode && ts.isFunctionTypeNode(typeNode); | ||
@@ -217,0 +219,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { TSESTree } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESTree } from '@typescript-eslint/experimental-utils'; | ||
/** Returns a list of statements corresponding to a `if - else if - else` chain */ | ||
@@ -3,0 +3,0 @@ export declare function collectIfBranches(node: TSESTree.IfStatement): { |
@@ -1,2 +0,2 @@ | ||
import { TSESTree, TSESLint } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESTree, TSESLint } from '@typescript-eslint/experimental-utils'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Equivalence is implemented by comparing node types and their tokens. |
@@ -1,2 +0,2 @@ | ||
import { TSESTree, TSESLint } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESTree, TSESLint } from '@typescript-eslint/experimental-utils'; | ||
import { Rule } from './types'; | ||
@@ -3,0 +3,0 @@ export interface IssueLocation { |
@@ -1,2 +0,2 @@ | ||
import { TSESTree } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESTree } from '@typescript-eslint/experimental-utils'; | ||
export declare function isArrowFunctionExpression(node: TSESTree.Node | undefined): node is TSESTree.ArrowFunctionExpression; | ||
@@ -3,0 +3,0 @@ export declare function isAssignmentExpression(node: TSESTree.Node | undefined): node is TSESTree.AssignmentExpression; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isVariableDeclaration = exports.isThrowStatement = exports.isReturnStatement = exports.isObjectExpression = exports.isModuleDeclaration = exports.isMemberExpression = exports.isLogicalExpression = exports.isLiteral = exports.isIfStatement = exports.isIdentifier = exports.isFunctionExpression = exports.isFunctionDeclaration = exports.isExpressionStatement = exports.isContinueStatement = exports.isConditionalExpression = exports.isCallExpression = exports.isBooleanLiteral = exports.isBlockStatement = exports.isBinaryExpression = exports.isAssignmentExpression = exports.isArrowFunctionExpression = void 0; | ||
/* | ||
* eslint-plugin-sonarjs | ||
* Copyright (C) 2018-2021 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
const experimental_utils_1 = require("@typescript-eslint/experimental-utils"); | ||
const MODULE_DECLARATION_NODES = [ | ||
experimental_utils_1.AST_NODE_TYPES.ImportDeclaration, | ||
experimental_utils_1.AST_NODE_TYPES.ExportNamedDeclaration, | ||
experimental_utils_1.AST_NODE_TYPES.ExportDefaultDeclaration, | ||
experimental_utils_1.AST_NODE_TYPES.ExportAllDeclaration, | ||
'ImportDeclaration', | ||
'ExportNamedDeclaration', | ||
'ExportDefaultDeclaration', | ||
'ExportAllDeclaration', | ||
]; | ||
@@ -30,0 +10,0 @@ function isArrowFunctionExpression(node) { |
@@ -1,2 +0,2 @@ | ||
import { ParserServices } from '@typescript-eslint/experimental-utils'; | ||
import type { ParserServices } from '@typescript-eslint/experimental-utils'; | ||
export declare type RequiredParserServices = { | ||
@@ -3,0 +3,0 @@ [k in keyof ParserServices]: Exclude<ParserServices[k], undefined>; |
@@ -1,2 +0,2 @@ | ||
import { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils'; | ||
declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>; | ||
@@ -3,0 +3,0 @@ export declare namespace Rule { |
@@ -1,3 +0,3 @@ | ||
import { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils'; | ||
export declare function isIdentifier(node: TSESTree.Node, ...values: string[]): node is TSESTree.Identifier; | ||
export declare function isReferenceTo(ref: TSESLint.Scope.Reference, node: TSESTree.Node): boolean; |
@@ -1,3 +0,3 @@ | ||
import { TSESTree } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESTree } from '@typescript-eslint/experimental-utils'; | ||
export declare function findFirstMatchingAncestor(node: TSESTree.Node, predicate: (node: TSESTree.Node) => boolean): TSESTree.Node | undefined; | ||
export declare function ancestorsChain(node: TSESTree.Node, boundaryTypes: Set<string>): TSESTree.Node[]; |
@@ -1,3 +0,3 @@ | ||
import { TSESTree } from '@typescript-eslint/experimental-utils'; | ||
import type { TSESTree } from '@typescript-eslint/experimental-utils'; | ||
import { RequiredParserServices } from './parser-services'; | ||
export declare function getTypeFromTreeNode(node: TSESTree.Node, services: RequiredParserServices): import("typescript").Type; |
{ | ||
"name": "eslint-plugin-sonarjs", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "SonarJS rules for ESLint", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -11,3 +11,2 @@ # eslint-plugin-sonarjs [![npm version](https://badge.fury.io/js/eslint-plugin-sonarjs.svg)](https://badge.fury.io/js/eslint-plugin-sonarjs) [![Build Status](https://api.cirrus-ci.com/github/SonarSource/eslint-plugin-sonarjs.svg?branch=master)](https://cirrus-ci.com/github/SonarSource/eslint-plugin-sonarjs) [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=eslint-plugin-sonarjs&metric=alert_status)](https://sonarcloud.io/dashboard?id=eslint-plugin-sonarjs) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=eslint-plugin-sonarjs&metric=coverage)](https://sonarcloud.io/dashboard?id=eslint-plugin-sonarjs) | ||
* Generators should "yield" something ([`generator-without-yield`]) | ||
* All branches in a conditional structure should not have exactly the same implementation ([`no-all-duplicated-branches`]) | ||
@@ -19,3 +18,3 @@ * Collection elements should not be replaced unconditionally ([`no-element-overwrite`]) | ||
* Identical expressions should not be used on both sides of a binary operator ([`no-identical-expressions`]) | ||
* Return values from functions without side effects should not be ignored ([`no-ignored-return`]) | ||
* Return values from functions without side effects should not be ignored ([`no-ignored-return`]) (*uses-types*) | ||
* Loops with at most one iteration should be refactored ([`no-one-iteration-loop`]) | ||
@@ -33,3 +32,3 @@ * The output of functions that don't return anything should not be used ([`no-use-of-empty-return-value`]) | ||
* Collapsible "if" statements should be merged ([`no-collapsible-if`]) | ||
* Collection sizes and array length comparisons should make sense ([`no-collection-size-mischeck`]) | ||
* Collection sizes and array length comparisons should make sense ([`no-collection-size-mischeck`]) (*uses-types*) | ||
* String literals should not be duplicated ([`no-duplicate-string`]) | ||
@@ -55,3 +54,2 @@ * Two branches in a conditional structure should not have exactly the same implementation ([`no-duplicated-branches`]) | ||
[`elseif-without-else`]: ./docs/rules/elseif-without-else.md | ||
[`generator-without-yield`]: ./docs/rules/generator-without-yield.md | ||
[`max-switch-cases`]: ./docs/rules/max-switch-cases.md | ||
@@ -90,3 +88,4 @@ [`no-all-duplicated-branches`]: ./docs/rules/no-all-duplicated-branches.md | ||
Node.js (>=10.x). | ||
* Node.js (>=10.x). | ||
* ESLint 5.x, 6.x or 7.x (peer dependency for the plugin). | ||
@@ -130,2 +129,3 @@ ## Usage | ||
``` | ||
* To enable all rules of this plugin use `@typescript-eslint/parser` as a parser for ESLint ([like we do](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/6e06d59a233e07b28fbbd6398e08b9b0c63b18f9/.eslintrc.js#L4)). Thanks to it, type information is available, which is beneficial or even essential for some rules. | ||
@@ -132,0 +132,0 @@ ## Available Configurations |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
287535
143
4250