ember-template-lint-plugin-css-modules
raw JSON → 1.0.0 verified Fri May 01 auth: no javascript
An ember-template-lint plugin for enforcing best practices with ember-css-modules. Version 1.0.0 (stable) switches to ES Modules, requires Node >=12.22.0 and ember-template-lint ^4.2.0. Provides two rules: 'no-class' (disallows all class attributes) and 'static-local-class' (requires local-class values to be static strings). Differentiates from generic linting by being tailor-made for the ember-css-modules addon, ensuring modular CSS patterns are enforced at template level.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module from /path/to/ember-template-lint-plugin-css-modules/index.js not supported. Instead rename the index.js to a file of .cjs extension... ↓
cause CommonJS project trying to require the ESM-only plugin (v1.0.0+)
fix
Convert project to ESM or use dynamic import: const plugin = (await import('ember-template-lint-plugin-css-modules')).default;
error Cannot find module 'ember-template-lint-plugin-css-modules' ↓
cause Plugin not installed or peer dependency ember-template-lint missing
fix
Run 'npm install --save-dev ember-template-lint-plugin-css-modules' and ensure ember-template-lint ^4.2.0 is installed.
error Validation error: Invalid rule name 'no-class' in config. Did you mean 'css-modules/no-class'? ↓
cause Rule specified without the 'css-modules/' prefix
fix
Change rule key to 'css-modules/no-class' in your .template-lintrc.js.
Warnings
breaking v1.0.0 ships as ES Module only. CommonJS require() will throw. ↓
fix Use import syntax or dynamic import if using CommonJS project (e.g., 'const plugin = await import(...)').
breaking Node.js <12.22.0 or between 13.x and 15.x may not be supported. ↓
fix Upgrade Node.js to a supported major version (12.22+, 14.17+, 16+).
deprecated ember-template-lint v3 is not supported; peer dependency requires ^4.2.0 ↓
fix Upgrade ember-template-lint to v4.2.0 or higher.
gotcha Rules must be prefixed with 'css-modules/' in .template-lintrc.js ↓
fix Use 'css-modules/no-class' instead of 'no-class'.
Install
npm install ember-template-lint-plugin-css-modules yarn add ember-template-lint-plugin-css-modules pnpm add ember-template-lint-plugin-css-modules Imports
- plugin wrong
plugins: ['ember-template-lint-plugin-css-modules/index']correctplugins: ['ember-template-lint-plugin-css-modules'] - rules wrong
rules: { 'no-class': true }correctrules: { 'css-modules/no-class': true } - default import (ESM) wrong
const plugin = require('ember-template-lint-plugin-css-modules');correctimport plugin from 'ember-template-lint-plugin-css-modules';
Quickstart
// .template-lintrc.js - ESM (requires Node ES module)
import plugin from 'ember-template-lint-plugin-css-modules';
export default {
plugins: ['ember-template-lint-plugin-css-modules'],
rules: {
'css-modules/no-class': true,
'css-modules/static-local-class': true,
},
};