-
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 #199 from sasjs/issue-45
feat: add a new config maxHeaderLineLength
- Loading branch information
Showing
13 changed files
with
1,890 additions
and
10,399 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { LintConfig } from '../types' | ||
import { getHeaderLinesCount } from './getHeaderLinesCount' | ||
import { DefaultLintConfiguration } from './getLintConfig' | ||
|
||
const sasCodeWithHeader = `/** | ||
@file | ||
@brief <Your brief here> | ||
<h4> SAS Macros </h4> | ||
**/ | ||
%put hello world; | ||
` | ||
|
||
const sasCodeWithoutHeader = `%put hello world;` | ||
|
||
describe('getHeaderLinesCount', () => { | ||
it('should return the number of line header spans upon', () => { | ||
const config = new LintConfig(DefaultLintConfiguration) | ||
expect(getHeaderLinesCount(sasCodeWithHeader, config)).toEqual(5) | ||
expect(getHeaderLinesCount(sasCodeWithoutHeader, config)).toEqual(0) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { LintConfig } from '../types' | ||
import { splitText } from './splitText' | ||
|
||
/** | ||
* This function returns the number of lines the header spans upon. | ||
* The file must start with "/*" and the header will finish with ⇙ | ||
*/ | ||
export const getHeaderLinesCount = (text: string, config: LintConfig) => { | ||
let count = 0 | ||
|
||
if (text.trimStart().startsWith('/*')) { | ||
const lines = splitText(text, config) | ||
|
||
for (const line of lines) { | ||
count++ | ||
if (line.match(/\*\//)) { | ||
break | ||
} | ||
} | ||
} | ||
|
||
return count | ||
} |
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