View on GitHub

eslint-plugin-budapestian

Lint rules for Budapestian notation

Enforce local variables to adhere to a pattern (local-variable-pattern)

This rule enforces that local variables (let, const) start with a l and are pascal cased.

🔧 When possible, the --fix option on the command line renames the variables to the correct pattern.

Rule Details

Examples of incorrect code for this rule:

const f = () => {
  let localVariable = 456;
};

const f = () => {
  const YetAnotherOne = 789;
};

function f() {
  let variable, another_one, yet_another;
}

Examples of correct code for this rule:

const f = (pThing) => {
  let lLocalVariable = 456;
};

const f = () => {
  const lYetAnotherOne = 789;
};

function f() {
  let lVariable, lAnotherOne, lYetAnother;
}

Options

exceptions

Type: array

If you want to allow some variable names to not adhere to the rule, you can specify these. E.g. if you’re doing a lot of calculations in 3 dimensions it might make sense to have the variables x, y, and z over anything else for readability purposes.

"budapestian/local-variable-pattern": [
  "error",
  { "exceptions": ["x", "y", "z"] }
]

When Not To Use It