Registry / testing / coffeelint

coffeelint

JSON →
library2.1.0jsnpmunverified

CoffeeLint is a style checker for CoffeeScript that helps keep code consistent and avoid common mistakes. Version 2.1.0 (stable, released 2019) targets Node.js >=6.9.1. It provides over 20 built-in rules covering spacing, naming, and syntax pitfalls. Alternatives like coffeelint-stylish offer custom reporters, but CoffeeLint remains the standard linter for the CoffeeScript ecosystem.

npm install coffeelint
INSTALL
IMPORT
SIG · COFFEELINT
C
coffeelint
testingjavascriptv2.1.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.

coffeelint
const coffeelint = require('coffeelint');
import coffeelint from 'coffeelint';
CoffeeLint does not ship ES modules; use CommonJS require.
coffeelint.lint
coffeelint.lint(source, config, options);
coffeelint.lint(source, options);
Second argument must be a config object (may be empty). Only two positional args besides optional callback.
coffeelint.registerRule
coffeelint.registerRule(rule, ruleName);
coffeelint.registerRule(rule);
registerRule requires ruleName as second argument.

Lints a CoffeeScript file using a custom config and prints errors to console.

const coffeelint = require('coffeelint'); const fs = require('fs'); const source = fs.readFileSync('./example.coffee', 'utf8'); const config = { max_line_length: { level: 'warn', value: 80 }, no_trailing_whitespace: { level: 'error' } }; const errors = coffeelint.lint(source, config); if (errors.length) { errors.forEach(err => console.log(`Line ${err.lineNumber}: ${err.message} (${err.rule})`)); } else { console.log('No lint errors!'); }
coffeelint --version
Debug
Known issues
breakingv2.0.0 dropped Node.js 4 support; requires Node >=6.9.1.
fix
Update Node.js to v6.9.1 or later.
affects: >=2.0.0
deprecatedRule 'no_tabs' is deprecated in favor of 'indentation'.
fix
Use 'indentation' rule with 'tabs' option.
affects: >=1.10.0
gotchaConfig option 'level' for a rule is case-sensitive; only 'error', 'warn', or 'ignore' accepted.
fix
Ensure level strings are lowercase exactly.
affects: >=1.0.0
gotchaCoffeeLint uses its own CoffeeScript parser (coffee-script) and may produce different results than the official compiler version.
fix
Pin coffee-script version to match your project's compiler version.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: config is not a function
Calling lint(source, configFunction) instead of lint(source, config). require('coffeelint') is not the lint function.
fix
Use coffeelint.lint(source, config) – note, coffeelint is required, not coffeelint.lint.
Error: Cannot find module 'coffee-script'
coffee-script is a peer dependency not automatically installed.
fix
Run npm install coffee-script --save-dev
Ignoring file because extension is not .coffee or .litcoffee
CoffeeLint only scans .coffee and .litcoffee files by default.
fix
Pass a custom glob pattern or rename your file to have .coffee extension.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
coffee-scriptrequiredRequired to parse CoffeeScript files.
globrequiredUsed for file globbing patterns.
ignorerequiredUsed to respect .gitignore rules.
minimatchrequiredUsed for pattern matching.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
coffeelint — npm install coffeelint · libregistry