Skip to content

linter: Panic when eslint-disable-next-line is tailed by none-rulename #25892

Description

@Isokaeder

What version of Oxlint are you using?

1.76.0

What command did you run?

oxlint --max-warnings=0

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
	"$schema": "./node_modules/oxlint/configuration_schema.json",
	"plugins": [
		"eslint",
		"import",
		"oxc",
		"promise",
		"typescript",
		"unicorn",
		"vue"
	],
	"categories": {
		"correctness": "error",
		"pedantic": "error"
	},
	"jsPlugins": ["eslint-plugin-perfectionist"],
	"ignorePatterns": [
		"**/node_modules/**",
		"**/dist/**",
		"src/shared/types/api-specs.d.ts",
		"eslint.config.js"
	],
	"rules": {
		"max-classes-per-file": "off",
		"max-dependencies": "off",
		"max-depth": "off",
		"max-lines": "off",
		"max-lines-per-function": "off",
		"no-alert": "error",
		"no-console": "error",
		"no-else-return": "off",
		"no-empty": "error",
		"no-inline-comments": "off",
		"no-magic-numbers": [
			"error",
			{
				"ignore": [-1, 0, 1, 2, 3, 5, 10]
			}
		],
		"no-negated-condition": "off",
		"no-restricted-imports": [
			"error",
			{
				"paths": [
					{
						"allowTypeImports": true,
						"message": "Import dayjs from ~shared/config/dayjs-config",
						"name": "dayjs"
					},
					{
						"importNames": ["SetupContext"],
						"message": "It’s not necessary to manually annotate the setup function’s context.",
						"name": "vue"
					},
					{
						"allowTypeImports": true,
						"message": "Avoid named imports from lodash (e.g. import { foo } from 'lodash'); use direct imports instead (e.g. import foo from 'lodash/foo').",
						"name": "lodash"
					}
				]
			}
		],
		"no-use-before-define": "error",
		"no-warning-comments": "off",
		"no-unneeded-ternary": "error",
		"no-unused-expressions": ["error", { "allowTernary": true }],
		"require-unicode-regexp": "off",
		"import/no-named-as-default-member": "off",
		"oxc/bad-bitwise-operator": "warn",
		"oxc/branches-sharing-code": "warn",
		"perfectionist/sort-array-includes": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-classes": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-enums": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-exports": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-interfaces": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-intersection-types": [
			"warn",
			{
				"groups": ["named", "object", "function", "unknown", "nullish"],
				"order": "asc",
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-jsx-props": [
			"warn",
			{
				"type": "natural"
			}
		],
		"perfectionist/sort-maps": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-modules": "off", // conflicts with @typescript-eslint/no-use-before-define
		"perfectionist/sort-named-exports": [
			"warn",
			{ "partitionByComment": true, "type": "natural" }
		],
		"perfectionist/sort-named-imports": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-object-types": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-objects": [
			"warn",
			{
				"type": "unsorted",
				"useConfigurationIf": {
					"callingFunctionNamePattern": "^defineComponent$"
				}
			},
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-sets": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-switch-case": [
			"warn",
			{
				"type": "natural"
			}
		],
		"perfectionist/sort-union-types": [
			"warn",
			{
				"groups": ["named", "object", "function", "unknown", "nullish"],
				"order": "asc",
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"perfectionist/sort-variable-declarations": [
			"warn",
			{
				"partitionByComment": true,
				"type": "natural"
			}
		],
		"promise/no-multiple-resolved": "error",
		"typescript/ban-ts-comment": "off",
		"typescript/consistent-type-imports": "error",
		"typescript/dot-notation": "error",
		"typescript/no-base-to-string": "error",
		"typescript/no-duplicate-type-constituents": "off",
		"typescript/no-dynamic-delete": "error",
		"typescript/no-empty-interface": "error",
		"typescript/no-empty-object-type": "error",
		"typescript/no-explicit-any": "error",
		"typescript/no-floating-promises": "off",
		"typescript/no-inferrable-types": "error",
		"typescript/no-misused-promises": "off",
		"typescript/no-non-null-assertion": "error",
		"typescript/no-unnecessary-boolean-literal-compare": "error",
		"typescript/no-unnecessary-condition": "error",
		"typescript/no-unnecessary-template-expression": "error",
		"typescript/no-unnecessary-type-arguments": "error",
		"typescript/no-unnecessary-type-assertion": "error",
		"typescript/no-unnecessary-type-constraint": "error",
		"typescript/no-unnecessary-type-conversion": "error",
		"typescript/no-unnecessary-type-parameters": "error",
		"typescript/no-unsafe-argument": "off",
		"typescript/no-unsafe-assignment": "off",
		"typescript/no-unsafe-call": "off",
		"typescript/no-unsafe-enum-comparison": "off",
		"typescript/no-unsafe-member-access": "off",
		"typescript/no-unsafe-return": "off",
		"typescript/no-unsafe-type-assertion": "off",
		"typescript/no-unused-vars": "error",
		"typescript/non-nullable-type-assertion-style": "off",
		"typescript/prefer-find": "error",
		"typescript/prefer-for-of": "error",
		"typescript/prefer-nullish-coalescing": "warn",
		"typescript/prefer-readonly-parameter-types": "off",
		"typescript/prefer-reduce-type-parameter": "error",
		"typescript/prefer-regexp-exec": "error",
		"typescript/promise-function-async": "off",
		"typescript/restrict-template-expressions": "off",
		"typescript/return-await": "off",
		"typescript/strict-boolean-expressions": "off",
		"typescript/strict-void-return": "off",
		"typescript/switch-exhaustiveness-check": "off",
		"unicorn/escape-case": "off",
		"unicorn/no-array-callback-reference": "off",
		"unicorn/no-hex-escape": "off",
		"unicorn/no-negated-condition": "off",
		"unicorn/no-useless-undefined": "off",
		"unicorn/prefer-add-event-listener": "error",
		"unicorn/prefer-at": "off",
		"unicorn/prefer-dom-node-dataset": "off",
		"unicorn/prefer-number-coercion": "off",
		"unicorn/prefer-ternary": "warn",
		"vue/no-required-prop-with-default": "error",
		"vue/require-default-export": "error"
	},
	"options": {
		"reportUnusedDisableDirectives": "warn",
		"typeAware": true
	},
	"overrides": [
		{
			"files": ["**/*.test.ts", "**/test/*.ts"],
			"rules": {
				"no-console": "off",
				"no-magic-numbers": "off",
				"no-non-null-assertion": "off",
				"typescript/no-explicit-any": "off",
				"typescript/unbound-method": "off",
				"vitest/no-disabled-tests": "error"
			}
		}
	],
	"env": {
		"builtin": true,
		"node": true
	}
}

What happened?

After some file changes I ran oxlint and it panicked with this rather cryptic error:

thread '<unnamed>' (1028348) panicked at crates/oxc_linter/src/disable_directives.rs:205:25:
start byte index 2228 is out of bounds for string of length 0

Luckily I could figure it out when I looked at my diff: I added this line of code as one of changes:

// oxlint-disable-next-line typescript/no-explicit-any FORWARD does not exist on Icon enum
const icon = Yoco.Icon.FORWARD as any

Removing the "FORWARD does not exist on Icon enum" part in the ignore comment fixed the issue.

I can not give you the whole file for proprietary reasons, but I ran some tests.

  • Linting only the file would not run into the issue, neither does copying the above two lines in a separate file by itself.
  • Generally copying thsee lines if I copy them into .ts files never reproduced the issue, but any time I would copy them into a .vue file it would (the original file where it happened is a .vue file as well).
  • removing the valid rule name will stop oxlint from panicking
// oxlint-disable-next-line FORWARD does not exist on Icon enum
const icon = Yoco.Icon.FORWARD as any
  • removing the line that contains the lint error will stop oxlint from panicking
// oxlint-disable-next-line typescript/no-explicit-any FORWARD does not exist on Icon enum
  • disabling reportUnusedDisableDirectives will stop oxlint from panicking

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions