Skip to content

TypeScript (and JavaScript) Plugin

Rules for linting JavaScript and TypeScript code, including the latest and greatest powerful typed linting rules.
This plugin comes packaged with the flint npm package.

Flint’s TypeScript plugin provides the following presets:

PresetRecommendedDescription
logical✅ AlwaysCommon rules for finding bugs and enforcing good logical practices.
logicalStrict☑️ When ReadyAdditional rules for finding bugs and enforcing good logical practices.
stylistic✅ AlwaysCommon rules for consistent styling and best stylistic practices.
stylisticStrict☑️ When ReadyAdditional rules for consistent styling and best stylistic practices.
untypedExtra rules for files that aren’t type-checked by TypeScript.

If you are just getting started with linting, Flint recommends using the logical and stylistic presets:

flint.config.ts
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: [ts.presets.logical, ts.presets.stylistic],
},
],
});

If you are experienced with both JavaScript/TypeScript and linting, Flint recommends using the logicalStrict and stylisticStrict presets:

flint.config.ts
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: [ts.presets.logicalStrict, ts.presets.stylisticStrict],
},
],
});

Rules that find bugs and enforce good logical practices for most-to-all JavaScript and TypeScript files.

flint.config.ts
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: ts.presets.logical,
},
],
});

Additional logical rules that enforce best practices which are not always straightforward to implement. These rules are recommended for projects where a majority of developers are experienced with both JavaScript/TypeScript and using a linter.

flint.config.ts
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: ts.presets.logicalStrict,
},
],
});

This preset’s rules are a superset of those in logical.

Rules that enforce consistent styling and best stylistic practices for most-to-all JavaScript and TypeScript files.

flint.config.ts
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: ts.presets.stylistic,
},
],
});

Additional stylistic rules that enforce best practices which are not always straightforward to implement. These rules are recommended for projects where a majority of developers are experienced with both JavaScript/TypeScript and using a linter.

flint.config.ts
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: ts.presets.stylisticStrict,
},
],
});

This preset’s rules are a superset of those in stylistic.

Rules that fill in rudimentary safety practices that would normally be caught by TypeScript.

flint.config.ts
import { defineConfig, ts } from "flint";
export default defineConfig({
use: [
{
files: ts.files.all,
rules: ts.presets.untyped,
},
],
});

The untyped preset is broadly applicable for JavaScript files that aren’t type-checked by TypeScript. For long-lived projects, Flint recommends using this only as a stopgap measure pending converting files fully to TypeScript.

