Skip to content

Commit

Permalink
feat: add indent example
Browse files Browse the repository at this point in the history
  • Loading branch information
izayl committed Sep 11, 2022
1 parent df3be96 commit 5e46b37
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/tough-seahorses-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@izayl/eslint-config-basic": patch
"@izayl/eslint-config-ts": patch
---

feat: add indent example
12 changes: 12 additions & 0 deletions packages/basic/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,15 @@ const objArr = [
]

const fn = async () => { }

const indentCase = (input) => {
const obj = input > 0
? {
type: 'positive',
value: input,
}
: {
type: 'negative',
value: input,
}
}
4 changes: 4 additions & 0 deletions packages/basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ module.exports = {
'comma-dangle': ['error', 'always-multiline'],
'array-element-newline': ['error', 'consistent'],
'array-bracket-spacing': ['error', 'never'],
indent: ['error', 2, {
SwitchCase: 1,
offsetTernaryExpressions: false,
}],

// function
'space-before-function-paren': 'off',
Expand Down
14 changes: 14 additions & 0 deletions packages/typescript/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,17 @@ const boolValue2 = boolOrNumberOrStringFunction('string')

// example:generic-functions
// example:function-chaining

// example: intent
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const intentCase = (input: number) => {
return input > 0
? {
type: 'positive',
value: input,
}
: {
type: 'negative',
value: input,
}
}
14 changes: 8 additions & 6 deletions packages/typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ module.exports = {
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
rules: {
// off
// @note: must disable the base rule as it can report incorrect errors
intent: "off",
indent: 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-useless-constructor': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',

'@typescript-eslint/indent': [
'error',
2,
{
SwitchCase: 1,
ignoredNodes: ['TSTypeParameterInstantiation'],
offsetTernaryExpressions: false,
},
],
'@typescript-eslint/member-delimiter-style': ['error', {
Expand All @@ -27,10 +34,5 @@ module.exports = {
},
}],

// off
'@typescript-eslint/ban-ts-comment': 'off',
'no-useless-constructor': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
}

0 comments on commit 5e46b37

Please sign in to comment.