Skip to content

Commit

Permalink
style: add ts-eslint indent rule
Browse files Browse the repository at this point in the history
Ensures consistent indentation.
[Documentation](https://typescript-eslint.io/rules/indent)

!! This has [known issues](typescript-eslint/typescript-eslint#1824), revert to ESLint's version if necessary.

This rule ensures:
```js
function foo() {
  if (bar) {
    console.log('baz');
  } else {
    console.log('qux');
  }
}

switch(a){
  case "a":
    break;
  case "b":
    break;
}
```

Instead of allowing:
```js
function foo() {
 if (bar) {
console.log('baz');
} else {
     console.log('qux');
 }
}

switch(a){
case "a":
    break;
case "b":
    break;
}
```
  • Loading branch information
devonzara committed Apr 2, 2023
1 parent 02898f1 commit 2406322
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .eslintrc.js
Expand Up @@ -13,7 +13,18 @@ module.exports = {
},
rules: {
// Basic rules
indent: ['error', 2, { SwitchCase: 1 }],
// `ts-lint: indent` has known issues, we can remove if it becomes a problem...
// https://github.com/typescript-eslint/typescript-eslint/issues/1824
indent: 'off',
'@typescript-eslint/indent': ['error', 2, {
SwitchCase: 1,
flatTernaryExpressions: false,
ignoredNodes: [
'PropertyDefinition[decorators]',
'TSUnionType',
'FunctionExpression[params]:has(Identifier[decorators])',
],
}],
'max-len': ['warn', 120],
'prefer-const': 'error',
semi: ['error', 'always'],
Expand Down

0 comments on commit 2406322

Please sign in to comment.