Registry / testing / lint-fn

lint-fn

JSON →
library2.45.0jsnpmunverified

lint-fn is a Node.js library (v2.45.0) that runs ESLint with automatic fixes using predefined rules based on file path. It supports JavaScript and TypeScript files, has a peer dependency on TypeScript 4.7.4, and requires Node.js >15. Differentiators include file-path-based rule selection and environment variable support for skipping specific ESLint rules. The package ships TypeScript types, but has a known issue with linting certain TypeScript declaration files like rambda/files/index.d.ts. Development appears slow, with a TODO item referencing lack of ESLint debug config. The library is published on npm and hosted on GitHub under selfrefactor/services.

npm install lint-fn
INSTALL
IMPORT
SIG · LINT-FN
L
lint-fn
testingjavascriptv2.45.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import lintFn from 'lint-fn'
const lintFn = require('lint-fn')
ESM-only since v2. The default export is a function that lints a file.
lintFn
import { lintFn } from 'lint-fn'
Named export for the lint function. Both default and named exports exist.
type LintOptions
import type { LintOptions } from 'lint-fn'
import { LintOptions } from 'lint-fn'
Type import for TypeScript types. Use 'import type' to avoid runtime overhead.

Demonstrates importing lintFn and using it to lint a TypeScript file with custom rules and env variable to skip a rule.

import lintFn from 'lint-fn'; const filePath = 'src/index.ts'; const options = { fix: true, rules: { 'no-unused-vars': 'error' }, // SKIP_ESLINT_RULES env var can skip rules: 'no-nested-ternary, max-len' }; process.env.SKIP_ESLINT_RULES = 'no-nested-ternary'; lintFn(filePath, options) .then((result) => { console.log('Lint fixed:', result); }) .catch((error) => { console.error('Lint error:', error); });
Debug
Known issues
breakingVersion 2.0+ is ESM-only and requires Node.js >15. CommonJS require() will fail.
fix
Use import syntax or upgrade to Node.js >15 and set 'type': 'module' in package.json.
affects: >=2.0
deprecatedDefault import may be removed in future versions; prefer named import { lintFn } for clarity.
fix
Switch to import { lintFn } from 'lint-fn'.
affects: >=2.0
gotchaLinting of TypeScript declaration files (*.d.ts) may not work correctly; manual ESLint debug config needed.
fix
Add ESLint debug configuration or avoid linting .d.ts files directly.
affects: all
gotchaPredefined rules depend on file path; custom rules may be overridden if not passed correctly.
fix
Ensure custom rules are passed in the options object; check documentation for path-based rule precedence.
affects: all
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/lint-fn/index.js from /path/to/your-file.js not supported.
Using CommonJS require() to import an ESM-only module with Node.js <15 or without module type.
fix
Use dynamic import: import('lint-fn') or switch to ES modules.
TypeError: lintFn is not a function
Attempting default import without default export, or mixing named and default imports incorrectly.
fix
Use import lintFn from 'lint-fn' for default, or import { lintFn } for named.
Cannot find module 'typescript' or its corresponding type declarations.
TypeScript peer dependency not installed.
fix
npm install typescript@4.7.4 --save-dev
Upgrade
Version history
2.45.0latest on npm
Audit
Dependencies
typescriptrequiredpeer dependency for TypeScript file support
Agent activity
4 hits · last 30 days
node
4
Resources
lint-fn — npm install lint-fn · libregistry