feat: ✨ add eslint's max-len rule
This commit is contained in:
@@ -2,7 +2,7 @@ root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
6
configs/js/src/@types/eslint-plugin-i.d.ts
vendored
6
configs/js/src/@types/eslint-plugin-i.d.ts
vendored
@@ -5,9 +5,9 @@ import type { ESLint, Linter } from 'eslint';
|
||||
* @summary ESLint plugin with rules that help validate proper imports.
|
||||
*
|
||||
* ---
|
||||
* **Note:** Types in this project where overridden to be compatible with ESLint new flat
|
||||
* config types. ESlint already has backwards compatibility for plugins not created in the
|
||||
* new flat config.
|
||||
* **Note:** Types in this project where overridden to be compatible with
|
||||
* ESLint new flat config types. ESlint already has backwards compatibility
|
||||
* for plugins not created in the new flat config.
|
||||
* @see {@link https://www.npmjs.com/package/eslint-plugin-import npm package}
|
||||
*/
|
||||
declare module 'eslint-plugin-i' {
|
||||
|
||||
@@ -4,9 +4,9 @@ import type { ESLint } from 'eslint';
|
||||
* @summary JSDoc specific linting rules for ESLint.
|
||||
*
|
||||
* ---
|
||||
* **Note:** Types in this project where overridden to be compatible with ESLint new flat
|
||||
* config types. ESlint already has backwards compatibility for plugins not created in the
|
||||
* new flat config.
|
||||
* **Note:** Types in this project where overridden to be compatible with
|
||||
* ESLint new flat config types. ESlint already has backwards compatibility
|
||||
* for plugins not created in the new flat config.
|
||||
* @see {@link https://www.npmjs.org/package/eslint-plugin-jsdoc npm package}
|
||||
*/
|
||||
declare module 'eslint-plugin-jsdoc' {
|
||||
|
||||
16
configs/js/src/@types/typescript-eslint.d.ts
vendored
16
configs/js/src/@types/typescript-eslint.d.ts
vendored
@@ -4,9 +4,9 @@ import type { ESLint, Linter } from 'eslint';
|
||||
* @summary An ESLint plugin which provides lint rules for TypeScript codebases.
|
||||
*
|
||||
* ---
|
||||
* **Note:** Types in this project where overridden to be compatible with ESLint new flat
|
||||
* config types. ESlint already has backwards compatibility for plugins not created in the
|
||||
* new flat config.
|
||||
* **Note:** Types in this project where overridden to be compatible with ESLint
|
||||
* new flat config types. ESlint already has backwards compatibility for plugins
|
||||
* not created in the new flat config.
|
||||
* @see {@link https://www.npmjs.com/package/@typescript-eslint/eslint-plugin npm package}
|
||||
*/
|
||||
declare module '@typescript-eslint/eslint-plugin' {
|
||||
@@ -31,13 +31,13 @@ declare module '@typescript-eslint/eslint-plugin' {
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary An ESLint parser which leverages TypeScript ESTree to allow for ESLint
|
||||
* to lint TypeScript source code.
|
||||
* @summary An ESLint parser which leverages TypeScript ESTree to
|
||||
* allow for ESLint to lint TypeScript source code.
|
||||
*
|
||||
* ---
|
||||
* **Note:** Types in this project where overridden to be compatible with ESLint new flat
|
||||
* config types. ESlint already has backwards compatibility for parsers not created in the
|
||||
* new flat config.
|
||||
* **Note:** Types in this project where overridden to be compatible
|
||||
* with ESLint new flat config types. ESlint already has backwards
|
||||
* compatibility for parsers not created in the new flat config.
|
||||
* @see {@link https://www.npmjs.com/package/@typescript-eslint/parser npm package}
|
||||
*/
|
||||
declare module '@typescript-eslint/parser' {
|
||||
|
||||
@@ -8,8 +8,9 @@ import importPlugin from 'eslint-plugin-i';
|
||||
import process from 'node:process';
|
||||
|
||||
/**
|
||||
* This config adds necessary plugins and configuration for ESLint to use in the other configs
|
||||
* **This should always be in the top of the configuration array**.
|
||||
* This config adds necessary plugins and configuration for ESLint
|
||||
* to use in the other configs **This should always be in the top
|
||||
* of the configuration array**.
|
||||
* @type {import('eslint').Linter.FlatConfig}
|
||||
*/
|
||||
const config = {
|
||||
|
||||
@@ -36,7 +36,9 @@ const recommended = {
|
||||
|
||||
...{}, // Plugin: @typescript-eslint/eslint-plugin
|
||||
'@typescript-eslint/block-spacing': ['error', 'always'],
|
||||
'@typescript-eslint/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
||||
'@typescript-eslint/brace-style': ['error', 'stroustrup', {
|
||||
allowSingleLine: true,
|
||||
}],
|
||||
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
|
||||
'@typescript-eslint/comma-spacing': 'error',
|
||||
'@typescript-eslint/func-call-spacing': 'error',
|
||||
@@ -46,7 +48,10 @@ const recommended = {
|
||||
parameters: 1 },
|
||||
FunctionExpression: { body: 1,
|
||||
parameters: 1 },
|
||||
ImportDeclaration: 1, MemberExpression: 1, ObjectExpression: 1, SwitchCase: 1,
|
||||
ImportDeclaration: 1,
|
||||
MemberExpression: 1,
|
||||
ObjectExpression: 1,
|
||||
SwitchCase: 1,
|
||||
VariableDeclarator: 1,
|
||||
flatTernaryExpressions: false,
|
||||
ignoreComments: false, ignoredNodes: [
|
||||
@@ -69,12 +74,20 @@ const recommended = {
|
||||
'JSXSpreadChild',
|
||||
'TSTypeParameterInstantiation',
|
||||
'FunctionExpression > .params[decorators.length > 0]',
|
||||
// eslint-disable-next-line max-len
|
||||
'FunctionExpression > .params > :matches(Decorator, :not(:first-child))',
|
||||
// eslint-disable-next-line max-len
|
||||
'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key',
|
||||
], offsetTernaryExpressions: true, outerIIFEBody: 1,
|
||||
}],
|
||||
'@typescript-eslint/key-spacing': ['error', { afterColon: true, beforeColon: false }],
|
||||
'@typescript-eslint/keyword-spacing': ['error', { after: true, before: true }],
|
||||
'@typescript-eslint/key-spacing': ['error', {
|
||||
afterColon: true,
|
||||
beforeColon: false,
|
||||
}],
|
||||
'@typescript-eslint/keyword-spacing': ['error', {
|
||||
after: true,
|
||||
before: true,
|
||||
}],
|
||||
'@typescript-eslint/lines-between-class-members': ['error'],
|
||||
'@typescript-eslint/member-delimiter-style': ['error', {
|
||||
multiline: { delimiter: 'comma', requireLast: true },
|
||||
@@ -91,7 +104,10 @@ const recommended = {
|
||||
named: 'never',
|
||||
}],
|
||||
'@typescript-eslint/space-infix-ops': 'error',
|
||||
'@typescript-eslint/type-annotation-spacing': ['error', { after: true, before: false }],
|
||||
'@typescript-eslint/type-annotation-spacing': ['error', {
|
||||
after: true,
|
||||
before: false,
|
||||
}],
|
||||
'block-spacing': 'off',
|
||||
'brace-style': 'off',
|
||||
'comma-dangle': 'off',
|
||||
@@ -118,7 +134,11 @@ const recommended = {
|
||||
...perfectionistPlugin.configs['recommended-natural'].rules,
|
||||
|
||||
'perfectionist/sort-exports': ['error', { type: 'line-length' }],
|
||||
'perfectionist/sort-imports': ['error', { order: 'desc', type: 'line-length' }],
|
||||
'perfectionist/sort-imports': ['error', {
|
||||
order: 'desc',
|
||||
type: 'line-length',
|
||||
}],
|
||||
'perfectionist/sort-interfaces': ['error', { type: 'natural' }],
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ const recommended = {
|
||||
files: [...tsFiles, ...jsFiles],
|
||||
rules: {
|
||||
'camelcase': 'error',
|
||||
'max-len': ['error', { code: 80, comments: 100, ignoreUrls: true }],
|
||||
'no-case-declarations': 'error',
|
||||
'no-confusing-arrow': 'error',
|
||||
'no-console': 'error',
|
||||
@@ -34,7 +35,10 @@ const recommended = {
|
||||
'require-yield': 'error',
|
||||
|
||||
...{}, // Plugin: @typescript-eslint/eslint-plugin
|
||||
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
||||
/*
|
||||
* '@typescript-eslint/adjacent-overload-signatures': 'error',
|
||||
* Incompatible with perfectionist/sort-interfaces
|
||||
*/
|
||||
'@typescript-eslint/array-type': 'error',
|
||||
'@typescript-eslint/await-thenable': 'error',
|
||||
'@typescript-eslint/ban-ts-comment': 'error',
|
||||
@@ -42,6 +46,7 @@ const recommended = {
|
||||
'@typescript-eslint/ban-types': 'error',
|
||||
'@typescript-eslint/class-literal-property-style': 'error',
|
||||
'@typescript-eslint/consistent-generic-constructors': 'error',
|
||||
// eslint-disable-next-line max-len
|
||||
'@typescript-eslint/consistent-indexed-object-style': ['error', 'index-signature'],
|
||||
'@typescript-eslint/consistent-type-assertions': 'error',
|
||||
'@typescript-eslint/consistent-type-definitions': 'error',
|
||||
@@ -108,7 +113,9 @@ const recommended = {
|
||||
'unicorn/empty-brace-spaces': 'error',
|
||||
'unicorn/error-message': 'error',
|
||||
'unicorn/escape-case': 'error',
|
||||
'unicorn/expiring-todo-comments': ['error', { allowWarningComments: false }],
|
||||
'unicorn/expiring-todo-comments': ['error', {
|
||||
allowWarningComments: false,
|
||||
}],
|
||||
'unicorn/explicit-length-check': 'error',
|
||||
'unicorn/new-for-builtins': 'error',
|
||||
'unicorn/no-abusive-eslint-disable': 'error',
|
||||
@@ -175,13 +182,17 @@ const recommended = {
|
||||
'unicorn/prefer-reflect-apply': 'error',
|
||||
'unicorn/prefer-regexp-test': 'error',
|
||||
'unicorn/prefer-set-has': 'error',
|
||||
'unicorn/prefer-set-size': 'error', // TODO [>=1.0.0]: Should this be on a "performance" preset?
|
||||
'unicorn/prefer-spread': 'error', // TODO [>=1.0.0]: Should this be disabled on a "performance" preset?
|
||||
// TODO [>=1.0.0]: Should this be on a "performance" preset?
|
||||
'unicorn/prefer-set-size': 'error',
|
||||
// TODO [>=1.0.0]: Should this be disabled on a "performance" preset?
|
||||
'unicorn/prefer-spread': 'error',
|
||||
'unicorn/prefer-string-replace-all': 'error',
|
||||
'unicorn/prefer-string-slice': 'error',
|
||||
'unicorn/prefer-string-starts-ends-with': 'error',
|
||||
'unicorn/prefer-string-trim-start-end': 'error',
|
||||
'unicorn/prefer-switch': ['error', { emptyDefaultCase: 'do-nothing-comment' }],
|
||||
'unicorn/prefer-switch': ['error', {
|
||||
emptyDefaultCase: 'do-nothing-comment',
|
||||
}],
|
||||
'unicorn/prefer-ternary': 'error',
|
||||
'unicorn/prefer-top-level-await': 'error',
|
||||
'unicorn/prefer-type-error': 'error',
|
||||
@@ -260,11 +271,17 @@ const strict = {
|
||||
'func-names': ['error', 'as-needed'],
|
||||
'func-style': ['error', 'declaration'],
|
||||
'grouped-accessor-pairs': ['error', 'setBeforeGet'],
|
||||
'logical-assignment-operators': ['error', 'always', { enforceForIfStatements: true }],
|
||||
'logical-assignment-operators': ['error', 'always', {
|
||||
enforceForIfStatements: true,
|
||||
}],
|
||||
'max-classes-per-file': ['error', 1],
|
||||
'max-depth': ['error', 4],
|
||||
'max-lines': ['error', 500],
|
||||
'max-lines-per-function': ['error', { max: 60, skipBlankLines: true, skipComments: true }],
|
||||
'max-lines-per-function': ['error', {
|
||||
max: 60,
|
||||
skipBlankLines: true,
|
||||
skipComments: true,
|
||||
}],
|
||||
'max-nested-callbacks': ['error', 10],
|
||||
'max-params': ['error', 4],
|
||||
'max-statements': ['error', 10],
|
||||
@@ -320,8 +337,14 @@ const strict = {
|
||||
|
||||
...{}, // Plugin: @typescript-eslint/eslint-plugin
|
||||
'@typescript-eslint/class-methods-use-this': 'error',
|
||||
'@typescript-eslint/consistent-type-exports': ['error', { fixMixedExportsWithInlineTypeSpecifier: false }],
|
||||
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: true, fixStyle: 'separate-type-imports', prefer: 'type-imports' }],
|
||||
'@typescript-eslint/consistent-type-exports': ['error', {
|
||||
fixMixedExportsWithInlineTypeSpecifier: false,
|
||||
}],
|
||||
'@typescript-eslint/consistent-type-imports': ['error', {
|
||||
disallowTypeAnnotations: true,
|
||||
fixStyle: 'separate-type-imports',
|
||||
prefer: 'type-imports',
|
||||
}],
|
||||
'@typescript-eslint/default-param-last': 'error',
|
||||
'@typescript-eslint/dot-notation': 'error',
|
||||
'@typescript-eslint/method-signature-style': ['error', 'method'],
|
||||
@@ -376,7 +399,10 @@ const strict = {
|
||||
|
||||
...{}, // Plugin: eslint-plugin-import
|
||||
'import/extensions': ['error', 'always', { ignorePackages: true }],
|
||||
'import/max-dependencies': ['error', { ignoreTypeImports: true, max: 10 }],
|
||||
'import/max-dependencies': ['error', {
|
||||
ignoreTypeImports: true,
|
||||
max: 10,
|
||||
}],
|
||||
'import/no-absolute-path': 'error',
|
||||
'import/no-anonymous-default-export': 'error',
|
||||
'import/no-cycle': 'error',
|
||||
@@ -385,7 +411,9 @@ const strict = {
|
||||
'import/no-named-default': 'error',
|
||||
'import/no-relative-packages': 'error',
|
||||
'import/no-relative-parent-imports': 'error',
|
||||
'import/no-unassigned-import': ['error', { allow: ['**/*.css', '**/*.scss', '**/*.less'] }],
|
||||
'import/no-unassigned-import': ['error', {
|
||||
allow: ['**/*.css', '**/*.scss', '**/*.less'],
|
||||
}],
|
||||
'import/prefer-default-export': 'error',
|
||||
'import/unambiguous': 'error',
|
||||
|
||||
|
||||
Reference in New Issue
Block a user