eslint-plugin-backbone
raw JSON → 3.0.0 verified Sat Apr 25 auth: no javascript maintenance
ESLint plugin providing Backbone-specific linting rules for ESLint. Current stable version is 3.0.0, released in 2024, which requires ESLint >=9.0.0 and uses flat config only. The plugin includes rules for common Backbone patterns and anti-patterns, such as enforcing model defaults, event scope, and view conventions. Compared to alternatives like eslint-plugin-ember, this plugin is Backbone-only and has been in maintenance mode since Backbone's decline in popularity. Older versions (2.x) support ESLint 3.x-8.x with legacy config.
Common errors
error Error: Failed to load plugin 'backbone': Cannot find module 'eslint-plugin-backbone' ↓
cause Plugin not installed or peer dependencies missing (ESLint >=9 required).
fix
Run
npm install eslint-plugin-backbone --save-dev and ensure ESLint version is >=9. error Configuration for rule 'backbone/collection-model' is invalid: Value [2, {...}] is not an array. ↓
cause Using ESLint legacy config with v3 plugin which expects flat config format.
fix
Upgrade to ESLint >=9 and use eslint.config.js with flat config, not .eslintrc.
error TypeError: backbone.configs is not iterable ↓
cause Import error: likely using CJS require('eslint-plugin-backbone').configs.recommended which is undefined.
fix
Use ESM import:
import backbone from 'eslint-plugin-backbone' and access backbone.configs.recommended. error ESLint couldn't determine the plugin 'backbone' uniquely. ↓
cause Multiple instances of eslint-plugin-backbone installed, or legacy config with plugin name collision.
fix
Ensure only one version is installed (dedupe with
npm dedupe). In flat config, use the plugin object directly. Warnings
breaking v3.0.0 drops support for ESLint <9 and removes legacy .eslintrc configs. Only flat config is supported. ↓
fix Upgrade to ESLint >=9 and use eslint.config.js with flat config. Do not use .eslintrc.* files.
breaking v3.0.0 changes import style: you must use ESM import, not CJS require. ↓
fix Replace `const backbone = require('eslint-plugin-backbone')` with `import backbone from 'eslint-plugin-backbone'`.
deprecated v2.x is deprecated. It still receives critical fixes but no new features. ↓
fix Upgrade to v3 if you can use ESLint >=9. Otherwise, stay on v2.1.1.
gotcha Rule 'no-native-jquery' default severity is 'warn' but some users expect it to be 'error'. ↓
fix Override rule severity in your config: `'backbone/no-native-jquery': 'error'`.
gotcha When using flat config, you must explicitly list all global variables (Backbone, _) if not using recommended config. ↓
fix Add `globals: { Backbone: 'writable', _: 'writable' }` in your flat config.
gotcha The events-on-top rule accepts an array of property names; misconfiguring it can cause false positives. ↓
fix Ensure the second argument is a flat array of strings, e.g., ['tagName', 'className'].
Install
npm install eslint-plugin-backbone yarn add eslint-plugin-backbone pnpm add eslint-plugin-backbone Imports
- default import wrong
const backbone = require('eslint-plugin-backbone')correctimport backbone from 'eslint-plugin-backbone' - plugin object (for plugins field) wrong
var backbone = require('eslint-plugin-backbone').defaultcorrectimport backbone from 'eslint-plugin-backbone' - configs.recommended wrong
require('eslint-plugin-backbone').configs.recommendedcorrectbackbone.configs.recommended - rules (flat config style) wrong
rules: { 'collection-model': 2 }correctrules: { 'backbone/collection-model': 'error' }
Quickstart
import eslint from '@eslint/js';
import backbone from 'eslint-plugin-backbone';
import globals from 'globals';
export default [
eslint.configs.recommended,
backbone.configs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
Backbone: 'writable',
_: 'writable'
}
},
rules: {
'backbone/collection-model': 'error',
'backbone/defaults-on-top': 'warn'
}
}
];