{"id":25869,"library":"lint-fn","title":"Lint Fn","description":"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.","status":"active","version":"2.45.0","language":"javascript","source_language":"en","source_url":"https://github.com/selfrefactor/services#master","tags":["javascript","typescript"],"install":[{"cmd":"npm install lint-fn","lang":"bash","label":"npm"},{"cmd":"yarn add lint-fn","lang":"bash","label":"yarn"},{"cmd":"pnpm add lint-fn","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for TypeScript file support","package":"typescript","optional":false}],"imports":[{"note":"ESM-only since v2. The default export is a function that lints a file.","wrong":"const lintFn = require('lint-fn')","symbol":"default","correct":"import lintFn from 'lint-fn'"},{"note":"Named export for the lint function. Both default and named exports exist.","wrong":null,"symbol":"lintFn","correct":"import { lintFn } from 'lint-fn'"},{"note":"Type import for TypeScript types. Use 'import type' to avoid runtime overhead.","wrong":"import { LintOptions } from 'lint-fn'","symbol":"type LintOptions","correct":"import type { LintOptions } from 'lint-fn'"}],"quickstart":{"code":"import lintFn from 'lint-fn';\n\nconst filePath = 'src/index.ts';\nconst options = {\n  fix: true,\n  rules: {\n    'no-unused-vars': 'error'\n  },\n  // SKIP_ESLINT_RULES env var can skip rules: 'no-nested-ternary, max-len'\n};\n\nprocess.env.SKIP_ESLINT_RULES = 'no-nested-ternary';\n\nlintFn(filePath, options)\n  .then((result) => {\n    console.log('Lint fixed:', result);\n  })\n  .catch((error) => {\n    console.error('Lint error:', error);\n  });","lang":"typescript","description":"Demonstrates importing lintFn and using it to lint a TypeScript file with custom rules and env variable to skip a rule."},"warnings":[{"fix":"Use import syntax or upgrade to Node.js >15 and set 'type': 'module' in package.json.","message":"Version 2.0+ is ESM-only and requires Node.js >15. CommonJS require() will fail.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Switch to import { lintFn } from 'lint-fn'.","message":"Default import may be removed in future versions; prefer named import { lintFn } for clarity.","severity":"deprecated","affected_versions":">=2.0"},{"fix":"Add ESLint debug configuration or avoid linting .d.ts files directly.","message":"Linting of TypeScript declaration files (*.d.ts) may not work correctly; manual ESLint debug config needed.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure custom rules are passed in the options object; check documentation for path-based rule precedence.","message":"Predefined rules depend on file path; custom rules may be overridden if not passed correctly.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use dynamic import: import('lint-fn') or switch to ES modules.","cause":"Using CommonJS require() to import an ESM-only module with Node.js <15 or without module type.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/lint-fn/index.js from /path/to/your-file.js not supported."},{"fix":"Use import lintFn from 'lint-fn' for default, or import { lintFn } for named.","cause":"Attempting default import without default export, or mixing named and default imports incorrectly.","error":"TypeError: lintFn is not a function"},{"fix":"npm install typescript@4.7.4 --save-dev","cause":"TypeScript peer dependency not installed.","error":"Cannot find module 'typescript' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}