Performance Plugin
Rules for specialized code designed specifically to be run in performance-critical "hot paths".
This plugin is provided in a standalone @flint.fyi/plugin-performance npm package.
npm install @flint.fyi/plugin-performancebun install @flint.fyi/plugin-performancedeno install @flint.fyi/plugin-performancepnpm install @flint.fyi/plugin-performanceyarn install @flint.fyi/plugin-performancePresets
Section titled βPresetsβFlintβs performance plugin provides the following preset:
| Preset | Recommended | Description |
|---|---|---|
logical | β Always | Common rules for finding bugs and good practices for high-performance code. |
Flint recommends using the logical preset:
import { const performance: Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined>, Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined>, Rule<...>, Rule<...>, Rule<...>]>
performance } from "@flint.fyi/performance";import { function defineConfig(definition: ConfigDefinition): Config
Defines a new linter configuration for a Flint config file.
defineConfig } from "flint";
export default function defineConfig(definition: ConfigDefinition): Config
Defines a new linter configuration for a Flint config file.
defineConfig({ ConfigDefinition.use: ConfigUseDefinition[]
Specifies the files to be linted alongside the rules and settings to lint with.
use: [ { ConfigUseDefinition.files: AnyLevelDeep<FilesValue>
A list of glob patterns describing which file(s) to lint.
files: const performance: Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined>, Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined>, Rule<...>, Rule<...>, Rule<...>]>
performance.Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"]; } & { ...; }, "noDelete", undefined>, Rule<...>, Rule<...>, Rule<...>, Rule<...>]>.files: undefined
Selectors of files this plugin suggests applying its rules to.
files.any
all, ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>
Any number of rules and/or presets of rules to enable for those files.
rules: [const performance: Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined>, Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined>, Rule<...>, Rule<...>, Rule<...>]>
performance.Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"]; } & { ...; }, "noDelete", undefined>, Rule<...>, Rule<...>, Rule<...>, Rule<...>]>.presets: PluginPresets<[Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined>, Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined>, Rule<{ readonly description: "Reports using await expressions inside loops."; readonly id: "loopAwaits"; readonly presets: readonly [...];} & { readonly pluginId: string; readonly url: string;}, "noAwaitInLoop", undefined>, Rule<...>, Rule<...>]>
Preset lists of rules to enable on files.
presets.logical: (Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined> | Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined> | Rule<{ readonly description: "Reports using await expressions inside loops."; readonly id: "loopAwaits"; readonly presets: readonly [...];} & { readonly pluginId: string; readonly url: string;}, "noAwaitInLoop", undefined> | Rule<...> | Rule<...>)[]
logical], }, ],});logical
Section titled βlogicalβRules that find bugs and enforce good performance practices and catch common pitfalls for most-to-all JavaScript and TypeScript files.
import { const performance: Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined>, Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined>, Rule<...>, Rule<...>, Rule<...>]>
performance } from "@flint.fyi/performance";import { function defineConfig(definition: ConfigDefinition): Config
Defines a new linter configuration for a Flint config file.
defineConfig } from "flint";
export default function defineConfig(definition: ConfigDefinition): Config
Defines a new linter configuration for a Flint config file.
defineConfig({ ConfigDefinition.use: ConfigUseDefinition[]
Specifies the files to be linted alongside the rules and settings to lint with.
use: [ { ConfigUseDefinition.files: AnyLevelDeep<FilesValue>
A list of glob patterns describing which file(s) to lint.
files: const performance: Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined>, Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined>, Rule<...>, Rule<...>, Rule<...>]>
performance.Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"]; } & { ...; }, "noDelete", undefined>, Rule<...>, Rule<...>, Rule<...>, Rule<...>]>.files: undefined
Selectors of files this plugin suggests applying its rules to.
files.any
all, ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>
Any number of rules and/or presets of rules to enable for those files.
rules: const performance: Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined>, Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined>, Rule<...>, Rule<...>, Rule<...>]>
performance.Plugin<RuleAbout<string>, string | undefined, [Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"]; } & { ...; }, "noDelete", undefined>, Rule<...>, Rule<...>, Rule<...>, Rule<...>]>.presets: PluginPresets<[Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined>, Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined>, Rule<{ readonly description: "Reports using await expressions inside loops."; readonly id: "loopAwaits"; readonly presets: readonly [...];} & { readonly pluginId: string; readonly url: string;}, "noAwaitInLoop", undefined>, Rule<...>, Rule<...>]>
Preset lists of rules to enable on files.
presets.logical: (Rule<{ readonly description: "Reports using the delete operator."; readonly id: "deletes"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDelete", undefined> | Rule<{ readonly description: "Disallow computed member access on imported namespace identifiers."; readonly id: "importedNamespaceDynamicAccesses"; readonly presets: readonly ["logical"];} & { readonly pluginId: string; readonly url: string;}, "noDynamicAccess", undefined> | Rule<{ readonly description: "Reports using await expressions inside loops."; readonly id: "loopAwaits"; readonly presets: readonly [...];} & { readonly pluginId: string; readonly url: string;}, "noAwaitInLoop", undefined> | Rule<...> | Rule<...>)[]
logical, }, ],});| Flint Rule | Preset |
|---|---|
deletesReports using the delete operator. | logical |
importedNamespaceDynamicAccessesDisallow computed member access on imported namespace identifiers. | logical |
loopAwaitsReports using await expressions inside loops. | logical |
loopFunctionsReports function declarations and expressions inside loops that reference variables modified by the loop. | logical |
spreadAccumulatorsReports spread operations that accumulate values in loops, causing quadratic time complexity. | logical |