Here is the problem:
When I run fixer then this
export class Test {
public declare id: number;
}
transforms into this
export class Test {
declare public id: number;
}
It is a problem for me because I'm new in the project and the old codebase have a lot of places with this order of modifiers public declare
and when I run automatic eslint/prettier
fixer it reorders them. But the older developer strictly wants me to keep old style, and his argument is:
access modifiers should come first
- How can I turn off this rule?
- Should I try to turn off this rule?
Is there a source where it is strictly declared in which order should I write modifiers of class members, so I will be able to argue with his argument :)
Maybe it is a bug of prettier
like this one, and I need to report a new one
.prettierrc.json
{
"trailingComma": "all",
"tabWidth": 4,
"printWidth": 120,
"semi": true,
"bracketSpacing": true,
"endOfLine": "lf",
"arrowParens": "avoid",
"overrides": [
{
"files": "*.yml",
"options": {
"tabWidth": 2
}
}
]
}
.eslintrc.json
{
"root": true,
"env": {
"browser": true,
"es2020": true
},
"ignorePatterns": ["node_modules", "build", "dist", "*.config.js"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier", "unused-imports"],
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier"
],
"rules": {
"no-console": [
"warn",
{
"allow": ["warn", "error"]
}
],
"prettier/prettier": "warn",
"unused-imports/no-unused-imports": "warn",
"unused-imports/no-unused-vars": [
"warn",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
],
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"types": ["boolean"],
"format": ["PascalCase"],
"prefix": ["is", "has", "have", "should", "show", "can", "did", "will"]
}
],
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.name='Boolean']",
"message": "Use '!!' instead of 'Boolean()' for type coercion."
}
]
}
}
Name | Version |
---|---|
WebStorm | 2024.3.2.1 |
Typescript | 5.3.3 |
@typescript-eslint/eslint-plugin | 6.7.4 |
eslint | 8.26.0 |
prettier | 3.5.3 |
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744335096a4569076.html
评论列表(0条)