mirror of
https://github.com/sasjs/lint.git
synced 2026-01-15 08:10:05 +00:00
fix(lint): ignore indentation multiple when set to zero
This commit is contained in:
@@ -14,6 +14,12 @@ describe('indentationMultiple', () => {
|
||||
expect(indentationMultiple.test(line, 1, config)).toEqual([])
|
||||
})
|
||||
|
||||
it('should ignore indentation when the multiple is set to 0', () => {
|
||||
const line = " %put 'hello';"
|
||||
const config = new LintConfig({ indentationMultiple: 0 })
|
||||
expect(indentationMultiple.test(line, 1, config)).toEqual([])
|
||||
})
|
||||
|
||||
it('should return an empty array when the line is not indented', () => {
|
||||
const line = "%put 'hello';"
|
||||
const config = new LintConfig({ indentationMultiple: 2 })
|
||||
|
||||
@@ -9,9 +9,13 @@ const message = 'Line has incorrect indentation'
|
||||
const test = (value: string, lineNumber: number, config?: LintConfig) => {
|
||||
if (!value.startsWith(' ')) return []
|
||||
|
||||
const indentationMultiple = config?.indentationMultiple || 2
|
||||
const indentationMultiple = isNaN(config?.indentationMultiple as number)
|
||||
? 2
|
||||
: config?.indentationMultiple
|
||||
|
||||
if (indentationMultiple === 0) return []
|
||||
const numberOfSpaces = value.search(/\S|$/)
|
||||
if (numberOfSpaces % indentationMultiple === 0) return []
|
||||
if (numberOfSpaces % indentationMultiple! === 0) return []
|
||||
return [
|
||||
{
|
||||
message: `${message} - ${numberOfSpaces} ${
|
||||
|
||||
Reference in New Issue
Block a user