Итак, поскольку Angular 11 не поддерживает TSLint, я переключился на ESLint (пока не слишком доволен этим).
Сейчас у меня есть неприятная проблема с интервалом, которую я пытаюсь решить в конфигурации .eslintrc.js.
Возьмите эти строки кода (это то, что у меня есть и что я хочу сохранить):
readonly DELETE_DIALOG_MESSAGE = "This message doesn't exceed the width limit & is 1 line.";
readonly RETURN_TO_DRAFT_MESSAGE =
"This message is supper long, like really loooong. So it exceeds my width limit and is dropped a line.";
Вы видите этот отступ после выпавшей строки для более длинного сообщения? Я хочу сохранить это. Но ESLint его удаляет.
ESLint делает это так:
readonly DELETE_DIALOG_MESSAGE = "This message doesn't exceed the width limit & is 1 line.";
readonly RETURN_TO_DRAFT_MESSAGE =
"This message is supper long, like really loooong. So it exceeds my width limit and is dropped a line.";
Видеть? Без отступа. Это еще более неприятно, потому что (я использую более красивый для форматирования) мой модуль форматирования добавит пространство обратно.
Я пытаюсь найти правило переключения / конфигурация, добавляющая отступ, когда строка удаляется, когда она превышает предел ширины.
Любая помощь будет оценена!
Мое правило отступа: "@typescript-eslint/indent": ["error", 2],
А вот и весь мой конфигурационный файл .eslintrc.js:
module.exports = {
env: {
browser: true,
es6: true,
node: true
},
extends: ["prettier", "prettier/@typescript-eslint"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module"
},
plugins: [
"eslint-plugin-import",
"eslint-plugin-jsdoc",
"@angular-eslint/eslint-plugin",
// "eslint-plugin-react",
"@typescript-eslint",
"@typescript-eslint/tslint"
],
rules: {
"@angular-eslint/component-class-suffix": "error",
"@angular-eslint/directive-class-suffix": "error",
"@angular-eslint/no-host-metadata-property": "error",
"@angular-eslint/no-input-rename": "error",
"@angular-eslint/no-inputs-metadata-property": "error",
"@angular-eslint/no-output-on-prefix": "error",
"@angular-eslint/no-output-rename": "error",
"@angular-eslint/no-outputs-metadata-property": "error",
"@angular-eslint/use-lifecycle-interface": "error",
"@angular-eslint/use-pipe-transform-interface": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
accessibility: "explicit"
}
],
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/member-delimiter-style": [
"error",
{
multiline: {
delimiter: "semi",
requireLast: true
},
singleline: {
delimiter: "semi",
requireLast: false
}
}
],
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-inferrable-types": [
"error",
{
ignoreParameters: true
}
],
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/quotes": "off",
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"arrow-body-style": ["off"],
"arrow-parens": ["off", "always"],
"brace-style": ["error", "1tbs"],
"comma-dangle": "off",
"constructor-super": "error",
curly: "error",
"eol-last": "error",
eqeqeq: ["error", "smart"],
"guard-for-in": "error",
"id-blacklist": "off",
"id-match": "off",
"import/no-deprecated": "warn",
"jsdoc/no-types": "error",
"linebreak-style": "off",
"max-len": [
"error",
{
code: 140
}
],
"new-parens": "off",
"newline-per-chained-call": "off",
"no-bitwise": "error",
"no-caller": "error",
"no-console": [
"error",
{
allow: [
"log",
"dirxml",
"warn",
"error",
"dir",
"timeLog",
"assert",
"clear",
"count",
"countReset",
"group",
"groupCollapsed",
"groupEnd",
"table",
"Console",
"markTimeline",
"profile",
"profileEnd",
"timeline",
"timelineEnd",
"timeStamp",
"context"
]
}
],
"no-debugger": "error",
"no-empty": "off",
"no-eval": "error",
"no-extra-semi": "off",
"no-fallthrough": "error",
"no-irregular-whitespace": "off",
"no-multiple-empty-lines": "off",
"no-new-wrappers": "error",
"no-restricted-imports": ["error", "rxjs/Rx"],
"no-shadow": [
"off",
{
hoist: "all"
}
],
"@typescript-eslint/no-shadow": ["error"],
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "off",
"no-unused-labels": "error",
"no-var": "error",
"prefer-const": "error",
"quote-props": "off",
radix: "error",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-wrap-multilines": "off",
"space-before-function-paren": "off",
"space-before-blocks": "error",
"space-in-parens": ["off", "never"],
"spaced-comment": [
"error",
"always",
{
markers: ["/"]
}
],
"@typescript-eslint/tslint/config": [
"error",
{
rules: {
"import-spacing": true,
whitespace: [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"]
}
}
]
}
};