@craftworks/eslint-config-angular
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@craftworks/eslint-config-angular

NPM version Downloads

An ESLint config optimized for Angular.

Contains the configs of

and applies a custom config.

Following configurations are provided

Note that this setup is not set up for **/*.js files.

Installation

npm install @craftworks/eslint-config-angular --save-dev

Check for necessary peer dependencies.

Usage

eslint.config.mjs

import eslintConfigAngular from '@craftworks/eslint-config-angular';

export default [
  ...eslintConfigAngular,
  {
    files: ['**/*.ts'],
    languageOptions: {
      parserOptions: {
        project: ['./tsconfig.lint.json'],
      },
    },
    rules: {
      '@angular-eslint/component-selector': [
        'error',
        {
          type: ['element', 'attribute'],
          prefix: '[PREFIX]',
          style: 'kebab-case',
        },
      ],
      '@angular-eslint/directive-selector': [
        'error',
        {
          type: ['element', 'attribute'],
          prefix: '[PREFIX]',
          style: 'camelCase',
        },
      ],
      // Optional TypeScript rule overwrites
    },
  },
  {
    files: ['**/*.html'],
    rules: {
      // Optional HTML rule overwrites
    },
  },
];

Create a tsconfig.lint.json for your Angular project that defines all the files that should be linted.

{
  "extends": "./tsconfig.json",
  "include": ["src"]
}

Note that only flat config is supported.

Migration from @craftworks/tslint-config-angular

Allows easier migration by disabling a set of rules that would make migration more difficult. It is recommended to avoid this config in the long run, as it won't be actively maintained.

eslint.config.mjs

import eslintConfigAngular from '@craftworks/eslint-config-angular';
import eslintConfigAngularUnsafeTyping from '@craftworks/eslint-config-angular/unsafe-typing';
import eslintConfigAngularTslintConfigAngularBridge from '@craftworks/eslint-config-angular/tslint-config-angular-bridge';

export default [
  ...eslintConfigAngular,
  ...eslintConfigAngularUnsafeTyping,
  ...eslintConfigAngularTslintConfigAngularBridge,
  {
    files: ['**/*.ts'],
    languageOptions: {
      parserOptions: {
        project: ['./tsconfig.lint.json'],
      },
    },
    rules: {
      // Optional TypeScript rule overwrites
    },
  },
  {
    files: ['**/*.html'],
    rules: {
      // Optional HTML rule overwrites
    },
  },
];

Peer Dependencies

  • eslint: ^9.0.0
  • angular-eslint: >=18.0.0
  • @eslint/js: ^9.0.0
  • typescript: ^4.8.4 || ^5.0.0
  • typescript-eslint: ^8.0.0

The version of angular-eslint must match the version of Angular you are using.

The minimal node version is 18.18.0.

See package.json for more details

Change Log

See CHANGELOG.md

License

MIT

Package Sidebar

Install

npm i @craftworks/eslint-config-angular

Weekly Downloads

325

Version

2.0.0

License

MIT

Unpacked Size

28.6 kB

Total Files

18

Last publish

Collaborators

  • zualexander
  • phi_spindler