-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(harper.js): added more detailed and beginner-friendly documentat…
…ion on linting
- Loading branch information
1 parent
ace693c
commit ef4d503
Showing
6 changed files
with
48 additions
and
8 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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
// We can import `harper.js` using native ECMAScript syntax. | ||
import { WorkerLinter } from 'https://unpkg.com/[email protected]/dist/harper.js'; | ||
|
||
// Since we are working the browser, we can use either `WorkerLinter`, which doesn't block the event loop, or `LocalLinter`, which does. | ||
// Since we are working in the browser, we can use either `WorkerLinter`, which doesn't block the event loop, or `LocalLinter`, which does. | ||
let linter = new WorkerLinter(); | ||
|
||
// Every time the `<textarea/>` received an input, we process it and update our list. | ||
|
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,25 @@ | ||
--- | ||
title: Linting With harper.js | ||
--- | ||
|
||
[Linting](<https://en.wikipedia.org/wiki/Lint_(software)>) is the process of consuming, analyzing, and finding faults in text. | ||
This is the principle task Harper tries to do. | ||
When possible, Harper also tries to automatically generate fixes for any issues it finds. | ||
|
||
In `harper.js`, there's just one interface you need to worry about: the `Linter`. | ||
|
||
## Linters | ||
|
||
The `Linter` type is relatively straightforward and has two implementations: the `LocalLinter` and the `WorkerLinter`. | ||
Notice how every method returns a `Promise<...>`. | ||
|
||
@code(../../../../../../harper.js/src/Linter.ts) | ||
|
||
The `LocalLinter` will instantiate and prepare Harper's WebAssembly module asynchronously, but notably **in the same event loop**. | ||
This can result in high [LCP](https://developer.mozilla.org/en-US/docs/Glossary/Largest_contentful_paint), so this implementation is only recommended in situtations where the event loop will not be doing other latency-sensitive things. | ||
In other words: the `LocalLinter` is not for the web. | ||
|
||
The `WorkerLinter`, on the other hand, will instantiate and prepare Harper's WebAssembly module inside a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API), which means it will **not** block the event loop. | ||
This is recommended for interactive web applications. | ||
|
||
[Visit our page about CDNs](./CDN) to see an example of the `WorkerLinter` in action. |
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