1
0
mirror of https://github.com/sasjs/lint.git synced 2026-01-10 05:50:05 +00:00

Revert "feat(*): add line endings rule, add automatic formatting for fixable violations"

This reverts commit 33a57c3163.
This commit is contained in:
Krishna Acondy
2021-04-19 20:46:38 +01:00
parent 0c22ade942
commit eb5a1bbbcb
32 changed files with 318 additions and 930 deletions

View File

@@ -1,4 +0,0 @@
export enum LineEndings {
LF = 'lf',
CRLF = 'crlf'
}

View File

@@ -1,4 +1,3 @@
import { LineEndings } from './LineEndings'
import { LintConfig } from './LintConfig'
import { LintRuleType } from './LintRuleType'
@@ -109,33 +108,6 @@ describe('LintConfig', () => {
expect(config.indentationMultiple).toEqual(0)
})
it('should create an instance with the line endings set to LF', () => {
const config = new LintConfig({ lineEndings: 'lf' })
expect(config).toBeTruthy()
expect(config.lineEndings).toEqual(LineEndings.LF)
})
it('should create an instance with the line endings set to CRLF', () => {
const config = new LintConfig({ lineEndings: 'crlf' })
expect(config).toBeTruthy()
expect(config.lineEndings).toEqual(LineEndings.CRLF)
})
it('should create an instance with the line endings set to LF by default', () => {
const config = new LintConfig({})
expect(config).toBeTruthy()
expect(config.lineEndings).toEqual(LineEndings.LF)
})
it('should throw an error with an invalid value for line endings', () => {
expect(() => new LintConfig({ lineEndings: 'test' })).toThrowError(
`Invalid value for lineEndings: can be ${LineEndings.LF} or ${LineEndings.CRLF}`
)
})
it('should create an instance with all flags set', () => {
const config = new LintConfig({
noTrailingSpaces: true,

View File

@@ -2,8 +2,7 @@ import {
hasDoxygenHeader,
hasMacroNameInMend,
noNestedMacros,
hasMacroParentheses,
lineEndings
hasMacroParentheses
} from '../rules/file'
import {
indentationMultiple,
@@ -13,7 +12,6 @@ import {
noTrailingSpaces
} from '../rules/line'
import { lowerCaseFileNames, noSpacesInFileNames } from '../rules/path'
import { LineEndings } from './LineEndings'
import { FileLintRule, LineLintRule, PathLintRule } from './LintRule'
/**
@@ -29,7 +27,6 @@ export class LintConfig {
readonly pathLintRules: PathLintRule[] = []
readonly maxLineLength: number = 80
readonly indentationMultiple: number = 2
readonly lineEndings: LineEndings = LineEndings.LF
constructor(json?: any) {
if (json?.noTrailingSpaces) {
@@ -49,19 +46,6 @@ export class LintConfig {
this.lineLintRules.push(maxLineLength)
}
if (json?.lineEndings) {
if (
json.lineEndings !== LineEndings.LF &&
json.lineEndings !== LineEndings.CRLF
) {
throw new Error(
`Invalid value for lineEndings: can be ${LineEndings.LF} or ${LineEndings.CRLF}`
)
}
this.lineEndings = json.lineEndings
this.fileLintRules.push(lineEndings)
}
if (!isNaN(json?.indentationMultiple)) {
this.indentationMultiple = json.indentationMultiple as number
this.lineLintRules.push(indentationMultiple)

View File

@@ -19,7 +19,6 @@ export interface LintRule {
export interface LineLintRule extends LintRule {
type: LintRuleType.Line
test: (value: string, lineNumber: number, config?: LintConfig) => Diagnostic[]
fix?: (value: string, config?: LintConfig) => string
}
/**
@@ -27,8 +26,7 @@ export interface LineLintRule extends LintRule {
*/
export interface FileLintRule extends LintRule {
type: LintRuleType.File
test: (value: string, config?: LintConfig) => Diagnostic[]
fix?: (value: string, config?: LintConfig) => string
test: (value: string) => Diagnostic[]
}
/**