Skip to content

Commit

Permalink
Always set line and column on LintMessage
Browse files Browse the repository at this point in the history
This follows the precedent already set by configuration errors, which
also lack a specific location within a file and instead hard code the
beginning of the file. If we were designing the API from scratch, we'd
probably omit locations from config errors as well, but this approach
minimizes risk of breakage for an existing codebase.
  • Loading branch information
btmills committed Apr 9, 2023
1 parent 9c2fa34 commit 0e12c67
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/cli-engine/cli-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ function createIgnoreResult(filePath, baseDir) {
{
fatal: false,
severity: 1,
message
message,
line: 0,
column: 0
}
],
suppressedMessages: [],
Expand Down
4 changes: 3 additions & 1 deletion lib/eslint/eslint-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,9 @@ function createIgnoreResult(filePath, baseDir) {
{
fatal: false,
severity: 1,
message
message,
line: 0,
column: 0
}
],
suppressedMessages: [],
Expand Down
4 changes: 2 additions & 2 deletions lib/shared/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ module.exports = {};

/**
* @typedef {Object} LintMessage
* @property {number|undefined} column The 1-based column number.
* @property {number} column The 1-based column number.
* @property {number} [endColumn] The 1-based column number of the end location.
* @property {number} [endLine] The 1-based line number of the end location.
* @property {boolean} [fatal] If `true` then this is a fatal error.
* @property {{range:[number,number], text:string}} [fix] Information for autofix.
* @property {number|undefined} line The 1-based line number.
* @property {number} line The 1-based line number.
* @property {string} message The error message.
* @property {string} [messageId] The ID of the message in the rule's meta.
* @property {(string|null)} [nodeType] Type of node
Expand Down
4 changes: 3 additions & 1 deletion tests/lib/eslint/flat-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5014,7 +5014,9 @@ describe("FlatESLint", () => {
{
fatal: false,
message: "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override.",
severity: 1
severity: 1,
line: 0,
column: 0
}
],
usedDeprecatedRules: [],
Expand Down

0 comments on commit 0e12c67

Please sign in to comment.