-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from sasjs/lint-file-paths
feat(*): group folder and project diagnostics by file path
- Loading branch information
Showing
5 changed files
with
51 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,86 @@ | ||
import { lintProject } from './lintProject' | ||
import { Severity } from '../types/Severity' | ||
import * as utils from '../utils' | ||
import path from 'path' | ||
jest.mock('../utils') | ||
|
||
describe('lintProject', () => { | ||
it('should identify lint issues in a given project', async () => { | ||
jest | ||
.spyOn(utils, 'getProjectRoot') | ||
.mockImplementationOnce(() => Promise.resolve(path.join(__dirname, '..'))) | ||
const results = await lintProject() | ||
|
||
expect(results.length).toEqual(8) | ||
expect(results).toContainEqual({ | ||
expect(results.size).toEqual(1) | ||
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(results).toContainEqual({ | ||
expect(diagnostics).toContainEqual({ | ||
message: 'Line contains trailing spaces', | ||
lineNumber: 2, | ||
startColumnNumber: 1, | ||
endColumnNumber: 2, | ||
severity: Severity.Warning | ||
}) | ||
expect(results).toContainEqual({ | ||
expect(diagnostics).toContainEqual({ | ||
message: 'File name contains spaces', | ||
lineNumber: 1, | ||
startColumnNumber: 1, | ||
endColumnNumber: 1, | ||
severity: Severity.Warning | ||
}) | ||
expect(results).toContainEqual({ | ||
expect(diagnostics).toContainEqual({ | ||
message: 'File name contains uppercase characters', | ||
lineNumber: 1, | ||
startColumnNumber: 1, | ||
endColumnNumber: 1, | ||
severity: Severity.Warning | ||
}) | ||
expect(results).toContainEqual({ | ||
expect(diagnostics).toContainEqual({ | ||
message: 'File missing Doxygen header', | ||
lineNumber: 1, | ||
startColumnNumber: 1, | ||
endColumnNumber: 1, | ||
severity: Severity.Warning | ||
}) | ||
expect(results).toContainEqual({ | ||
expect(diagnostics).toContainEqual({ | ||
message: 'Line contains encoded password', | ||
lineNumber: 5, | ||
startColumnNumber: 10, | ||
endColumnNumber: 18, | ||
severity: Severity.Error | ||
}) | ||
expect(results).toContainEqual({ | ||
expect(diagnostics).toContainEqual({ | ||
message: 'Line is indented with a tab', | ||
lineNumber: 7, | ||
startColumnNumber: 1, | ||
endColumnNumber: 1, | ||
severity: Severity.Warning | ||
}) | ||
expect(results).toContainEqual({ | ||
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 () => { | ||
jest | ||
.spyOn(utils, 'getProjectRoot') | ||
.mockImplementationOnce(() => Promise.resolve('')) | ||
|
||
await expect(lintProject()).rejects.toThrowError( | ||
'SASjs Project Root was not found.' | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters