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
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.
fixUse 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.
fixRun npm install coffee-script --save-dev
Ignoring file because extension is not .coffee or .litcoffee
CoffeeLint only scans .coffee and .litcoffee files by default.
fixPass a custom glob pattern or rename your file to have .coffee extension.
Audit
Dependencies
coffee-scriptrequiredRequired to parse CoffeeScript files.
globrequiredUsed for file globbing patterns.
ignorerequiredUsed to respect .gitignore rules.
minimatchrequiredUsed for pattern matching.