@noshift.js/lint
v0.1.0
Published
A linter for NoShift.js (.nsjs) files
Downloads
27
Readme
@noshift.js/lint
English | 日本語
A linter for NoShift.js (.nsjs) files
[!Important]
⚠ Breaking Changes (v0.1.0): Syntax changes in NoShift.js v0.15.0 —^3is now#,^6is now Capitalize,^\is now_. New keyword aliases:or,and,@or,@and.
Installation
npm install -D @noshift.js/lintOr globally:
npm install -g @noshift.js/lintCLI Usage
# Lint all .nsjs files in rootdir (reads nsjsconfig.json)
nslint
# Lint specific files
nslint src/index.nsjs src/utils.nsjs
# Create nsjslinter.json with default rules
nslint init| Command | Alias | Description |
|---|---|---|
| nslint | | Lint all .nsjs files in rootdir |
| nslint <file> [file...] | | Lint specific files |
| nslint init | nslint create | Create nsjslinter.json with defaults |
| nslint version | nslint -v | Show version |
| nslint help | nslint -h | Show help |
Configuration
Create a nsjslinter.json at the project root (or run nslint init):
{
"rules": {
"unclosed-string": "error",
"unclosed-comment": "error",
"unclosed-template-expr": "error",
"unknown-caret-sequence": "error",
"lone-caret": "error",
"capitalize-eof": "error",
"uppercase-in-code": "warning",
"trailing-whitespace": "off",
"no-consecutive-blank-lines": "off"
}
}Each rule can be set to "error", "warning", or "off".
Rules
| Rule | Default | Description |
|---|---|---|
| unclosed-string | error | Unclosed string literal (^2, ^7, ^@) |
| unclosed-comment | error | Unclosed block comment (/^:...^:/) |
| unclosed-template-expr | error | Unclosed template expression (^4^[...^]) |
| unknown-caret-sequence | error | Unknown ^X sequence |
| lone-caret | error | Lone ^ at end of file |
| capitalize-eof | error | ^6 at end of file with no character to capitalize |
| uppercase-in-code | warning | Uppercase letter in code (use ^6 instead) |
| trailing-whitespace | off | Trailing whitespace at end of line |
| no-consecutive-blank-lines | off | Consecutive blank lines |
Programmatic API
ESM
import { lint, createDefaultConfig, getRuleNames } from "@noshift.js/lint";
const messages = lint(source);
for (const m of messages) {
console.log(`${m.line}:${m.column} [${m.severity}] ${m.message} (${m.rule})`);
}CJS
const { lint, createDefaultConfig, getRuleNames } = require("@noshift.js/lint");
const messages = lint(source);
for (const m of messages) {
console.log(`${m.line}:${m.column} [${m.severity}] ${m.message} (${m.rule})`);
}API Reference
| Function | Description |
|---|---|
| lint(source, config?) | Lint source code. Returns { line, column, message, severity, rule }[] |
| createDefaultConfig() | Returns a default nsjslinter.json config object |
| getDefaultRules() | Returns the default rules map |
| getRuleNames() | Returns an array of all rule names |
| loadConfigSync(path) | Load and parse a nsjslinter.json file |
Ecosystem / Links
- noshift.js (npm) — The Core Compiler CLI
- @noshift.js/lint (npm) — The Official Linter
- prettier-plugin-noshift.js (npm) — The Official Prettier Plugin
- VS Code Extension — Editor Support (Syntax Highlighting, Snippets)
- Website & Playground
- Repository
License
MIT © otoneko.
