1.3.1 • Published 6 months ago

@kiforks/eslint-config v1.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@kiforks/eslint-config

npm version Build Status Downloads per month

Created by Kifor Kostiantyn

This is the standard configuration file for ESLint from Kifor Kostiantyn.

Use it as is or as a basis for your own configuration.

Installation

You first need to install your published configuration, for example:

npm install --save-dev eslint @kiforks/eslint-config
yarn add --dev eslint @kiforks/eslint-config
pnpm add --save-dev eslint @kiforks/eslint-config
bun add --dev eslint @kiforks/eslint-config

Basic Configuration

In the root of the project, create a eslint.config.js file and add @kiforks/eslint-config to the extends field.

eslint.config.js

import kiforAngularTemplate from '@kiforks/eslint-config/angular-template.js';
import kiforAngularTypescript from '@kiforks/eslint-config/angular-typescript.js';
import kiforJavascript from '@kiforks/eslint-config/javascript.js';
import kiforJasmine from '@kiforks/eslint-config/tests-jasmine.js';
import kiforJest from '@kiforks/eslint-config/tests-jest.js';
import kiforTests from '@kiforks/eslint-config/tests.js';
import kiforTypescript from '@kiforks/eslint-config/typescript.js';

/** @type { import("eslint").Linter.Config[] } */
export default [
	...kiforTypescript.map(config => ({
		...config,
		languageOptions: {
			...config.languageOptions,
			parserOptions: {
				project: ['./tsconfig.base.json'],
				tsconfigRootDir: import.meta.dirname,
			},
		},
	})),
	...kiforJavascript,
	...kiforAngularTemplate,
	...kiforAngularTypescript,
	...kiforTests,
	...kiforJasmine,
	...kiforJest,
];

Configure Extension

You can override existing rules or add new ones by using the rules field in your ESLint configuration.

eslint.config.js

export default [
	...kiforTypescript,
	{
		rules: {
			'@typescript-eslint/no-explicit-any': 'off',
			'jest/prefer-expect-assertions': 'off',
		},
	},
];

Disable Recommend Configuration

The disable-recommend configuration is designed to disable certain ESLint rules that enforce stricter coding practices, giving developers more flexibility when needed. This can be useful in scenarios where specific recommendations are not suitable for your project's requirements.

Purpose

  • Flexibility: Allows you to bypass overly strict linting rules.
  • Customization: Focus on rules that align with your project's coding style.
  • Ease of Development: Reduces friction when rapid prototyping or working with legacy code.

Usage

In your eslint.config.js, extend the disable-recommend configuration:

import kiforDisableRecommend from '@kiforks/eslint-config/disable-recommend.js';

/** @type { import("eslint").Linter.Config[] } */
export default [...kiforDisableRecommend];

Feature-Sliced Design Configuration

The feature-sliced-design.js configuration enforces architectural boundaries based on the Feature-Sliced Design methodology. It restricts cross-layer imports to encourage modularity, scalability, and maintainability in frontend applications.

Key Features

  • Enforces layer isolation: shared, entities, features, widgets, pages, processes, app
  • Restricts disallowed import paths across layers
  • Works with .ts, .tsx, .js, .jsx files

Usage

import kiforFeatureSliced from '@kiforks/eslint-config/feature-sliced-design.js';

export default [...kiforFeatureSliced];

Usage in VSCode

  1. Install ESLint and the configuration.
  2. Open VSCode.
  3. Install the ESLint plugin.
  4. Use it.

Scripts

Add these scripts to your package.json for easier linting and formatting:

"scripts": {
  "lint": "npx eslint '**/*.{ts,html,js}' --quiet",
  "lint:fix": "npx eslint '**/*.{ts,html,js}' --quiet --fix"
}

License

MIT