CoffeeLint CJSX
raw JSON → 2.0.2 verified Fri May 01 auth: no javascript maintenance
A fork of CoffeeLint that adds support for React's CJSX syntax. Version 2.0.2 is the latest stable release; it uses coffee-react-transform 2.x, compatible with React 0.12. The package has irregular releases tied to React version changes. Key differentiators: enables CoffeeScript linting with JSX-like syntax, useful for legacy React projects using CoffeeScript. Current maintainer: Evan Morikawa. Note: This is a fork of the original coffeelint, aiming to merge back when possible.
Common errors
error Error: Cannot find module 'coffee-react-transform' ↓
cause Missing peer dependency coffee-react-transform.
fix
Run: npm install coffee-react-transform
error ReferenceError: CoffeeLint is not defined ↓
cause Incorrect import or require statement (e.g., using `import` in Node without transpilation).
fix
Use const CoffeeLint = require('coffeelint-cjsx');
error Syntax error: unexpected < ↓
cause CJSX syntax not recognized by CoffeeScript parser; npm install coffee-react-transform might be missing or outdated.
fix
Ensure coffee-react-transform >= 2.0.0 is installed.
error coffeelint: command not found ↓
cause CLI tool not installed globally or in PATH.
fix
Run via npx: npx coffeelint-cjsx or install locally: npm install --save-dev coffeelint-cjsx
Warnings
breaking v2.0.0 uses coffee-react-transform 2.x, which drops support for React <0.12. Upgrade your React version or use v1.x. ↓
fix Update React to >=0.12 or stay on coffeelint-cjsx@1.x.
deprecated CoffeeScript itself is deprecated in favor of modern JavaScript/TypeScript. This package is no longer actively developed. ↓
fix Consider migrating from CoffeeScript to JavaScript or TypeScript.
gotcha The package expects a 'coffeelint.json' config file in the project root; otherwise uses defaults. Missing config may cause unexpected linting errors. ↓
fix Create a 'coffeelint.json' file with desired rule configurations.
gotcha Global installation may conflict with other CoffeeLint variants (e.g., original coffeelint). Use local devDependencies. ↓
fix Install as devDependency: npm install --save-dev coffeelint-cjsx
Install
npm install coffeelint-cjsx yarn add coffeelint-cjsx pnpm add coffeelint-cjsx Imports
- CoffeeLint wrong
const CoffeeLint = require('coffeelint-cjsx')correctimport CoffeeLint from 'coffeelint-cjsx' - lint
import { lint } from 'coffeelint-cjsx' - CoffeeLint wrong
import CoffeeLint from 'coffeelint-cjsx'correctconst CoffeeLint = require('coffeelint-cjsx')
Quickstart
const CoffeeLint = require('coffeelint-cjsx');
const source = '<div>Hello</div>';
const config = { no_plusplus: { level: 'error' } };
try {
const errors = CoffeeLint.lint(source, config);
errors.forEach(e => console.log(`${e.line}: ${e.message}`));
} catch (err) {
console.error('Lint error:', err.message);
}