naming-convention
Checks identifier names against the selectors and formats you configure.
Rule details Suggestion
Section titled “Rule details ”SuggestionThis rule covers classes, interfaces, types, enums, variables, imports, parameters, members, and more. It works from the AST, so it stays fast and does not need full type-aware linting.
If you do not pass options, the default setup is:
default:camelCase, leading and trailing underscores allowedimport:camelCaseorPascalCasevariable:camelCaseorUPPER_CASE, leading and trailing underscores allowedtypeLike:PascalCase
The rule skips .d.ts files.
Configuration
Section titled “Configuration”import ceaseNonsense from "eslint-plugin-cease-nonsense";
export default [ { plugins: { "cease-nonsense": ceaseNonsense, }, rules: { "cease-nonsense/naming-convention": ["error", { selector: "interface", format: ["PascalCase"], }, { selector: "variable", format: ["camelCase", "UPPER_CASE"], leadingUnderscore: "allow", trailingUnderscore: "allow", }, ], }, },];Options
Section titled “Options”| Option | Type | What it does |
|---|---|---|
selector | string or string[] | Picks which identifiers this config entry applies to |
format | string[] or null | Allowed formats, such as camelCase, PascalCase, strictCamelCase, StrictPascalCase, snake_case, or UPPER_CASE |
filter | string or { regex, match } | Limits which names the entry applies to |
custom | { regex, match } | Adds an extra regex rule after format checks |
prefix / suffix | string[] | Requires one of the listed prefixes or suffixes |
leadingUnderscore / trailingUnderscore | string | Controls underscore usage with allow, allowDouble, allowSingleOrDouble, forbid, require, or requireDouble |
modifiers | string[] | Narrows by modifiers such as const, async, readonly, exported, unused, namespace, or requiresQuotes |
types | string[] | Narrows supported selectors by simple type groups such as array, boolean, function, number, or string |
selector supports both individual selectors like interface, typeAlias, enum, classMethod, typeProperty, and
import, and meta selectors like default, typeLike, variableLike, property, method, memberLike, and
accessor.
Examples
Section titled “Examples” Incorrect
interface IFoo {}
const foo_bar = 1;
class widgetFactory {} Correct
interface User {}
const userName = getUserName();const MAX_RETRIES = 3;
class WidgetFactory {}Common patterns
Section titled “Common patterns”[ { selector: "typeLike", format: ["PascalCase"], }, { selector: "variable", format: ["camelCase", "UPPER_CASE"], leadingUnderscore: "allow", trailingUnderscore: "allow", }, { selector: "interface", format: ["PascalCase"], custom: { match: false, regex: "^I[A-Z]" }, },]Related rules
Section titled “Related rules” prefer-pascal-case-enums Keeps enum names in PascalCase
no-shorthand-names Bans shorthand names that are hard to read