eslint-plugin-cflint
raw JSON → 1.0.0 verified Sat Apr 25 auth: no javascript
ESLint plugin providing two custom CloudFlare-specific linting rules: `no-substr` (prevents use of `String.prototype.substr`, considered legacy) and `no-this-assignment` (prevents assigning `this` to a variable). Current stable version is 1.0.0, initially released with no further updates. It requires ESLint as a peer dependency. Differentiators: lightweight and focused exclusively on patterns flagged internally by CloudFlare; minimal setup and no extra dependencies. Release cadence: single release, no maintenance indicated.
Common errors
error ESLint: Failed to load plugin 'cflint': Cannot find module 'eslint-plugin-cflint' ↓
cause Plugin not installed or ESLint cannot locate it.
fix
Run
npm install eslint-plugin-cflint --save-dev and ensure node_modules contains the package. error ESLint: Configuration for rule "cflint/no-substr" is invalid. Severity should be one of: 0, 1, 2, "off", "warn", "error". ↓
cause Incorrect rule severity value in ESLint config.
fix
Use 'error', 'warn', 'off' (or 2, 1, 0) as rule values.
Warnings
gotcha Plugin has only two rules; may not meet expectations for broader linting. ↓
fix Review the rules list; supplement with other ESLint plugins if needed.
gotcha Rules are deprecated within CloudFlare; no longer actively maintained. ↓
fix Consider using built-in ESLint rules like 'no-restricted-properties' for substr.
gotcha Plugin does not provide any shared configs (e.g., 'recommended'). Must be manually configured. ↓
fix Add 'cflint/no-substr' and 'cflint/no-this-assignment' manually to rules.
Install
npm install eslint-plugin-cflint yarn add eslint-plugin-cflint pnpm add eslint-plugin-cflint Imports
- plugin wrong
const plugin = require('eslint-plugin-cflint')correctimport plugin from 'eslint-plugin-cflint' - rules wrong
const { rules } = require('eslint-plugin-cflint')correctimport { rules } from 'eslint-plugin-cflint' - configs
import { configs } from 'eslint-plugin-cflint'
Quickstart
// .eslintrc.js
module.exports = {
plugins: ['cflint'],
rules: {
'cflint/no-substr': 'error',
'cflint/no-this-assignment': 'error'
}
};
// Example code that will be flagged:
let s = 'hello';
console.log(s.substr(0, 2)); // Error: no-substr
let self = this; // Error: no-this-assignment