GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: correct types and tighten type definitions in `SourceCode` class… · eslint/eslint@dc5ed33

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/languages/js/source-code
    • source-code.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/languages/js/source-code/source-code.js‎

Copy file name to clipboardExpand all lines: lib/languages/js/source-code/source-code.js
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const CODE_PATH_EVENTS = [
5353
/**
5454
* Validates that the given AST has the required information.
5555
* @param {ASTNode} ast The Program node of the AST to check.
56-
* @throws {Error} If the AST doesn't contain the correct information.
56+
* @throws {TypeError} If the AST doesn't contain the correct information.
5757
* @returns {void}
5858
* @private
5959
*/
@@ -147,8 +147,8 @@ function sortedMerge(tokens, comments) {
147147
* Normalizes a value for a global in a config
148148
* @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in
149149
* a global directive comment
150-
* @returns {("readable"|"writeable"|"off")} The value normalized as a string
151-
* @throws Error if global value is invalid
150+
* @returns {("readonly"|"writable"|"off")} The value normalized as a string
151+
* @throws {Error} if global value is invalid
152152
*/
153153
function normalizeConfigGlobal(configuredValue) {
154154
switch (configuredValue) {
@@ -471,6 +471,10 @@ class SourceCode extends TokenStore {
471471
* @type {string[]}
472472
*/
473473
this.lines = [];
474+
475+
/**
476+
* @type {number[]}
477+
*/
474478
this.lineStartIndices = [0];
475479

476480
const lineEndingPattern = astUtils.createGlobalLinebreakMatcher();
@@ -528,7 +532,7 @@ class SourceCode extends TokenStore {
528532

529533
/**
530534
* Gets the entire source text split into an array of lines.
531-
* @returns {Array} The source text as an array of lines.
535+
* @returns {string[]} The source text as an array of lines.
532536
* @public
533537
*/
534538
getLines() {
@@ -687,8 +691,8 @@ class SourceCode extends TokenStore {
687691
/**
688692
* Converts a source text index into a (line, column) pair.
689693
* @param {number} index The index of a character in a file
690-
* @throws {TypeError} If non-numeric index or index out of range.
691-
* @returns {Object} A {line, column} location object with a 0-indexed column
694+
* @throws {TypeError|RangeError} If non-numeric index or index out of range.
695+
* @returns {{line: number, column: number}} A {line, column} location object with a 0-indexed column
692696
* @public
693697
*/
694698
getLocFromIndex(index) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.