eslint-plugin-decorator-position

raw JSON →
6.1.0 verified Sat Apr 25 auth: no javascript

ESLint plugin that enforces consistent positioning of decorators (e.g., same line vs. new line before the target). Current stable version is 6.1.0 (released 2026-04-16) with minor updates adding ESLint 10 support and bundled TypeScript typings. Maintained by NullVoxPopuli, with frequent releases (~monthly) and support for ESLint 7, 8, 9, and 10. Key differentiator: provides both flat configs and legacy configs tailored for Ember projects, integrates with Prettier, and is the only dedicated decorator-position linter. Requires @babel/eslint-parser as a parser.

error Error [ERR_REQUIRE_ESM]: require() of ES Module .../eslint-plugin-decorator-position/index.js from ... not supported.
cause Using CommonJS require() on the ESM-only v6+ entry point.
fix
Use import() or switch to ESM. For legacy configs, use 'eslint-plugin-decorator-position/config-legacy/ember' which is still CJS.
error ESLint configuration error: Cannot find module 'eslint-plugin-decorator-position/config/recommended'
cause Importing with .js extension or wrong path for flat config.
fix
Use 'eslint-plugin-decorator-position/config/recommended' (no .js). Ensure package is installed.
error Parsing error: Unexpected character '@'
cause Parser is not configured to handle decorators (missing @babel/eslint-parser or plugin).
fix
Set parser to '@babel/eslint-parser' and add '@babel/plugin-proposal-decorators' with legacy: true in parserOptions.
error Rule "decorator-position/decorator-position" was not found.
cause Plugin not loaded or misconfigured in legacy eslintrc format.
fix
Ensure plugins array includes 'decorator-position' and rules are prefixed correctly. For flat config, add the plugin object.
breaking ESLint 6 compatibility dropped. Plugin v6 requires ESLint >=7.
fix Upgrade ESLint to version 7 or later (8/9/10 supported).
breaking Node.js <12 support dropped. Plugin v3+ requires Node >=12.
fix Upgrade Node.js to version 12 or higher.
breaking ESM-only plugin exports starting in v6.0.0. CommonJS require() fails with 'ERR_REQUIRE_ESM'.
fix Use dynamic import() in CommonJS, or switch to ESM. Alternatively, import legacy configs from 'eslint-plugin-decorator-position/config-legacy/ember' which remain CJS.
deprecated Legacy configs (e.g., 'plugin:decorator-position/ember') are deprecated in favor of flat configs.
fix Migrate to flat config using 'eslint-plugin-decorator-position/config/recommended'.
gotcha When using with Prettier, printWidth must be explicitly set in the decorator-position rule if not using a .prettierrc.js file; otherwise lint results may conflict with prettier/prettier rule.
fix Set 'decorator-position/decorator-position': ['error', { printWidth: 100 }] and matching printWidth in prettier/prettier rule.
gotcha The package always requires '@babel/eslint-parser' as parser; '@typescript-eslint/parser' is only partially supported and may cause false positives for TypeScript decorators.
fix Use @babel/eslint-parser with @babel/plugin-proposal-decorators. For TypeScript, ensure babelOptions are set accordingly.
npm install eslint-plugin-decorator-position
yarn add eslint-plugin-decorator-position
pnpm add eslint-plugin-decorator-position

Flat config setup with recommended preset, Babel parser, and custom printWidth.

// eslint.config.js
import plugin from 'eslint-plugin-decorator-position';
import recommended from 'eslint-plugin-decorator-position/config/recommended';
import babelParser from '@babel/eslint-parser';

export default [
  ...recommended,
  {
    languageOptions: {
      parser: babelParser,
      parserOptions: {
        requireConfigFile: false,
        babelOptions: {
          plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
        },
      },
    },
    rules: {
      'decorator-position/decorator-position': ['error', { printWidth: 100 }],
    },
  },
];