Implemented: 57 of 399 (14.2%)
Flint RulePreset
anyArgumentslogical
anyAssignmentslogical
anyCallslogical
anyMemberAccesslogical
anyReturnsReports returning a value with type any from a function.logical
argumentslogical
arrayConstructorslogical
arrayElementDeletionslogical
arrayEmptyCallbackSlotslogical
arrayMapIdentitieslogical
arrayUnnecessaryLengthCheckslogical
asyncFunctionAwaitslogical
asyncPromiseExecutorsReports using async functions as Promise executor functions.logical
asyncUnnecessaryPromiseWrapperslogical
awaitThenablelogical
caseDuplicatesReports switch statements with duplicate case clause test expressions.logical
caseFallthroughslogical
catchCallbackTypeslogical
charAtComparisonslogical
constVariableslogical
dateConstructorCloneslogical
debuggerStatementsReports using debugger statements.logical
defaultCaseLastReports switch statements where the default clause is not last.logical
deprecatedlogical
dynamicDeleteslogical
elseIfDuplicatesReports duplicate conditions in if-else-if chains that make code unreachable.logical
emptyDestructuresReports using empty destructuring patterns that destructure no values.logical
emptyEnumslogical
emptyExportslogical
emptyObjectTypeslogical
enumMemberLiteralslogical
enumMixedValueslogical
enumValueConsistencylogical
enumValueDuplicateslogical
equalityOperatorslogical
errorUnnecessaryCaptureStackTraceslogical
evalslogical
exceptionAssignmentsReports reassigning exception parameters in catch clauses.logical
explicitAnyslogical
exportMutableslogical
fetchMethodBodieslogical
finallyStatementSafetyReports control flow statements in finally blocks that can override control flow in try/catch blocks.logical
floatingPromiseslogical
forInArraysReports iterating over an array with a for-in loop.logical
functionCurryingRedundancyReports using .apply() or .call() or when the context (this value) provides no benefit.logical
functionNewCallsReports using the Function constructor to create functions from strings.logical
generatorFunctionYieldsReports generator functions that do not yield values.logical
getterSetterPairedTypeslogical
impliedEvalslogical
importEmptyBlockslogical
instanceOfArrayslogical
irregularWhitespaceslogical
isNaNComparisonslogical
meaninglessVoidOperatorslogical
misleadingVoidExpressionslogical
misusedPromiseslogical
moduleSpecifierListslogical
namespaceDeclarationsReports using legacy namespace declarations.logical
negativeZeroComparisonsReports comparisons with -0 that may not behave as expected.logical
newDefinitionslogical
newExpressionsReports standalone new expressions that don't use the constructed object.logical
nonNullAssertedOptionalChainslogical
nonOctalDecimalEscapesReports non-octal decimal escape sequences (\8 and \9) in string literals.logical
numberMethodRangeslogical
numericErasingOperationslogical
numericPrecisionlogical
objectCallsPrefer {} object literal notation or Object.create instead of calling or constructing Object.logical
objectPrototypeBuiltInsReports direct calls to Object.prototype methods on object instances.logical
objectSpreadUnnecessaryFallbackslogical
parameterPropertyAssignmentlogical
parseIntRadixeslogical
plusOperandslogical
promiseExecutorReturnslogical
promiseFinallyReturnslogical
promiseMethodSingleArrayArgumentslogical
promiseRejectErrorslogical
recursionOnlyArgumentslogical
redundantTypeConstituentslogical
regexAllGlobalFlagslogical
regexAmbiguousInvaliditylogical
regexContradictoryAssertionslogical
regexControlCharacterEscapeslogical
regexControlCharacterslogical
regexDuplicateCharacterClassCharacterslogical
regexDuplicateDisjunctionslogical
regexEmptyAlternativeslogical
regexEmptyCapturingGroupslogical
regexEmptyCharacterClasseslogical
regexEmptyGroupslogical
regexEmptyLazyQuantifierslogical
regexEmptyLookaroundsAssertionslogical
regexEmptyStringLiteralslogical
regexEscapeBackspaceslogical
regexIgnoreCaseFlagslogical
regexInvisibleCharacterslogical
regexLegacyFeatureslogical
regexLiteralslogical
regexLookaroundQuantifierOptimizationslogical
regexMisleadingCapturingGroupslogical
regexMisleadingQuantifierslogical
regexMisleadingUnicodeCharacterslogical
regexNamedCaptureGroupslogical
regexNonStandardFlagslogical
regexObscureRangeslogical
regexOctalEscapeslogical
regexQuantifierOptimizationslogical
regexSetOperationOptimizationslogical
regexStandaloneBackslasheslogical
regexSuperLinearBacktrackinglogical
regexSuperLinearMoveslogical
regexUnnecessaryAssertionslogical
regexUnnecessaryBackreferenceslogical
regexUnnecessaryCharacterClasseslogical
regexUnnecessaryCharacterRangeslogical
regexUnnecessaryDisjunctionslogical
regexUnnecessaryDollarReplacementslogical
regexUnnecessaryLookaroundAssertionslogical
regexUnnecessaryNestedAssertionslogical
regexUnnecessaryNestedQuantifierslogical
regexUnnecessaryNumericQuantifierslogical
regexUnnecessaryOptionalAssertionslogical
regexUnnecessaryReferentialBackreferenceslogical
regexUnnecessarySetOperandslogical
regexUnusedCapturingGroupslogical
regexUnusedFlagslogical
regexUnusedLazyQuantifierslogical
regexUnusedQuantifierslogical
regexValiditylogical
regexZeroQuantifierslogical
requireImportslogical
returnAwaitPromiseslogical
selfAssignmentsReports self-assignments which have no effect and are likely errors.logical
singleVariableDeclarationslogical
sparseArraysReports array literals with holes (sparse arrays).logical
strictBooleanExpressionslogical
stringCaseMismatcheslogical
templateExpressionValueslogical
thisAliaseslogical
throwErrorslogical
tripleSlashReferenceslogical
tripleSlashReferenceValiditylogical
tsCommentslogical
typeConstituentDuplicateslogical
unboundMethodslogical
unnecessaryBindlogical
unnecessaryCatchesReports catch clauses that only rethrow the caught error without modification.logical
unnecessaryComparisonslogical
unnecessaryConditionslogical
unnecessaryContinueslogical
unnecessaryLogicalComparisonslogical
unnecessaryMathClampslogical
unnecessaryNumericFractionslogical
unnecessarySpreadslogical
unnecessaryTemplateExpressionslogical
unnecessaryTypeArgumentslogical
unnecessaryTypeAssertionslogical
unnecessaryTypeConstraintslogical
unnecessaryTypeConversionslogical
unnecessaryTypeParameterslogical
unnecessaryUndefinedDefaultslogical
unnecessaryUseStrictslogical
unsafeDeclarationmerginglogical
unsafeEnumComparisonslogical
unsafeFunctionTypeslogical
unsafeToStringlogical
unsafeTypeAssertionslogical
unsafeUnaryNegationslogical
unusedExpressionslogical
unusedPrivateClassMemberslogical
unusedSwitchStatementslogical
unusedValueslogical
unusedVariableslogical
uselessDefaultAssignmentslogical
wrapperObjectslogical
wrapperObjectTypeslogical
accessorThisRecursionlogical (strict)
awaitInsidePromiseMethodslogical (strict)
caughtErrorCauseslogical (strict)
dateNowTimestampslogical (strict)
directivePairslogical (strict)
errorMessageslogical (strict)
errorSubclassPropertieslogical (strict)
extraneousClasseslogical (strict)
importExtraneousDependencieslogical (strict)
invalidVoidTypeslogical (strict)
nonNullAssertedNullishCoalesceslogical (strict)
nonNullAssertionslogical (strict)
reduceTypeParameterslogical (strict)
regexGraphemeStringLiteralslogical (strict)
returnThisTypeslogical (strict)
selfComparisonsReports comparing a value to itself.logical (strict)
stringCodePointslogical (strict)
unifiedSignatureslogical (strict)
arrayDeleteUnnecessaryCountsstylistic
arrayExistenceChecksConsistencystylistic
arrayFindsstylistic
arrayFlatUnnecessaryDepthsstylistic
arrayIncludesstylistic
arrayLoopsstylistic
arrayMutableReversesstylistic
arrayMutableSortsstylistic
arraySliceUnnecessaryEndstylistic
arrayTernarySpreadingConsistencystylistic
arrayTypesstylistic
asConstAssertionsstylistic
assignmentOperatorShorthandsstylistic
builtinConstructorNewsstylistic
chainedAssignmentsReports using chained assignment expressions (e.g., a = b = c).stylistic
classLiteralPropertiesstylistic
consecutiveNonNullAssertionsReports unnecessary extra non-null assertions.stylistic
emptyBlocksReports empty block statements that should contain code.stylistic
emptyModuleAttributesstylistic
emptyStaticBlocksReports empty static initialization blocks within class declarations.stylistic
emptyTypeParameterListsstylistic
exponentiationOperatorsstylistic
exportFromImportsstylistic
forDirectionsReports for loops with counter variables that move in the wrong direction.stylistic
functionCallSpreadsstylistic
functionTypeDeclarationsstylistic
genericConstructorCallsstylistic
groupedAccessorPairsstylistic
importCyclesstylistic
importDuplicatesstylistic
importSelfstylistic
importUnnecessaryPathSegmentsstylistic
indexedObjectTypesstylistic
jsdocAccessTagsstylistic
jsdocEmptyBlocksstylistic
jsdocEmptyTagsstylistic
jsdocImplementsTagsstylistic
jsdocParameterNamesstylistic
jsdocPropertyNamesstylistic
jsdocRedundantTypesstylistic
jsdocTemplateNamesstylistic
jsdocTypesSyntaxstylistic
jsdocUnnecessaryReturnsstylistic
jsdocUnnecessaryYieldsstylistic
jsdocValidTypesstylistic
jsdocValuesstylistic
jsdocYieldsstylistic
literalConstructorWrappersstylistic
methodSignatureStylesstylistic
multilineAmbiguitiesstylistic
namespaceKeywordsstylistic
nestedStandaloneIfsstylistic
nonNullableTypeAssertionsstylistic
nullishCoalescingOperatorsstylistic
numericLiteralParsingReports parseInt calls with binary, hexadecimal, or octal strings that can be replaced with numeric literals.stylistic
objectAssignSpreadsstylistic
objectHasOwnsPrefer Object.hasOwn() over Object.prototype.hasOwnProperty.call() for checking own properties.stylistic
objectShorthandstylistic
objectTypeDefinitionsstylistic
operatorAssignmentShorthandstylistic
optionalChainOperatorsstylistic
overloadSignaturesAdjacentstylistic
promiseFunctionAsyncstylistic
propertyAccessNotationstylistic
regexCharacterClassRangesstylistic
regexCharacterClassSetOperationsstylistic
regexConciseCharacterClassNegationsstylistic
regexDollarEscapesstylistic
regexPredefinedAssertionsstylistic
regexRepeatQuantifiersstylistic
regexTestMethodsstylistic
regexUnicodeEscapesstylistic
regexUnicodePropertiesstylistic
regexUnnecessaryEscapesstylistic
responseMethodsstylistic
returnAssignmentsReports using assignment expressions in return statements.stylistic
shadowsstylistic
stringStartsEndsWithstylistic
symbolDescriptionsReports Symbol() calls without description arguments.stylistic
tslintCommentsstylistic
typeAssertionsstylistic
typeExportsstylistic
typeImportsstylistic
undefinedInitialValuesstylistic
unicodeBOMsReports files with Unicode Byte Order Marks (BOMs).stylistic
unnecessaryBlocksReports standalone block statements that don't create a meaningful scope.stylistic
unnecessaryBooleanCastsstylistic
unnecessaryComputedKeysstylistic
unnecessaryConcatenationReports string concatenation using the + operator when both operands are string literals.stylistic
unnecessaryConstructorsstylistic
unnecessaryEscapesstylistic
unnecessaryQualifiersstylistic
unnecessaryRenamesstylistic
unnecessaryReturnsstylistic
unnecessaryTypeAnnotationsstylistic
unusedLabelsstylistic
varDeclarationsstylistic
voidOperatorReports using the void operator.stylistic
arrayFilteredFindsstylistic (strict)
arrayFlatMapMethodsstylistic (strict)
arrayFlatMethodsstylistic (strict)
arrayIncludesMethodsstylistic (strict)
arrayIndexOfMethodsstylistic (strict)
arraySomeMethodsstylistic (strict)
atAccessesstylistic (strict)
builtinCoercionsstylistic (strict)
caughtVariableNamesstylistic (strict)
classMethodsThisstylistic (strict)
combinedPushesstylistic (strict)
destructuringConsistencystylistic (strict)
directiveRequireDescriptionsstylistic (strict)
elseReturnsstylistic (strict)
emptyFilesstylistic (strict)
emptyFunctionsstylistic (strict)
escapeSequenceCasingstylistic (strict)
functionDefinitionScopeConsistencystylistic (strict)
globalThisAliasesstylistic (strict)
jsdocAsterisksstylistic (strict)
jsdocInformativeDocsstylistic (strict)
jsdocMisleadingBlocksstylistic (strict)
jsdocMultilineBlocksstylistic (strict)
jsdocParameterDescriptionHyphensstylistic (strict)
jsdocTagNamesstylistic (strict)
mathMethodsstylistic (strict)
namedDefaultExportsstylistic (strict)
namespaceImplicitAmbientImportsstylistic (strict)
negativeIndexLengthMethodsstylistic (strict)
nonNullAssertionPlacementstylistic (strict)
numberStaticMethodsstylistic (strict)
numericLiteralCasingstylistic (strict)
numericSeparatorGroupsstylistic (strict)
objectEntriesMethodsstylistic (strict)
parameterReassignmentsstylistic (strict)
regexCharacterClassesstylistic (strict)
regexDigitMatchersstylistic (strict)
regexExecutorsstylistic (strict)
regexHexadecimalEscapesstylistic (strict)
regexLetterCasingstylistic (strict)
regexLookaroundAssertionsstylistic (strict)
regexMatchNotationstylistic (strict)
regexNamedBackreferencesstylistic (strict)
regexNamedReplacementsstylistic (strict)
regexPlusQuantifiersstylistic (strict)
regexQuestionQuantifiersstylistic (strict)
regexResultArrayGroupsstylistic (strict)
regexStarQuantifiersstylistic (strict)
regexUnicodeCodepointEscapesstylistic (strict)
regexUnnecessaryNonCapturingGroupsstylistic (strict)
regexWordMatchersstylistic (strict)
setHasExistenceChecksstylistic (strict)
setSizeLengthChecksstylistic (strict)
sizeComparisonOperatorsstylistic (strict)
staticMemberOnlyClassesstylistic (strict)
stringSliceMethodsstylistic (strict)
stringTrimMethodsstylistic (strict)
structuredCloneMethodsstylistic (strict)
topLevelAwaitsstylistic (strict)
undefinedTypeofChecksstylistic (strict)
unnecessaryTernariesstylistic (strict)
arrayCallbackReturnsuntyped
caseDeclarationsReports lexical declarations in case clauses without wrapping them in blocks.untyped
classAssignmentsReports reassigning class declarations.untyped
classFieldDeclarationsuntyped
classMemberDuplicatesuntyped
constantAssignmentsReports attempting to reassign variables declared with const.untyped
constructorReturnsReports returning values from constructor functions.untyped
constructorSupersuntyped
defaultParameterLastuntyped
duplicateArgumentsReports functions with duplicate parameter names in their signatures.untyped
functionAssignmentsReports reassigning variables declared with function declarations.untyped
getterReturnsuntyped
globalAssignmentsReports attempting to assign to read-only global variables such as undefined, NaN, Infinity, Object, etc.untyped
globalObjectCallsReports calling global objects like Math, JSON, or Reflect as functions.untyped
importAssignmentsuntyped
invalidThisuntyped
nativeObjectExtensionsuntyped
newNativeNonConstructorsDisallows using new with global non-constructor functions like Symbol and BigInt.untyped
objectKeyDuplicatesReports unnecessary duplicate keys that override previous values.untyped
objectProtoReports using the deprecated proto property to access or modify an object's prototype.untyped
octalEscapesReports using octal escape sequences in string literals.untyped
octalNumbersReports using legacy octal numeric literals.untyped
sequencesReports using the comma operator in expressions.untyped
setterReturnsuntyped
shadowedRestrictedNamesReports variable declarations that shadow JavaScript's restricted names.untyped
thisBeforeSuperuntyped
typeofComparisonsReports typeof expressions that compare impossible string literals.untyped
unassignedVariablesReports variables that are declared but never assigned a value.untyped
undefinedVariablesReports using variables that are not defined.untyped
unreachableStatementsuntyped
unsafeNegationsReports negating the left operand of in or instanceof relations.untyped
unsafeOptionalChainsuntyped
usageBeforeDefinitionuntyped
useStrictDirectivesuntyped
variableBlockScopeUsageuntyped
variableDeletionsReports attempting to delete variables with the delete operator.untyped
variableRedeclarationsuntyped
withStatementsReports using with statementsuntyped
consoleCalls(none)
importTypeSideEffects(none)
regexUnicodeFlag(none)
restrictedGlobals(none)
restrictedIdentifiers(none)
restrictedImports(none)
restrictedProperties(none)
restrictedSyntax(none)
restrictedTypes(none)

Flint’s TypeScript plugin provides the following file selector:

  • all: **/*.{cjs,js,jsx,mjs,ts,tsx}
Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.