functional/no-classes

February 22, 2026 Β· View on GitHub

πŸ“ Disallow classes.

πŸ’ΌπŸš« This rule is enabled in the following configs: badge-noOtherParadigms noOtherParadigms, βœ… recommended, πŸ”’ strict. This rule is disabled in the β˜‘οΈ lite config.

Disallow use of the class keyword.

Rule Details

❌ Incorrect

/* eslint functional/no-classes: "error" */

class Dog {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }

  get ageInDogYears() {
    return 7 * this.age;
  }
}

const dogA = new Dog("Jasper", 2);

console.log(`${dogA.name} is ${dogA.ageInDogYears} in dog years.`);

βœ… Correct

/* eslint functional/no-classes: "error" */

function getAgeInDogYears(age) {
  return 7 * age;
}

const dogA = {
  name: "Jasper",
  age: 2,
};

console.log(`${dogA.name} is ${getAgeInDogYears(dogA.age)} in dog years.`);

Options

This rule accepts an options object of the following type:

type Options = {
  ignoreIdentifierPattern?: string[] | string;
  ignoreCodePattern?: string[] | string;
};

Default Options

const defaults = {};

ignoreIdentifierPattern

This option takes a RegExp string or an array of RegExp strings. It allows for the ability to ignore violations based on the class's name.

ignoreCodePattern

This option takes a RegExp string or an array of RegExp strings. It allows for the ability to ignore violations based on the code itself.