Skip to content

linter: context.getSourceCode() should be implemented or removed #15567

@SnowSquire

Description

@SnowSquire

What version of Oxlint are you using?

1.28.0

What command did you run?

oxlint src/bad.tsx

What does your .oxlintrc.json config file look like?

{
	"jsPlugins": [
		"eslint-plugin-solid"
	],
	"rules": {
		// identifier usage is important
		"solid/jsx-no-duplicate-props": 2,
		// "solid/jsx-uses-vars": 2, // not supported by oxc yet (uses markVariableAsUsed)
		// security problems
		"solid/no-innerhtml": 2,
		"solid/jsx-no-script-url": 2,
		// reactivity
		"solid/components-return-once": 1,
		"solid/no-destructure": 2,
		"solid/prefer-for": 2,
		"solid/reactivity": 1, // affected by this bug
		"solid/event-handlers": 1, // affected by this bug
		// these rules are mostly style suggestions
		"solid/imports": 1,
		"solid/style-prop": 1,
		"solid/no-react-deps": 1,
		"solid/no-react-specific-props": 1,
		"solid/self-closing-comp": 1,
		"solid/no-array-handlers": 2,
		"solid/prefer-show": 1 // affected by this bug
	},
}

What happened?

eslint-plugin-solid fails because context.getSourceCode() is defined but just throws. The eslint implementation of the function returns the sourcecode even though it's depreciated. I think the 2 options are stop defining getSourceCode, or implement the function.

https://github.com/eslint/eslint/blob/a89059dbf2832d417dd493ee81483227ec44e4ab/lib/linter/file-context.js#L123-L130

If i patch getSourceCode to return context.sourceCode then the rules work as expected

export function getSourceCode(context: CompatContext) {
  if (typeof context.getSourceCode === "function") {
    return context.getSourceCode();
  }
  return context.sourceCode;
}
``

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions