Skip to content

ESLint v10 compatibility #17

@raschan

Description

@raschan

Issue Summary: eslint-plugin-todo-plz incompatible with ESLint v10

Rule affected: todo-plz/ticket-ref
ESLint version: 10.x

Problem:
The ticket-ref rule calls context.getSourceCode() in its create function:

const sourceCode = context.getSourceCode();

context.getSourceCode() was deprecated in ESLint v8 (in favor of context.sourceCode) and fully removed in ESLint v10. This causes a runtime crash when the rule is loaded:
TypeError: Error while loading rule 'todo-plz/ticket-ref': context.getSourceCode is not a function

File: lib/rules/ticket-ref.js, line 56

Fix:
Replace:
const sourceCode = context.getSourceCode();
With:
const sourceCode = context.sourceCode;
Or for backwards compatibility with ESLint v8:
const sourceCode = context.sourceCode ?? context.getSourceCode();

  • ESLint v10 migration guide — removed context.getSourceCode()
  • The replacement context.sourceCode has been available since ESLint v8.39.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions