mirror of
https://github.com/sasjs/lint.git
synced 2025-12-10 17:34:36 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2209cbe0e | ||
|
|
fe974050f7 | ||
|
|
1402802f0a | ||
|
|
36b3a7f319 | ||
|
|
c56887d6e6 | ||
|
|
031a323839 | ||
|
|
c9b6c3af95 |
@@ -7,7 +7,7 @@
|
||||
"lowerCaseFileNames": true,
|
||||
"noTabIndentation": true,
|
||||
"indentationMultiple": 2,
|
||||
"hasMacroNameInMend": false,
|
||||
"hasMacroNameInMend": true,
|
||||
"noNestedMacros": true,
|
||||
"hasMacroParentheses": true
|
||||
}
|
||||
@@ -2,68 +2,87 @@ import { lintFile } from './lintFile'
|
||||
import { Severity } from '../types/Severity'
|
||||
import path from 'path'
|
||||
|
||||
const expectedDiagnostics = [
|
||||
{
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 2,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'File name contains spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'File name contains uppercase characters',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'File missing Doxygen header',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'Line contains encoded password',
|
||||
lineNumber: 5,
|
||||
startColumnNumber: 10,
|
||||
endColumnNumber: 18,
|
||||
severity: Severity.Error
|
||||
},
|
||||
{
|
||||
message: 'Line is indented with a tab',
|
||||
lineNumber: 7,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'Line has incorrect indentation - 3 spaces',
|
||||
lineNumber: 6,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: '%mend statement is missing macro name - mf_getuniquelibref',
|
||||
lineNumber: 17,
|
||||
startColumnNumber: 3,
|
||||
endColumnNumber: 9,
|
||||
severity: Severity.Warning
|
||||
}
|
||||
]
|
||||
|
||||
describe('lintFile', () => {
|
||||
it('should identify lint issues in a given file', async () => {
|
||||
const results = await lintFile(
|
||||
path.join(__dirname, '..', 'Example File.sas')
|
||||
)
|
||||
|
||||
expect(results.length).toEqual(8)
|
||||
expect(results).toContainEqual({
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(results).toContainEqual({
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 2,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(results).toContainEqual({
|
||||
message: 'File name contains spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(results).toContainEqual({
|
||||
message: 'File name contains uppercase characters',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(results).toContainEqual({
|
||||
message: 'File missing Doxygen header',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(results).toContainEqual({
|
||||
message: 'Line contains encoded password',
|
||||
lineNumber: 5,
|
||||
startColumnNumber: 10,
|
||||
endColumnNumber: 18,
|
||||
severity: Severity.Error
|
||||
})
|
||||
expect(results).toContainEqual({
|
||||
message: 'Line is indented with a tab',
|
||||
lineNumber: 7,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(results).toContainEqual({
|
||||
message: 'Line has incorrect indentation - 3 spaces',
|
||||
lineNumber: 6,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(results.length).toEqual(expectedDiagnostics.length)
|
||||
expect(results).toContainEqual(expectedDiagnostics[0])
|
||||
expect(results).toContainEqual(expectedDiagnostics[1])
|
||||
expect(results).toContainEqual(expectedDiagnostics[2])
|
||||
expect(results).toContainEqual(expectedDiagnostics[3])
|
||||
expect(results).toContainEqual(expectedDiagnostics[4])
|
||||
expect(results).toContainEqual(expectedDiagnostics[5])
|
||||
expect(results).toContainEqual(expectedDiagnostics[6])
|
||||
expect(results).toContainEqual(expectedDiagnostics[7])
|
||||
expect(results).toContainEqual(expectedDiagnostics[8])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,70 +2,90 @@ import { lintFolder } from './lintFolder'
|
||||
import { Severity } from '../types/Severity'
|
||||
import path from 'path'
|
||||
|
||||
describe('lintFolder', () => {
|
||||
it('should identify lint issues in a given folder', async () => {
|
||||
const results = await lintFolder(path.join(__dirname, '..'))
|
||||
|
||||
expect(results.size).toEqual(1)
|
||||
const diagnostics = results.get(
|
||||
path.join(__dirname, '..', 'Example File.sas')
|
||||
)!
|
||||
expect(diagnostics.length).toEqual(8)
|
||||
expect(diagnostics).toContainEqual({
|
||||
const expectedFilesCount = 1
|
||||
const expectedDiagnostics = [
|
||||
{
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
},
|
||||
{
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 2,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
},
|
||||
{
|
||||
message: 'File name contains spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
},
|
||||
{
|
||||
message: 'File name contains uppercase characters',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
},
|
||||
{
|
||||
message: 'File missing Doxygen header',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
},
|
||||
{
|
||||
message: 'Line contains encoded password',
|
||||
lineNumber: 5,
|
||||
startColumnNumber: 10,
|
||||
endColumnNumber: 18,
|
||||
severity: Severity.Error
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
},
|
||||
{
|
||||
message: 'Line is indented with a tab',
|
||||
lineNumber: 7,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
},
|
||||
{
|
||||
message: 'Line has incorrect indentation - 3 spaces',
|
||||
lineNumber: 6,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
},
|
||||
{
|
||||
message: '%mend statement is missing macro name - mf_getuniquelibref',
|
||||
lineNumber: 17,
|
||||
startColumnNumber: 3,
|
||||
endColumnNumber: 9,
|
||||
severity: Severity.Warning
|
||||
}
|
||||
]
|
||||
|
||||
describe('lintFolder', () => {
|
||||
it('should identify lint issues in a given folder', async () => {
|
||||
const results = await lintFolder(path.join(__dirname, '..'))
|
||||
|
||||
expect(results.size).toEqual(expectedFilesCount)
|
||||
const diagnostics = results.get(
|
||||
path.join(__dirname, '..', 'Example File.sas')
|
||||
)!
|
||||
expect(diagnostics.length).toEqual(expectedDiagnostics.length)
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[0])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[1])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[2])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[3])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[4])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[5])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[6])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[7])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[8])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,6 +4,73 @@ import * as utils from '../utils'
|
||||
import path from 'path'
|
||||
jest.mock('../utils')
|
||||
|
||||
const expectedFilesCount = 1
|
||||
const expectedDiagnostics = [
|
||||
{
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 2,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'File name contains spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'File name contains uppercase characters',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'File missing Doxygen header',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'Line contains encoded password',
|
||||
lineNumber: 5,
|
||||
startColumnNumber: 10,
|
||||
endColumnNumber: 18,
|
||||
severity: Severity.Error
|
||||
},
|
||||
{
|
||||
message: 'Line is indented with a tab',
|
||||
lineNumber: 7,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: 'Line has incorrect indentation - 3 spaces',
|
||||
lineNumber: 6,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
},
|
||||
{
|
||||
message: '%mend statement is missing macro name - mf_getuniquelibref',
|
||||
lineNumber: 17,
|
||||
startColumnNumber: 3,
|
||||
endColumnNumber: 9,
|
||||
severity: Severity.Warning
|
||||
}
|
||||
]
|
||||
|
||||
describe('lintProject', () => {
|
||||
it('should identify lint issues in a given project', async () => {
|
||||
jest
|
||||
@@ -11,67 +78,20 @@ describe('lintProject', () => {
|
||||
.mockImplementationOnce(() => Promise.resolve(path.join(__dirname, '..')))
|
||||
const results = await lintProject()
|
||||
|
||||
expect(results.size).toEqual(1)
|
||||
expect(results.size).toEqual(expectedFilesCount)
|
||||
const diagnostics = results.get(
|
||||
path.join(__dirname, '..', 'Example File.sas')
|
||||
)!
|
||||
expect(diagnostics.length).toEqual(8)
|
||||
expect(diagnostics).toContainEqual({
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
message: 'Line contains trailing spaces',
|
||||
lineNumber: 2,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 2,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
message: 'File name contains spaces',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
message: 'File name contains uppercase characters',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
message: 'File missing Doxygen header',
|
||||
lineNumber: 1,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
message: 'Line contains encoded password',
|
||||
lineNumber: 5,
|
||||
startColumnNumber: 10,
|
||||
endColumnNumber: 18,
|
||||
severity: Severity.Error
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
message: 'Line is indented with a tab',
|
||||
lineNumber: 7,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics).toContainEqual({
|
||||
message: 'Line has incorrect indentation - 3 spaces',
|
||||
lineNumber: 6,
|
||||
startColumnNumber: 1,
|
||||
endColumnNumber: 1,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
expect(diagnostics.length).toEqual(expectedDiagnostics.length)
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[0])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[1])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[2])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[3])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[4])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[5])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[6])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[7])
|
||||
expect(diagnostics).toContainEqual(expectedDiagnostics[8])
|
||||
})
|
||||
|
||||
it('should throw an error when a project root is not found', async () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { hasDoxygenHeader } from './hasDoxygenHeader'
|
||||
|
||||
describe('hasDoxygenHeader', () => {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FileLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { FileLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
|
||||
const name = 'hasDoxygenHeader'
|
||||
const description =
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { hasMacroNameInMend } from './hasMacroNameInMend'
|
||||
|
||||
describe('hasMacroNameInMend', () => {
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Diagnostic } from '../types/Diagnostic'
|
||||
import { FileLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { trimComments } from '../utils/trimComments'
|
||||
import { getColumnNumber } from '../utils/getColumnNumber'
|
||||
import { Diagnostic } from '../../types/Diagnostic'
|
||||
import { FileLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { trimComments } from '../../utils/trimComments'
|
||||
import { getColumnNumber } from '../../utils/getColumnNumber'
|
||||
|
||||
const name = 'hasMacroNameInMend'
|
||||
const description =
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { hasMacroParentheses } from './hasMacroParentheses'
|
||||
|
||||
describe('hasMacroParentheses', () => {
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Diagnostic } from '../types/Diagnostic'
|
||||
import { FileLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { trimComments } from '../utils/trimComments'
|
||||
import { getColumnNumber } from '../utils/getColumnNumber'
|
||||
import { Diagnostic } from '../../types/Diagnostic'
|
||||
import { FileLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { trimComments } from '../../utils/trimComments'
|
||||
import { getColumnNumber } from '../../utils/getColumnNumber'
|
||||
|
||||
const name = 'hasMacroParentheses'
|
||||
const description = 'Enforces the presence of parentheses in macro definitions.'
|
||||
4
src/rules/file/index.ts
Normal file
4
src/rules/file/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export { hasDoxygenHeader } from './hasDoxygenHeader'
|
||||
export { hasMacroNameInMend } from './hasMacroNameInMend'
|
||||
export { hasMacroParentheses } from './hasMacroParentheses'
|
||||
export { noNestedMacros } from './noNestedMacros'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { noNestedMacros } from './noNestedMacros'
|
||||
|
||||
describe('noNestedMacros', () => {
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Diagnostic } from '../types/Diagnostic'
|
||||
import { FileLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { trimComments } from '../utils/trimComments'
|
||||
import { getColumnNumber } from '../utils/getColumnNumber'
|
||||
import { Diagnostic } from '../../types/Diagnostic'
|
||||
import { FileLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { trimComments } from '../../utils/trimComments'
|
||||
import { getColumnNumber } from '../../utils/getColumnNumber'
|
||||
|
||||
const name = 'noNestedMacros'
|
||||
const description = 'Enfoces the absence of nested macro definitions.'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LintConfig, Severity } from '../types'
|
||||
import { LintConfig, Severity } from '../../types'
|
||||
import { indentationMultiple } from './indentationMultiple'
|
||||
|
||||
describe('indentationMultiple', () => {
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LintConfig } from '../types'
|
||||
import { LineLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { LintConfig } from '../../types'
|
||||
import { LineLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
|
||||
const name = 'indentationMultiple'
|
||||
const description = 'Ensure indentation by a multiple of the configured number.'
|
||||
5
src/rules/line/index.ts
Normal file
5
src/rules/line/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export { indentationMultiple } from './indentationMultiple'
|
||||
export { maxLineLength } from './maxLineLength'
|
||||
export { noEncodedPasswords } from './noEncodedPasswords'
|
||||
export { noTabIndentation } from './noTabIndentation'
|
||||
export { noTrailingSpaces } from './noTrailingSpaces'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LintConfig, Severity } from '../types'
|
||||
import { LintConfig, Severity } from '../../types'
|
||||
import { maxLineLength } from './maxLineLength'
|
||||
|
||||
describe('maxLineLength', () => {
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LintConfig } from '../types'
|
||||
import { LineLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { LintConfig } from '../../types'
|
||||
import { LineLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
|
||||
const name = 'maxLineLength'
|
||||
const description = 'Restrict lines to the specified length.'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { noEncodedPasswords } from './noEncodedPasswords'
|
||||
|
||||
describe('noEncodedPasswords', () => {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LineLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { LineLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
|
||||
const name = 'noEncodedPasswords'
|
||||
const description = 'Disallow encoded passwords in SAS code.'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { noTabIndentation } from './noTabIndentation'
|
||||
|
||||
describe('noTabs', () => {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LineLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { LineLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
|
||||
const name = 'noTabs'
|
||||
const description = 'Disallow indenting with tabs.'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { noTrailingSpaces } from './noTrailingSpaces'
|
||||
|
||||
describe('noTrailingSpaces', () => {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LineLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { LineLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
|
||||
const name = 'noTrailingSpaces'
|
||||
const description = 'Disallow trailing spaces on lines.'
|
||||
2
src/rules/path/index.ts
Normal file
2
src/rules/path/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { lowerCaseFileNames } from './lowerCaseFileNames'
|
||||
export { noSpacesInFileNames } from './noSpacesInFileNames'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { lowerCaseFileNames } from './lowerCaseFileNames'
|
||||
|
||||
describe('lowerCaseFileNames', () => {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PathLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { PathLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import path from 'path'
|
||||
|
||||
const name = 'lowerCaseFileNames'
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Severity } from '../types/Severity'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import { noSpacesInFileNames } from './noSpacesInFileNames'
|
||||
|
||||
describe('noSpacesInFileNames', () => {
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PathLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
import { Severity } from '../types/Severity'
|
||||
import { PathLintRule } from '../../types/LintRule'
|
||||
import { LintRuleType } from '../../types/LintRuleType'
|
||||
import { Severity } from '../../types/Severity'
|
||||
import path from 'path'
|
||||
|
||||
const name = 'noSpacesInFileNames'
|
||||
@@ -1,14 +1,17 @@
|
||||
import { hasDoxygenHeader } from '../rules/hasDoxygenHeader'
|
||||
import { indentationMultiple } from '../rules/indentationMultiple'
|
||||
import { lowerCaseFileNames } from '../rules/lowerCaseFileNames'
|
||||
import { maxLineLength } from '../rules/maxLineLength'
|
||||
import { noEncodedPasswords } from '../rules/noEncodedPasswords'
|
||||
import { noSpacesInFileNames } from '../rules/noSpacesInFileNames'
|
||||
import { noTabIndentation } from '../rules/noTabIndentation'
|
||||
import { noTrailingSpaces } from '../rules/noTrailingSpaces'
|
||||
import { hasMacroNameInMend } from '../rules/hasMacroNameInMend'
|
||||
import { noNestedMacros } from '../rules/noNestedMacros'
|
||||
import { hasMacroParentheses } from '../rules/hasMacroParentheses'
|
||||
import {
|
||||
hasDoxygenHeader,
|
||||
hasMacroNameInMend,
|
||||
noNestedMacros,
|
||||
hasMacroParentheses
|
||||
} from '../rules/file'
|
||||
import {
|
||||
indentationMultiple,
|
||||
maxLineLength,
|
||||
noEncodedPasswords,
|
||||
noTabIndentation,
|
||||
noTrailingSpaces
|
||||
} from '../rules/line'
|
||||
import { lowerCaseFileNames, noSpacesInFileNames } from '../rules/path'
|
||||
import { FileLintRule, LineLintRule, PathLintRule } from './LintRule'
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,10 @@ import * as fileModule from '@sasjs/utils/file'
|
||||
import { LintConfig } from '../types/LintConfig'
|
||||
import { getLintConfig } from './getLintConfig'
|
||||
|
||||
const expectedFileLintRulesCount = 4
|
||||
const expectedLineLintRulesCount = 5
|
||||
const expectedPathLintRulesCount = 2
|
||||
|
||||
describe('getLintConfig', () => {
|
||||
it('should get the lint config', async () => {
|
||||
const config = await getLintConfig()
|
||||
@@ -17,8 +21,8 @@ describe('getLintConfig', () => {
|
||||
const config = await getLintConfig()
|
||||
|
||||
expect(config).toBeInstanceOf(LintConfig)
|
||||
expect(config.fileLintRules.length).toEqual(3)
|
||||
expect(config.lineLintRules.length).toEqual(5)
|
||||
expect(config.pathLintRules.length).toEqual(2)
|
||||
expect(config.fileLintRules.length).toEqual(expectedFileLintRulesCount)
|
||||
expect(config.lineLintRules.length).toEqual(expectedLineLintRulesCount)
|
||||
expect(config.pathLintRules.length).toEqual(expectedPathLintRulesCount)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@ export const DefaultLintConfiguration = {
|
||||
maxLineLength: 80,
|
||||
noTabIndentation: true,
|
||||
indentationMultiple: 2,
|
||||
hasMacroNameInMend: false,
|
||||
hasMacroNameInMend: true,
|
||||
noNestedMacros: true,
|
||||
hasMacroParentheses: true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user