close

camelcase

Unreleased

Configuration

rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'camelcase': 'error',
    },
  },
]);

Rule Details

This rule enforces camelcase naming by reporting identifiers with internal underscores. Leading and trailing underscores and all-uppercase constants are allowed.

Examples of incorrect code for this rule:

const favorite_color = "blue";
obj.favorite_color = "blue";

Examples of correct code for this rule:

const favoriteColor = "blue";
const FAVORITE_COLOR = "blue";
const _favoriteColor = "blue";
obj.favorite_color();

Options

  • "properties": "always" (default) checks property declarations and writes; "never" permits underscored property names.
  • "ignoreDestructuring": true permits a destructured binding when it keeps the source property name, while later uses are still checked.
  • "ignoreImports": true permits a named import when its local and exported names are identical, while later uses are still checked.
  • "ignoreGlobals": true skips configured and comment-declared globals; unresolved names are still checked.
  • "allow" accepts exact names or JavaScript regular expression patterns.

Examples of correct code with property checks disabled:

{ "camelcase": ["error", { "properties": "never" }] }
const response = { response_code: 200 };
response.response_code = 201;

Examples of correct code with destructured source names ignored:

{ "camelcase": ["error", { "ignoreDestructuring": true }] }
const { response_code } = response;

Examples of correct code with an allow pattern:

{ "camelcase": ["error", { "allow": ["^UNSAFE_"] }] }
function UNSAFE_componentWillMount() {}

Original Documentation