@block65/oxlint
v1.93.0
Published
Block65 build of oxlint with additional type-aware rules routed to @block65/oxlint-tsgolint.
Maintainers
Readme
@block65/oxlint
oxlint with five added type-aware rules and eight changed upstream rules. The
five added rules are implemented in @block65/oxlint-tsgolint, and package.json declares the
oldest build of it they work with as an optional peer dependency on
oxlint-tsgolint. Linux x64 and arm64 only, the platforms Block65 runs. The
package version names the upstream release it is built on, as described under
Versioning.
# pnpm-workspace.yaml
overrides:
oxlint: npm:@block65/oxlint@[version]
oxlint-tsgolint: npm:@block65/oxlint-tsgolint@[version]Added rules
All five are typescript/ rules in the restriction category. They run in
tsgolint, so they need --type-aware. Four report a place where a finite
type is erased, and one a value invented where a finite type would have
named the choice.
define-messages-keys:defineMessageswhose keys are not a finite union of string or number literals. A call with no type argument passes when it resolves to an overload with aconsttype parameter, as react-intl 12's does, since that already keeps the literal keys.no-open-string-fallback: an inline string literal after??or??=, or as a destructuring default outside a parameter, where the operand is an openstringor a literal union the value is outside. A member of the union chooses a default and a named value is a typed default, so both pass. The empty string is left to the block65 plugin'sno-sentinel-fallback.no-widening-alias: aconstwhose annotation is wider than its initializer, such asstringover a literal union orRecord<string, T>over an object with known keys.no-widening-object-keys:Object.keysorObject.entrieson a value with a finite key type. Optionskeysandentriesname the helpers to use instead; the defaults aretypedKeysandtypedEntries.no-widening-return-type: a return annotation wider than what the body returns, such asbooleanoverreturn true. Optioncontracts(defaulttrue) allows a named object type as the annotation.
Changed rules
typescript/no-inferrable-types reports a primitive annotation it considers
redundant and suggests deleting it. On a const holding a literal the
annotation is not redundant: const a: number = 5 is typed number, while
const a = 5 is typed 5. Deleting it narrows the type, and on an exported
declaration that narrows what every other file sees.
In this build the rule stops reporting that case for number, string,
boolean and bigint. It still reports const a: 5 = 5, where the
annotation matches what inference already gives, and let, var, parameters
and properties, which widen on their own.
Five unicorn/ rules report what they did upstream, but --fix applies
fewer of their rewrites. Where a rewrite can change behaviour or types, it is
offered as a suggestion instead, which --fix-suggestions applies, or not
offered at all:
prefer-single-callmergespush()andunshift()calls only on a variable known to be an array: annotatedT[]orArray<T>, or initialised with an array and never reassigned. Any other receiver may have apush()that takes one argument, such as a stream's.no-typeof-undefineddoes not rewrite inside a generic function or class.typeof value === "undefined"narrows a value of an unconstrained type parameter toundefined, andvalue === undefineddoes not.no-useless-undefineddoes not rewrite these in TypeScript files:return undefinedand() => undefined, which change an inferred return type fromundefinedtovoid; a parameter's= undefineddefault, which makes the parameter required; and trailingundefinedarguments, which can leave a call short of a required parameter.prefer-dom-node-appendrewritesappendChild()only where its result is discarded, sinceappend()returnsundefined.prefer-query-selectorrewrites only a literal argument that means the same as a selector: an id, class or tag name of ASCII letters, digits,_and-that does not start with a digit, or a name without quotes. An id held in a variable would needCSS.escape(), and"address.line1"as a selector matches a class.
unicorn/catch-error-name keeps the key of a shorthand property it renames:
{ cause } becomes { cause: err }, not { err }.
Four unicorn/ rules report less than they do upstream:
new-for-builtinsreportsObject()but notObject(value), a conversion TypeScript types asany, whilenew Object(value)is typedObject.prefer-math-truncdoes not report an integer literal shifted left by zero, such as1 << 0at the start of a bit-flag sequence.explicit-length-checkdoes not report.lengthor.sizebefore||with a string fallback, such asprops.size || "base", where the property is a string.no-useless-undefineddoes not reportreturn undefinedin a TypeScript function that also returns a value. UndernoImplicitReturnsevery path must then return explicitly.
unicorn/number-literal-case takes upstream unicorn's hexadecimalValue
option, "uppercase" (the default) or "lowercase". oxfmt lower-cases hex
digits, so ["error", { "hexadecimalValue": "lowercase" }] agrees with it.
Versioning
The patch is upstream's patch times 100 plus a build number. Upstream 1.83.0
gives 1.83.0, then 1.83.1; an upstream 1.83.1 would give 1.83.100. The major
and minor are upstream's, so oxlint ranges keep resolving.
