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,
|
"lowerCaseFileNames": true,
|
||||||
"noTabIndentation": true,
|
"noTabIndentation": true,
|
||||||
"indentationMultiple": 2,
|
"indentationMultiple": 2,
|
||||||
"hasMacroNameInMend": false,
|
"hasMacroNameInMend": true,
|
||||||
"noNestedMacros": true,
|
"noNestedMacros": true,
|
||||||
"hasMacroParentheses": true
|
"hasMacroParentheses": true
|
||||||
}
|
}
|
||||||
@@ -2,68 +2,87 @@ import { lintFile } from './lintFile'
|
|||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../types/Severity'
|
||||||
import path from 'path'
|
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', () => {
|
describe('lintFile', () => {
|
||||||
it('should identify lint issues in a given file', async () => {
|
it('should identify lint issues in a given file', async () => {
|
||||||
const results = await lintFile(
|
const results = await lintFile(
|
||||||
path.join(__dirname, '..', 'Example File.sas')
|
path.join(__dirname, '..', 'Example File.sas')
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(results.length).toEqual(8)
|
expect(results.length).toEqual(expectedDiagnostics.length)
|
||||||
expect(results).toContainEqual({
|
expect(results).toContainEqual(expectedDiagnostics[0])
|
||||||
message: 'Line contains trailing spaces',
|
expect(results).toContainEqual(expectedDiagnostics[1])
|
||||||
lineNumber: 1,
|
expect(results).toContainEqual(expectedDiagnostics[2])
|
||||||
startColumnNumber: 1,
|
expect(results).toContainEqual(expectedDiagnostics[3])
|
||||||
endColumnNumber: 2,
|
expect(results).toContainEqual(expectedDiagnostics[4])
|
||||||
severity: Severity.Warning
|
expect(results).toContainEqual(expectedDiagnostics[5])
|
||||||
})
|
expect(results).toContainEqual(expectedDiagnostics[6])
|
||||||
expect(results).toContainEqual({
|
expect(results).toContainEqual(expectedDiagnostics[7])
|
||||||
message: 'Line contains trailing spaces',
|
expect(results).toContainEqual(expectedDiagnostics[8])
|
||||||
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
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,70 +2,90 @@ import { lintFolder } from './lintFolder'
|
|||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../types/Severity'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
|
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('lintFolder', () => {
|
describe('lintFolder', () => {
|
||||||
it('should identify lint issues in a given folder', async () => {
|
it('should identify lint issues in a given folder', async () => {
|
||||||
const results = await lintFolder(path.join(__dirname, '..'))
|
const results = await lintFolder(path.join(__dirname, '..'))
|
||||||
|
|
||||||
expect(results.size).toEqual(1)
|
expect(results.size).toEqual(expectedFilesCount)
|
||||||
const diagnostics = results.get(
|
const diagnostics = results.get(
|
||||||
path.join(__dirname, '..', 'Example File.sas')
|
path.join(__dirname, '..', 'Example File.sas')
|
||||||
)!
|
)!
|
||||||
expect(diagnostics.length).toEqual(8)
|
expect(diagnostics.length).toEqual(expectedDiagnostics.length)
|
||||||
expect(diagnostics).toContainEqual({
|
expect(diagnostics).toContainEqual(expectedDiagnostics[0])
|
||||||
message: 'Line contains trailing spaces',
|
expect(diagnostics).toContainEqual(expectedDiagnostics[1])
|
||||||
lineNumber: 1,
|
expect(diagnostics).toContainEqual(expectedDiagnostics[2])
|
||||||
startColumnNumber: 1,
|
expect(diagnostics).toContainEqual(expectedDiagnostics[3])
|
||||||
endColumnNumber: 2,
|
expect(diagnostics).toContainEqual(expectedDiagnostics[4])
|
||||||
severity: Severity.Warning
|
expect(diagnostics).toContainEqual(expectedDiagnostics[5])
|
||||||
})
|
expect(diagnostics).toContainEqual(expectedDiagnostics[6])
|
||||||
expect(diagnostics).toContainEqual({
|
expect(diagnostics).toContainEqual(expectedDiagnostics[7])
|
||||||
message: 'Line contains trailing spaces',
|
expect(diagnostics).toContainEqual(expectedDiagnostics[8])
|
||||||
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
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,73 @@ import * as utils from '../utils'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
jest.mock('../utils')
|
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', () => {
|
describe('lintProject', () => {
|
||||||
it('should identify lint issues in a given project', async () => {
|
it('should identify lint issues in a given project', async () => {
|
||||||
jest
|
jest
|
||||||
@@ -11,67 +78,20 @@ describe('lintProject', () => {
|
|||||||
.mockImplementationOnce(() => Promise.resolve(path.join(__dirname, '..')))
|
.mockImplementationOnce(() => Promise.resolve(path.join(__dirname, '..')))
|
||||||
const results = await lintProject()
|
const results = await lintProject()
|
||||||
|
|
||||||
expect(results.size).toEqual(1)
|
expect(results.size).toEqual(expectedFilesCount)
|
||||||
const diagnostics = results.get(
|
const diagnostics = results.get(
|
||||||
path.join(__dirname, '..', 'Example File.sas')
|
path.join(__dirname, '..', 'Example File.sas')
|
||||||
)!
|
)!
|
||||||
expect(diagnostics.length).toEqual(8)
|
expect(diagnostics.length).toEqual(expectedDiagnostics.length)
|
||||||
expect(diagnostics).toContainEqual({
|
expect(diagnostics).toContainEqual(expectedDiagnostics[0])
|
||||||
message: 'Line contains trailing spaces',
|
expect(diagnostics).toContainEqual(expectedDiagnostics[1])
|
||||||
lineNumber: 1,
|
expect(diagnostics).toContainEqual(expectedDiagnostics[2])
|
||||||
startColumnNumber: 1,
|
expect(diagnostics).toContainEqual(expectedDiagnostics[3])
|
||||||
endColumnNumber: 2,
|
expect(diagnostics).toContainEqual(expectedDiagnostics[4])
|
||||||
severity: Severity.Warning
|
expect(diagnostics).toContainEqual(expectedDiagnostics[5])
|
||||||
})
|
expect(diagnostics).toContainEqual(expectedDiagnostics[6])
|
||||||
expect(diagnostics).toContainEqual({
|
expect(diagnostics).toContainEqual(expectedDiagnostics[7])
|
||||||
message: 'Line contains trailing spaces',
|
expect(diagnostics).toContainEqual(expectedDiagnostics[8])
|
||||||
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
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw an error when a project root is not found', async () => {
|
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'
|
import { hasDoxygenHeader } from './hasDoxygenHeader'
|
||||||
|
|
||||||
describe('hasDoxygenHeader', () => {
|
describe('hasDoxygenHeader', () => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { FileLintRule } from '../types/LintRule'
|
import { FileLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
|
|
||||||
const name = 'hasDoxygenHeader'
|
const name = 'hasDoxygenHeader'
|
||||||
const description =
|
const description =
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import { hasMacroNameInMend } from './hasMacroNameInMend'
|
import { hasMacroNameInMend } from './hasMacroNameInMend'
|
||||||
|
|
||||||
describe('hasMacroNameInMend', () => {
|
describe('hasMacroNameInMend', () => {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Diagnostic } from '../types/Diagnostic'
|
import { Diagnostic } from '../../types/Diagnostic'
|
||||||
import { FileLintRule } from '../types/LintRule'
|
import { FileLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import { trimComments } from '../utils/trimComments'
|
import { trimComments } from '../../utils/trimComments'
|
||||||
import { getColumnNumber } from '../utils/getColumnNumber'
|
import { getColumnNumber } from '../../utils/getColumnNumber'
|
||||||
|
|
||||||
const name = 'hasMacroNameInMend'
|
const name = 'hasMacroNameInMend'
|
||||||
const description =
|
const description =
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import { hasMacroParentheses } from './hasMacroParentheses'
|
import { hasMacroParentheses } from './hasMacroParentheses'
|
||||||
|
|
||||||
describe('hasMacroParentheses', () => {
|
describe('hasMacroParentheses', () => {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Diagnostic } from '../types/Diagnostic'
|
import { Diagnostic } from '../../types/Diagnostic'
|
||||||
import { FileLintRule } from '../types/LintRule'
|
import { FileLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import { trimComments } from '../utils/trimComments'
|
import { trimComments } from '../../utils/trimComments'
|
||||||
import { getColumnNumber } from '../utils/getColumnNumber'
|
import { getColumnNumber } from '../../utils/getColumnNumber'
|
||||||
|
|
||||||
const name = 'hasMacroParentheses'
|
const name = 'hasMacroParentheses'
|
||||||
const description = 'Enforces the presence of parentheses in macro definitions.'
|
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'
|
import { noNestedMacros } from './noNestedMacros'
|
||||||
|
|
||||||
describe('noNestedMacros', () => {
|
describe('noNestedMacros', () => {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Diagnostic } from '../types/Diagnostic'
|
import { Diagnostic } from '../../types/Diagnostic'
|
||||||
import { FileLintRule } from '../types/LintRule'
|
import { FileLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import { trimComments } from '../utils/trimComments'
|
import { trimComments } from '../../utils/trimComments'
|
||||||
import { getColumnNumber } from '../utils/getColumnNumber'
|
import { getColumnNumber } from '../../utils/getColumnNumber'
|
||||||
|
|
||||||
const name = 'noNestedMacros'
|
const name = 'noNestedMacros'
|
||||||
const description = 'Enfoces the absence of nested macro definitions.'
|
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'
|
import { indentationMultiple } from './indentationMultiple'
|
||||||
|
|
||||||
describe('indentationMultiple', () => {
|
describe('indentationMultiple', () => {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LintConfig } from '../types'
|
import { LintConfig } from '../../types'
|
||||||
import { LineLintRule } from '../types/LintRule'
|
import { LineLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
|
|
||||||
const name = 'indentationMultiple'
|
const name = 'indentationMultiple'
|
||||||
const description = 'Ensure indentation by a multiple of the configured number.'
|
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'
|
import { maxLineLength } from './maxLineLength'
|
||||||
|
|
||||||
describe('maxLineLength', () => {
|
describe('maxLineLength', () => {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { LintConfig } from '../types'
|
import { LintConfig } from '../../types'
|
||||||
import { LineLintRule } from '../types/LintRule'
|
import { LineLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
|
|
||||||
const name = 'maxLineLength'
|
const name = 'maxLineLength'
|
||||||
const description = 'Restrict lines to the specified length.'
|
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'
|
import { noEncodedPasswords } from './noEncodedPasswords'
|
||||||
|
|
||||||
describe('noEncodedPasswords', () => {
|
describe('noEncodedPasswords', () => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LineLintRule } from '../types/LintRule'
|
import { LineLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
|
|
||||||
const name = 'noEncodedPasswords'
|
const name = 'noEncodedPasswords'
|
||||||
const description = 'Disallow encoded passwords in SAS code.'
|
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'
|
import { noTabIndentation } from './noTabIndentation'
|
||||||
|
|
||||||
describe('noTabs', () => {
|
describe('noTabs', () => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LineLintRule } from '../types/LintRule'
|
import { LineLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
|
|
||||||
const name = 'noTabs'
|
const name = 'noTabs'
|
||||||
const description = 'Disallow indenting with tabs.'
|
const description = 'Disallow indenting with tabs.'
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import { noTrailingSpaces } from './noTrailingSpaces'
|
import { noTrailingSpaces } from './noTrailingSpaces'
|
||||||
|
|
||||||
describe('noTrailingSpaces', () => {
|
describe('noTrailingSpaces', () => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { LineLintRule } from '../types/LintRule'
|
import { LineLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
|
|
||||||
const name = 'noTrailingSpaces'
|
const name = 'noTrailingSpaces'
|
||||||
const description = 'Disallow trailing spaces on lines.'
|
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'
|
import { lowerCaseFileNames } from './lowerCaseFileNames'
|
||||||
|
|
||||||
describe('lowerCaseFileNames', () => {
|
describe('lowerCaseFileNames', () => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { PathLintRule } from '../types/LintRule'
|
import { PathLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
const name = 'lowerCaseFileNames'
|
const name = 'lowerCaseFileNames'
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import { noSpacesInFileNames } from './noSpacesInFileNames'
|
import { noSpacesInFileNames } from './noSpacesInFileNames'
|
||||||
|
|
||||||
describe('noSpacesInFileNames', () => {
|
describe('noSpacesInFileNames', () => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { PathLintRule } from '../types/LintRule'
|
import { PathLintRule } from '../../types/LintRule'
|
||||||
import { LintRuleType } from '../types/LintRuleType'
|
import { LintRuleType } from '../../types/LintRuleType'
|
||||||
import { Severity } from '../types/Severity'
|
import { Severity } from '../../types/Severity'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
const name = 'noSpacesInFileNames'
|
const name = 'noSpacesInFileNames'
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
import { hasDoxygenHeader } from '../rules/hasDoxygenHeader'
|
import {
|
||||||
import { indentationMultiple } from '../rules/indentationMultiple'
|
hasDoxygenHeader,
|
||||||
import { lowerCaseFileNames } from '../rules/lowerCaseFileNames'
|
hasMacroNameInMend,
|
||||||
import { maxLineLength } from '../rules/maxLineLength'
|
noNestedMacros,
|
||||||
import { noEncodedPasswords } from '../rules/noEncodedPasswords'
|
hasMacroParentheses
|
||||||
import { noSpacesInFileNames } from '../rules/noSpacesInFileNames'
|
} from '../rules/file'
|
||||||
import { noTabIndentation } from '../rules/noTabIndentation'
|
import {
|
||||||
import { noTrailingSpaces } from '../rules/noTrailingSpaces'
|
indentationMultiple,
|
||||||
import { hasMacroNameInMend } from '../rules/hasMacroNameInMend'
|
maxLineLength,
|
||||||
import { noNestedMacros } from '../rules/noNestedMacros'
|
noEncodedPasswords,
|
||||||
import { hasMacroParentheses } from '../rules/hasMacroParentheses'
|
noTabIndentation,
|
||||||
|
noTrailingSpaces
|
||||||
|
} from '../rules/line'
|
||||||
|
import { lowerCaseFileNames, noSpacesInFileNames } from '../rules/path'
|
||||||
import { FileLintRule, LineLintRule, PathLintRule } from './LintRule'
|
import { FileLintRule, LineLintRule, PathLintRule } from './LintRule'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ import * as fileModule from '@sasjs/utils/file'
|
|||||||
import { LintConfig } from '../types/LintConfig'
|
import { LintConfig } from '../types/LintConfig'
|
||||||
import { getLintConfig } from './getLintConfig'
|
import { getLintConfig } from './getLintConfig'
|
||||||
|
|
||||||
|
const expectedFileLintRulesCount = 4
|
||||||
|
const expectedLineLintRulesCount = 5
|
||||||
|
const expectedPathLintRulesCount = 2
|
||||||
|
|
||||||
describe('getLintConfig', () => {
|
describe('getLintConfig', () => {
|
||||||
it('should get the lint config', async () => {
|
it('should get the lint config', async () => {
|
||||||
const config = await getLintConfig()
|
const config = await getLintConfig()
|
||||||
@@ -17,8 +21,8 @@ describe('getLintConfig', () => {
|
|||||||
const config = await getLintConfig()
|
const config = await getLintConfig()
|
||||||
|
|
||||||
expect(config).toBeInstanceOf(LintConfig)
|
expect(config).toBeInstanceOf(LintConfig)
|
||||||
expect(config.fileLintRules.length).toEqual(3)
|
expect(config.fileLintRules.length).toEqual(expectedFileLintRulesCount)
|
||||||
expect(config.lineLintRules.length).toEqual(5)
|
expect(config.lineLintRules.length).toEqual(expectedLineLintRulesCount)
|
||||||
expect(config.pathLintRules.length).toEqual(2)
|
expect(config.pathLintRules.length).toEqual(expectedPathLintRulesCount)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const DefaultLintConfiguration = {
|
|||||||
maxLineLength: 80,
|
maxLineLength: 80,
|
||||||
noTabIndentation: true,
|
noTabIndentation: true,
|
||||||
indentationMultiple: 2,
|
indentationMultiple: 2,
|
||||||
hasMacroNameInMend: false,
|
hasMacroNameInMend: true,
|
||||||
noNestedMacros: true,
|
noNestedMacros: true,
|
||||||
hasMacroParentheses: true
|
hasMacroParentheses: true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user