Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
This is the first version released after forking the [customisation] of the [original project].

* Scan specific directories ([631], [647])
* Scan directories configured by `files.include` ([635], [645])
* Fix handling of the configuration `files.exclude` ([635], [646])
* Support disabling rules in souces using `eslint-disable` ([630], [642])
* Support including and excluding rules in the `lint` method ([631], [643])
* Execute the command-line tool `denolint` without loading the Node.js VM ([648])
* Allow specifying directories, files and patterns as input for checking

[customisation]: https://github.com/prantlf/node-rs/commits/combined
[original project]: https://github.com/napi-rs/node-rs/tree/main/packages/deno-lint
[630]: napi-rs/node-rs#630
[631]: napi-rs/node-rs#631
[635]: napi-rs/node-rs#635
[642]: napi-rs/node-rs#642
[643]: napi-rs/node-rs#643
[645]: napi-rs/node-rs#645
[646]: napi-rs/node-rs#646
[647]: napi-rs/node-rs#647
[648]: napi-rs/node-rs#648
  • Loading branch information
prantlf committed Sep 28, 2022
0 parents commit 21f0f1f
Show file tree
Hide file tree
Showing 48 changed files with 4,495 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 2
indent_style = space
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
crates
node_modules
target
17 changes: 17 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
parser: '@typescript-eslint/parser'

parserOptions:
ecmaVersion: 2020
sourceType: module

env:
browser: true
es6: true
node: true

plugins:
- import

extends:
- eslint:recommended
- plugin:prettier/recommended
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
Cargo.lock
*.log
node_modules
packages/*/npm
packages/denolint/denolint
packages/libdenolint/index.d.ts
packages/libdenolint/libdenolint.node
target
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpx lint-staged && cargo fmt --all
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.d.ts
crates
node_modules
target
45 changes: 45 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "js tests",
"type": "node",
"request": "launch",
"program": "${file}",
"skipFiles": [
"<node_internals>/**"
]
},
{
"name": "executable",
"type": "lldb",
"request": "launch",
"cargo": {
"args": ["build", "--bin=denolint", "--package=denolint"],
"filter": {
"name": "denolint",
"kind": "bin"
}
},
"args": ["crates/shared/test/fail/ultimate2.js"],
"cwd": "${workspaceFolder}"
},
{
"name": "rust tests",
"type": "lldb",
"request": "launch",
"cargo": {
"args": ["test", "--no-run", "--bin=denolint", "--package=denolint"],
"filter": {
"name": "denolint",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"packages/denolint/denolint": true,
"packages/**/*/*.node": true
},
"search.exclude": {
"**/node_modules": true,
"**/npm": true,
"**/target": true,
"packages/libdenolint/index.d.ts": true
}
}
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cargo-features = ["strip"]

[workspace]
members = ["./packages/denolint", "./packages/libdenolint"]

[profile.release]
codegen-units = 4
lto = true
overflow-checks = false
strip = 'symbols'
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2020-2022 LongYinan
Copyright (c) 2022 Ferdinand Prantl

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# denolint

> Monorepo for calling `deno lint` in Node.js projects using the Rust package [deno_lint].
This project started as fork of a [customised @node-rs/deno-lint], adding the flexibility of `eslint`:

* Scan specific directories ([631], [647])
* Scan directories configured by `files.include` ([635], [645])
* Fix handling of the configuration `files.exclude` ([635], [646])
* Support disabling rules in souces using `eslint-disable` ([630], [642])
* Support including and excluding rules in the `lint` method ([631], [643])
* Execute the command-line tool `denolint` without loading the Node.js VM ([648])
* Offer both synchronous and asynchronous methods ([650])
* Allow specifying directories, files and patterns as input for checking

## Synopsis

Scan sources in two directories on the command line:

npx denolint src test

Check one source file programmatically:

```js
import { readFile } from 'fs/promises'
import { lint } from 'libdenolint'

const filepath = 'src/index.js'
const source = await readFile(filepath)

const warnings = await lint(filepath, source)
for (const warning of warnings) console.warn(warning)
```

## Packages

See more information about the packages and their compatibility with [@node-rs/deno-lint]:

| Project | Package | Description |
| ------------- | ------------------------------------------------------------------- | --------------------------------------------- |
| [denolint] | [![denolint](https://img.shields.io/npm/v/denolint.svg)][cmd] | Deno lint command-line executable for Node.js |
| [libdenolint] | [![libdenolint](https://img.shields.io/npm/v/libdenolint.svg)][lib] | Deno lint library binding for Node.js |

## Support matrix

| Platform | node14 | node16 | node18 |
| ---------------- | ------ | ------ | ------ |
| Windows x64 ||||
| Windows x32 ||||
| Windows arm64 ||||
| MacOS x64 ||||
| MacOS arm64 ||||
| Linux x64 gnu ||||
| Linux x64 musl ||||
| Linux arm gnu ||||
| Linux arm64 gnu ||||
| Linux arm64 musl ||||
| Android arm64 ||||
| Android armv7 ||||
| FreeBSD x64 ||||

[deno_lint]: https://github.com/denoland/deno_lint
[customised @node-rs/deno-lint]: https://github.com/prantlf/node-rs/commits/combined
[@node-rs/deno-lint]: https://github.com/napi-rs/node-rs/tree/main/packages/deno-lint
[denolint]: https://github.com/prantlf/denolint/tree/master/packages/denolint
[cmd]: https://www.npmjs.com/package/denolint
[libdenolint]: https://github.com/prantlf/denolint/tree/master/packages/libdenolint
[lib]: https://www.npmjs.com/package/libdenolint
[630]: https://github.com/napi-rs/node-rs/issues/630
[631]: https://github.com/napi-rs/node-rs/issues/631
[635]: https://github.com/napi-rs/node-rs/issues/635
[642]: https://github.com/napi-rs/node-rs/pull/642
[643]: https://github.com/napi-rs/node-rs/pull/643
[645]: https://github.com/napi-rs/node-rs/pull/645
[646]: https://github.com/napi-rs/node-rs/pull/646
[647]: https://github.com/napi-rs/node-rs/pull/647
[648]: https://github.com/napi-rs/node-rs/issues/648
[650]: https://github.com/napi-rs/node-rs/issues/650
12 changes: 12 additions & 0 deletions crates/alloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "global_alloc"
version = "1.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[target.'cfg(not(target_os = "linux"))'.dependencies]
mimalloc-rust = { version = "0.2" }

[target.'cfg(all(target_os = "linux", not(all(target_env = "musl", target_arch = "aarch64"))))'.dependencies]
mimalloc-rust = { version = "0.2", features = ["local-dynamic-tls"] }
6 changes: 6 additions & 0 deletions crates/alloc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[cfg(all(
not(all(target_os = "linux", target_env = "musl", target_arch = "aarch64")),
not(debug_assertions)
))]
#[global_allocator]
static ALLOC: mimalloc_rust::GlobalMiMalloc = mimalloc_rust::GlobalMiMalloc;
17 changes: 17 additions & 0 deletions crates/shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "shared"
version = "1.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["lib"]

[dependencies]
deno_ast = "0.19.0"
deno_lint = "0.33.0"
ignore = "0.4.18"
miette = { version = "5.3.0", features = ["fancy-no-backtrace"] }
serde = "1.0.145"
serde_json = "1.0.85"

0 comments on commit 21f0f1f

Please sign in to comment.