-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deno-lint): implment webpack loader and cli
- Loading branch information
1 parent
9e1c24a
commit 59454e2
Showing
12 changed files
with
267 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,93 @@ | ||
# `@node-rs/deno-lint` | ||
|
||
![](https://github.com/napi-rs/node-rs/workflows/CI/badge.svg) | ||
![](https://img.shields.io/npm/dm/@node-rs/deno-lint.svg?sanitize=true) | ||
|
||
> deno_lint nodejs binding | ||
## Performance | ||
|
||
### Hardware info | ||
|
||
``` | ||
Model Name: MacBook Pro | ||
Model Identifier: MacBookPro15,1 | ||
Processor Name: 6-Core Intel Core i9 | ||
Processor Speed: 2.9 GHz | ||
Number of Processors: 1 | ||
Total Number of Cores: 6 | ||
L2 Cache (per Core): 256 KB | ||
L3 Cache: 12 MB | ||
Hyper-Threading Technology: Enabled | ||
Memory: 32 GB | ||
``` | ||
|
||
### Benchmark | ||
|
||
``` | ||
@node-rs/deno-lint x 885 ops/sec ±1.26% (92 runs sampled) | ||
eslint x 118 ops/sec ±4.97% (78 runs sampled) | ||
Lint benchmark bench suite: Fastest is @node-rs/deno-lint | ||
``` | ||
|
||
## Usage | ||
|
||
```ts | ||
import { lint } from 'deno-lint' | ||
import { lint } from '@node-rs/deno-lint' | ||
|
||
lint(filepath, source, enableAllRules) | ||
``` | ||
|
||
## webpack-loader | ||
|
||
```js | ||
// webpack.config.js | ||
|
||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
enforce: 'pre', | ||
test: /\.(t|j)s?$/, | ||
loader: '@node-rs/deno-lint/webpack-loader', | ||
exclude: [/node_modules/], | ||
}, | ||
], | ||
}, | ||
} | ||
``` | ||
|
||
### Options | ||
|
||
You can pass denolint options using standard webpack loader options. | ||
|
||
#### `enableAllRules` | ||
|
||
- Type: `Boolean` | ||
- Default: `false` | ||
|
||
Whether to enable all rules. If false, `denolint` will enable all recommend rules. | ||
|
||
#### `failOnError` | ||
|
||
- Type: `Boolean` | ||
- Default: `false` | ||
|
||
Will cause the module build to fail if there are any errors, if option is set to `true`. | ||
|
||
#### `quiet` | ||
|
||
- Type: `Boolean` | ||
- Default: `false` | ||
|
||
Emit nothing even if there were errors happened. | ||
|
||
## `denolint` cli | ||
|
||
### usage | ||
|
||
`npx denolint` | ||
|
||
### `--all`, `-a` | ||
|
||
Enable all rules flag, if not present, denolint will run with recommend rules. |
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,3 @@ | ||
# `@node-rs/deno-lint-linux-musl` | ||
|
||
This is the Linux 64-bit `musl` binary for `@node-rs/deno-lint`. |
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 @@ | ||
{ | ||
"name": "@node-rs/deno-lint-linux-musl", | ||
"version": "0.0.0", | ||
"description": "Deno lint binding for NodeJS", | ||
"keywords": ["Deno", "Lint", "ESLint", "node-rs", "napi", "N-API", "Rust", "napi-rs"], | ||
"author": "LongYinan <lynweklm@gmail.com>", | ||
"homepage": "https://github.com/napi-rs/node-rs", | ||
"license": "MIT", | ||
"main": "deno-lint.musl.node", | ||
"files": ["deno-lint.musl.node"], | ||
"os": ["linux"], | ||
"cpu": ["x64"], | ||
"engines": { | ||
"node": ">= 8.9" | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/", | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/napi-rs/node-rs.git" | ||
} | ||
} |
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 @@ | ||
module.exports = ['win32', 'darwin', 'linux'] |
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,33 @@ | ||
const { getOptions } = require('loader-utils') | ||
|
||
const { lint } = require('./index') | ||
|
||
module.exports = function denoLintLoader(source, sm) { | ||
const callback = this.async() | ||
const options = getOptions(this) | ||
const diagnostics = lint(this.resourcePath, source, options.enableAllRules) | ||
|
||
if (this.resourcePath.endsWith('diff-size.ts')) { | ||
this.emitWarning(`${this.resourcePath}, ${diagnostics.length}`) | ||
} | ||
|
||
const hasError = diagnostics.length | ||
|
||
if (!hasError) { | ||
callback(null, source, sm) | ||
return | ||
} | ||
|
||
if (options.failOnError) { | ||
callback(new Error('Lint error'), source, sm) | ||
return | ||
} | ||
|
||
if (!options.quiet) { | ||
for (const diagnostic of diagnostics) { | ||
this.emitError(diagnostic) | ||
} | ||
} | ||
|
||
callback(null, source, sm) | ||
} |
Oops, something went wrong.