@hayuno-ag/eslint-config
v1.0.4
Published
ESLint configuration used for projects at Hayuno AG
Downloads
1,364
Readme
@hayuno-ag/eslint-config
This packages offers configurations for ESLint and Prettier which are used for projects at Hayuno AG.
Prerequisites
Install eslint, typescript, @typescript-eslint/parser, eslint-config-prettier, prettier and @hayuno-ag/eslint-config as dev dependencies:
npm install --save-dev @hayuno-ag/eslint-config eslint typescript @typescript-eslint/parser eslint-config-prettier prettierNote: If you're using Next.js, next is already expected to be installed in your project. The plugin is included as a dependency of this package: @next/eslint-plugin-next.
Integration
By setting-up your eslint.config.mjs (example):
import { defineConfig } from 'eslint/config';
import eslintConfig from '@hayuno-ag/eslint-config';
// additional imports
export default defineConfig([
globalIgnores(['**/node_modules', '**/dist', '**/build', 'bin/**', 'package-lock.json']),
...eslintConfig,
{
languageOptions: {
/* your language options */
},
rules: {
/* your override rules */
},
},
// Test-specific rules
{
files: ['tests/**/*.test.tsx', 'tests/**/*.test.ts'],
rules: {
'@hayuno-ag/no-speculative-it': 'warn',
/* your additional rule overrides */
},
},
// Ignore patterns
{
ignores: [
/* your ignore file patterns */
],
},
]);Custom Rules Plugin
This package also offers a custom rules plugin, which can be used to add custom rules to your project.
Currently, there's only one rule: @hayuno-ag/no-speculative-it, defined at rules/no-speculative-it.ts.
Defining additional rules
Taking no-speculative-it.js as template, you can easily define additional rules by just adding another
js-file implementing the rule and storing it at rules/custom. rules/custom/index.js will then automatically
load all rules from this directory and index.mjs will export them as long as jest is installed as
dependency in the consuming project.
By default, all newly-created rules are set to error severity. If you want to change this, you can
simply set the meta.severity property in the rule definition as shown in no-speculative-it.js.
As shown in Integration above, you can change a rule's severity level by adding it to the rules
property of your eslint.config.mjs. If you don't want to override a rule's severity level, you don't have
to add it to the according rules property. It then is executed with its default severity level.
The names of the rules defined in this project are prefixed with @hayuno-ag/. Therefore, no-speculative-it
is referenced by @hayuno-ag/no-speculative-it.
@hayuno-ag/no-speculative-it
This rule is used to prevent speculative it statements and enforces the usage of imperative statements instead.
Example: Instead of it('should restart the universe from the beginning') the imperative statement
it('restarts the universe from the beginning') should be used.
Default severity: error.
Additional information
This package requires the following peer dependencies to be installed in your project:
eslint(>= 9.33.0)typescript(>= 4.0.0)@typescript-eslint/parser(^8.37.0)eslint-config-prettier(^10.1.8)prettier(^3.6.2)jest(^30.2.0) - only required if you want to use the Jest-related rules
All ESLint plugins (such as eslint-plugin-react, eslint-plugin-react-hooks, eslint-plugin-jsx-a11y,
etc.) are included as regular dependencies in this package, so you don't need to install them separately.
