Skip to content

Blazing fast linter for JavaScript and TypeScript written in Rust.

License

Notifications You must be signed in to change notification settings

prantlf/denolint

Repository files navigation

denolint

Monorepo for calling deno lint in Node.js projects using the Rust package deno_lint.

A lot faster than eslint, handling both JavaScript and TypeScript sources. Use rollup-plugin-denolint for Rollup. Use esbuild-plugin-denolint for esbuild. Use webpack-loader-denolint for Webpack. Or simpler, just the command-line denolint.

This project started as fork of a customised @node-rs/deno-lint, adding the flexibility of eslint:

  • Scan specific directories with specific ignore patterns (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
  • Print warning messages in pretty or compact formats
  • Explain a rule or list all supported rules on the console

Synopsis

Scan sources in two directories on the command line:

$ npx denolint src test

no-var

× `var` keyword is not allowed.
╭─[src/index.js:3:3]
3 │ export function answer() {
4 │   var answer = 42
·   ───────────────
5 │   return answer
╰────
help: https://lint.deno.land/#no-var

Check one source file programmatically:

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 Deno lint command-line executable for Node.js
libdenolint libdenolint 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

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Publishing

This is for me :-)

Upgrading:

cd packages/libdenolint
ncu -u
pnpm i
cd ../..
ncu -u
pnpm i
cargo update
cargo upgrade --incompatible
pnpm run lint
cargo fmt --all
cargo clippy -- -D warnings
cargo outdated --exit-code 1
cargo audit
cargo pants

cd packages/denolint
npm run build
npm run test:other
cd ../libdenolint
npm run build
npm run test:other

Change directory to packages/denolint and/or packages/libdenolint depending on what packages you want to publish and run:

npm version --no-git-tag-version X.Y.Z

Consolidate CHANGELOG.md and commit the changes with one of the following messages, depending on what packages you want to publish:

g c -am 'chore(release): publish both X.Y.Z'
g c -am 'chore(release): publish denolint X.Y.Z'
g c -am 'chore(release): publish libdenolint X.Y.Z'
g t vX.Y.Z
g p
and create a GitHub release

License

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

Licensed under the MIT license.