-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: eslint-plugin - fix issue with document directives
Ignore Regexp were not being honored.
- Loading branch information
Showing
8 changed files
with
2,635 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* @type { import("eslint").Linter.Config } | ||
*/ | ||
const config = { | ||
extends: ['./.eslintrc.js', 'plugin:@cspell/recommended'], | ||
}; | ||
|
||
module.exports = config; |
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
13 changes: 13 additions & 0 deletions
13
packages/cspell-lib/fixtures/docValidator/sample-with-cspell-directives.ts
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,13 @@ | ||
// cspell:disable-next-line | ||
const message = 'Helllo world'; | ||
|
||
// cspell:disable | ||
const messages = ['muawhahahaha', 'grrrr', 'uuug', 'aarf']; | ||
// cspell:enable | ||
|
||
function main() { | ||
console.log(message); | ||
console.log(messages); | ||
} | ||
|
||
main(); |
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,24 @@ | ||
import { createTimer, polyHrTime } from './timer'; | ||
import { promisify } from 'util'; | ||
|
||
const delay = promisify(setTimeout); | ||
|
||
describe('timer', () => { | ||
test('createTimer', async () => { | ||
const t = createTimer(); | ||
await delay(12); | ||
expect(t.elapsed()).toBeGreaterThan(10); | ||
}); | ||
|
||
test('polyHrTime', async () => { | ||
const a = createTimer(); | ||
const b = createTimer(polyHrTime); | ||
await delay(12); | ||
const a1 = a.elapsed(); | ||
const b1 = b.elapsed(); | ||
expect(a1).toBeGreaterThanOrEqual(10); | ||
expect(b1).toBeGreaterThanOrEqual(10); | ||
|
||
expect(Math.abs(b1 - a1)).toBeLessThan(2); | ||
}); | ||
}); |
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,40 @@ | ||
const _hrTime: HRTimeFn = process?.hrtime || polyHrTime; | ||
|
||
export interface Timer { | ||
/** Start / restart the timer. */ | ||
start(): void; | ||
/** | ||
* Calculate the amount of time in ms since the | ||
* timer was created / started. | ||
*/ | ||
elapsed(): number; | ||
} | ||
|
||
export function createTimer(hrTimeFn = _hrTime): Timer { | ||
let start: HRTime = hrTimeFn(); | ||
|
||
return { | ||
start() { | ||
start = hrTimeFn(); | ||
}, | ||
elapsed() { | ||
return toMilliseconds(hrTimeFn(start)); | ||
}, | ||
}; | ||
} | ||
|
||
export type HRTimeFn = (time?: HRTime) => HRTime; | ||
|
||
export type HRTime = [number, number]; | ||
|
||
export function toMilliseconds(t: HRTime): number { | ||
return (t[0] + t[1] * 1e-9) * 1000; | ||
} | ||
|
||
export function polyHrTime(time?: HRTime): HRTime { | ||
const now = Date.now() - (time ? toMilliseconds(time) : 0); | ||
const inSeconds = now * 1.0e-3; | ||
const s = Math.floor(inSeconds); | ||
const n = (inSeconds - s) * 1.0e9; | ||
return [s, n]; | ||
} |