summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/source-code/source-code.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2021-10-09 18:11:41 -0700
committerRich Trott <rtrott@gmail.com>2021-10-11 18:37:33 -0700
commit8ca76eba73cf75a72cc008b09c2ae537fe6e6d0f (patch)
tree28dc44d1bc746b3c65536bbb40d5ef6d94b3e7f4 /tools/node_modules/eslint/lib/source-code/source-code.js
parentdd8e219d71e999a66c5fa4e01436c179425a4c8a (diff)
downloadnode-new-8ca76eba73cf75a72cc008b09c2ae537fe6e6d0f.tar.gz
tools: update ESLint to 8.0.0
PR-URL: https://github.com/nodejs/node/pull/40394 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/lib/source-code/source-code.js')
-rw-r--r--tools/node_modules/eslint/lib/source-code/source-code.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/node_modules/eslint/lib/source-code/source-code.js b/tools/node_modules/eslint/lib/source-code/source-code.js
index cc4524fa74..49b2820a84 100644
--- a/tools/node_modules/eslint/lib/source-code/source-code.js
+++ b/tools/node_modules/eslint/lib/source-code/source-code.js
@@ -143,10 +143,12 @@ function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) {
// Public Interface
//------------------------------------------------------------------------------
+/**
+ * Represents parsed source code.
+ */
class SourceCode extends TokenStore {
/**
- * Represents parsed source code.
* @param {string|Object} textOrConfig The source code text or config object.
* @param {string} textOrConfig.text The source code text.
* @param {ASTNode} textOrConfig.ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
@@ -175,20 +177,20 @@ class SourceCode extends TokenStore {
/**
* The flag to indicate that the source code has Unicode BOM.
- * @type boolean
+ * @type {boolean}
*/
this.hasBOM = (text.charCodeAt(0) === 0xFEFF);
/**
* The original text source code.
* BOM was stripped from this text.
- * @type string
+ * @type {string}
*/
this.text = (this.hasBOM ? text.slice(1) : text);
/**
* The parsed AST for the source code.
- * @type ASTNode
+ * @type {ASTNode}
*/
this.ast = ast;
@@ -223,7 +225,7 @@ class SourceCode extends TokenStore {
/**
* The source code split into lines according to ECMA-262 specification.
* This is done to avoid each rule needing to do so separately.
- * @type string[]
+ * @type {string[]}
*/
this.lines = [];
this.lineStartIndices = [0];
@@ -506,6 +508,7 @@ class SourceCode extends TokenStore {
/**
* Converts a source text index into a (line, column) pair.
* @param {number} index The index of a character in a file
+ * @throws {TypeError} If non-numeric index or index out of range.
* @returns {Object} A {line, column} location object with a 0-indexed column
* @public
*/
@@ -545,6 +548,9 @@ class SourceCode extends TokenStore {
* @param {Object} loc A line/column location
* @param {number} loc.line The line number of the location (1-indexed)
* @param {number} loc.column The column number of the location (0-indexed)
+ * @throws {TypeError|RangeError} If `loc` is not an object with a numeric
+ * `line` and `column`, if the `line` is less than or equal to zero or
+ * the line or column is out of the expected range.
* @returns {number} The range index of the location in the file.
* @public
*/