@typescript-eslint/typescript-estree
Advanced tools
Comparing version
@@ -8,3 +8,3 @@ /** | ||
import ts from 'typescript'; | ||
import { ESTreeNodeLoc, ESTreeNode, ESTreeToken } from './temp-types-based-on-js-source'; | ||
import { ESTreeNodeLoc, ESTreeNode, ESTreeToken, LineAndColumnData } from './temp-types-based-on-js-source'; | ||
import { AST_NODE_TYPES } from './ast-node-types'; | ||
@@ -73,2 +73,9 @@ /** | ||
/** | ||
* Returns line and column data for the given positions, | ||
* @param pos position to check | ||
* @param ast the AST object | ||
* @returns line and column | ||
*/ | ||
export declare function getLineAndCharacterFor(pos: number, ast: ts.SourceFile): LineAndColumnData; | ||
/** | ||
* Returns line and column data for the given start and end positions, | ||
@@ -130,11 +137,2 @@ * for the given AST | ||
/** | ||
* Find the first matching token based on the given predicate function. | ||
* @param {ts.Node} previousToken The previous ts.Token | ||
* @param {ts.Node} parent The parent ts.Node | ||
* @param {Function} predicate The predicate function to apply to each checked token | ||
* @param {ts.SourceFile} ast The TS AST | ||
* @returns {ts.Node|undefined} a matching ts.Token | ||
*/ | ||
export declare function findFirstMatchingToken(previousToken: ts.Node | undefined, parent: ts.Node, predicate: (node: ts.Node) => boolean, ast: ts.SourceFile): ts.Node | undefined; | ||
/** | ||
* Find the first matching ancestor based on the given predicate function. | ||
@@ -141,0 +139,0 @@ * @param {ts.Node} node The current ts.Node |
@@ -201,2 +201,16 @@ "use strict"; | ||
/** | ||
* Returns line and column data for the given positions, | ||
* @param pos position to check | ||
* @param ast the AST object | ||
* @returns line and column | ||
*/ | ||
function getLineAndCharacterFor(pos, ast) { | ||
const loc = ast.getLineAndCharacterOfPosition(pos); | ||
return { | ||
line: loc.line + 1, | ||
column: loc.character | ||
}; | ||
} | ||
exports.getLineAndCharacterFor = getLineAndCharacterFor; | ||
/** | ||
* Returns line and column data for the given start and end positions, | ||
@@ -210,12 +224,5 @@ * for the given AST | ||
function getLocFor(start, end, ast) { | ||
const startLoc = ast.getLineAndCharacterOfPosition(start), endLoc = ast.getLineAndCharacterOfPosition(end); | ||
return { | ||
start: { | ||
line: startLoc.line + 1, | ||
column: startLoc.character | ||
}, | ||
end: { | ||
line: endLoc.line + 1, | ||
column: endLoc.character | ||
} | ||
start: getLineAndCharacterFor(start, ast), | ||
end: getLineAndCharacterFor(end, ast) | ||
}; | ||
@@ -351,20 +358,2 @@ } | ||
/** | ||
* Find the first matching token based on the given predicate function. | ||
* @param {ts.Node} previousToken The previous ts.Token | ||
* @param {ts.Node} parent The parent ts.Node | ||
* @param {Function} predicate The predicate function to apply to each checked token | ||
* @param {ts.SourceFile} ast The TS AST | ||
* @returns {ts.Node|undefined} a matching ts.Token | ||
*/ | ||
function findFirstMatchingToken(previousToken, parent, predicate, ast) { | ||
while (previousToken) { | ||
if (predicate(previousToken)) { | ||
return previousToken; | ||
} | ||
previousToken = findNextToken(previousToken, parent, ast); | ||
} | ||
return undefined; | ||
} | ||
exports.findFirstMatchingToken = findFirstMatchingToken; | ||
/** | ||
* Find the first matching ancestor based on the given predicate function. | ||
@@ -371,0 +360,0 @@ * @param {ts.Node} node The current ts.Node |
{ | ||
"name": "@typescript-eslint/typescript-estree", | ||
"version": "1.1.1-alpha.7+bdf880b", | ||
"version": "1.1.1-alpha.8+4954ed2", | ||
"description": "A parser that converts TypeScript source code into an ESTree compatible form", | ||
@@ -45,6 +45,6 @@ "main": "dist/parser.js", | ||
"devDependencies": { | ||
"@typescript-eslint/shared-fixtures": "1.1.1-alpha.7+bdf880b", | ||
"@typescript-eslint/shared-fixtures": "1.1.1-alpha.8+4954ed2", | ||
"typescript": "~3.2.1" | ||
}, | ||
"gitHead": "bdf880bc2c7817852e542fb926a7fa6510c2db69" | ||
"gitHead": "4954ed2c476bf9654ffe020b587fd6691a985d01" | ||
} |
Sorry, the diff of this file is too big to display
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
216612
-0.72%5247
-0.57%