mirror of
https://github.com/napi-rs/node-rs.git
synced 2026-10-28 11:04:33 +08:00
feat(denolint): upgrade denolint crate (#762)
This commit is contained in:
1 parent
5cf454d338
commit
19b888c2bd
8 files changed
+51
-13
No files matched your search
@@ -13,3 +13,4 @@ packages/*/*.wasi.cjs
|
||||
packages/*/wasi-worker.mjs
|
||||
packages/*/index.js
|
||||
packages/*/index.d.ts
|
||||
packages/bcrypt/binding.js
|
||||
+5
-1
@@ -3,6 +3,10 @@ node_modules
|
||||
lib
|
||||
.yarn
|
||||
yarn.lock
|
||||
packages/*/*.wasi.js
|
||||
packages/*/*.wasi.cjs
|
||||
packages/*/index.js
|
||||
packages/*/browser.js
|
||||
packages/*/wasi-worker*
|
||||
packages/*/index.d.ts
|
||||
packages/*/binding.js
|
||||
packages/*/binding.d.ts
|
||||
@@ -23,7 +23,7 @@ test('genSalt should return a string', async (t) => {
|
||||
t.is(typeof (await genSalt(10, '2b')), 'string')
|
||||
t.is(typeof (await genSalt(10, '2y')), 'string')
|
||||
t.is(typeof (await genSalt(10, '2x')), 'string')
|
||||
await t.throwsAsync(async () => genSalt(10, 'invalid' as any))
|
||||
t.throws(() => genSalt(10, 'invalid' as any))
|
||||
})
|
||||
|
||||
test('verifySync hashed password from bcrypt should be true', (t) => {
|
||||
|
||||
@@ -8,10 +8,10 @@ version = "0.1.0"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
annotate-snippets = { version = "0.9", features = ["color"] }
|
||||
annotate-snippets = { version = "0.10" }
|
||||
anyhow = "1"
|
||||
deno_ast = "=0.31.6"
|
||||
deno_lint = "=0.52.2"
|
||||
deno_ast = "=1.0.1"
|
||||
deno_lint = "=0.53.0"
|
||||
env_logger = "0.10"
|
||||
global_alloc = { path = "../../crates/alloc" }
|
||||
globwalk = "0.9"
|
||||
|
||||
@@ -12,7 +12,7 @@ class LintCommand extends Command {
|
||||
|
||||
private readonly checkOnly = Option.Boolean('--check-only', { required: false })
|
||||
|
||||
async execute() {
|
||||
execute() {
|
||||
const hasError = denolint(this.cwd ?? __dirname, this.configPath ?? '.denolint.json')
|
||||
return Promise.resolve(hasError && !this.checkOnly ? 1 : 0)
|
||||
}
|
||||
|
||||
@@ -298,6 +298,20 @@ switch (platform) {
|
||||
}
|
||||
}
|
||||
break
|
||||
case 's390x':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'deno-lint.linux-s390x-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./deno-lint.linux-s390x-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@node-rs/deno-lint-linux-s390x-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use std::path::Path;
|
||||
use std::str;
|
||||
|
||||
use deno_ast::MediaType;
|
||||
use deno_lint::linter::LintFileOptions;
|
||||
use deno_lint::linter::LinterBuilder;
|
||||
use deno_lint::rules::{get_all_rules, get_recommended_rules};
|
||||
use ignore::overrides::OverrideBuilder;
|
||||
@@ -56,7 +57,6 @@ fn lint(
|
||||
},
|
||||
None => get_recommended_rules(),
|
||||
})
|
||||
.media_type(get_media_type(Path::new(file_name.as_str())))
|
||||
.ignore_diagnostic_directive("eslint-disable-next-line")
|
||||
.build();
|
||||
|
||||
@@ -71,7 +71,11 @@ fn lint(
|
||||
};
|
||||
|
||||
let (s, file_diagnostics) = linter
|
||||
.lint(file_name.clone(), source_string.to_owned())
|
||||
.lint_file(LintFileOptions {
|
||||
media_type: get_media_type(Path::new(file_name.as_str())),
|
||||
filename: file_name.clone(),
|
||||
source_code: source_string.to_owned(),
|
||||
})
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
Status::GenericFailure,
|
||||
@@ -171,17 +175,18 @@ fn denolint(__dirname: String, config_path: String) -> Result<bool> {
|
||||
|
||||
let linter = LinterBuilder::default()
|
||||
.rules(rules.clone())
|
||||
.media_type(get_media_type(p))
|
||||
.ignore_file_directive("eslint-disable")
|
||||
.ignore_diagnostic_directive("eslint-disable-next-line")
|
||||
.build();
|
||||
let (s, file_diagnostics) = linter
|
||||
.lint(
|
||||
p.to_str()
|
||||
.lint_file(LintFileOptions {
|
||||
source_code: file_content,
|
||||
filename: p
|
||||
.to_str()
|
||||
.ok_or_else(|| Error::from_reason(format!("Convert path to string failed: {:?}", &p)))?
|
||||
.to_owned(),
|
||||
file_content.clone(),
|
||||
)
|
||||
media_type: get_media_type(p),
|
||||
})
|
||||
.map_err(|e| {
|
||||
Error::new(
|
||||
Status::GenericFailure,
|
||||
|
||||
@@ -298,6 +298,20 @@ switch (platform) {
|
||||
}
|
||||
}
|
||||
break
|
||||
case 's390x':
|
||||
localFileExisted = existsSync(
|
||||
join(__dirname, 'jsonwebtoken.linux-s390x-gnu.node')
|
||||
)
|
||||
try {
|
||||
if (localFileExisted) {
|
||||
nativeBinding = require('./jsonwebtoken.linux-s390x-gnu.node')
|
||||
} else {
|
||||
nativeBinding = require('@node-rs/jsonwebtoken-linux-s390x-gnu')
|
||||
}
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user