A local web tool for linting and formatting Rhino JavaScript code with ESLint and js-beautify, using a few specialized rules created Provenir problems.
- Install Node.js from (Download here)
- Clone repository: https://github.com/timothyjmorris/provenir-linter.git
- Open terminal/command prompt in that folder
- Install Dependencies, run:
npm install - Start the
Expressserver, run:npm start - Bookmark
http://localhost:3000andhttp://localhost:3000/style-guide
To stop the server, press Ctrl+C in the terminal.
- Paste your code into the left panel
- Click "Lint & Format" button (or press
Ctrl+Enter) - Review issues in the results panel below
- Copy formatted code from the right panel back to Provenir
- Check Style Guide for MAC team specific best practices
- Full
ESLintintegration with custom rules js-beautifyformatting with tab indentation- Custom Provenir rules for platform-specific quirks
- Side-by-side code comparison using
CodeMirror - Detailed issue descriptions with links to documentation
- Auto-fix indicators & summary
- Integrated Style Guide with Provenir best practices
- Responsive design (works on any screen size)
- Keyboard shortcuts (Ctrl+Enter to format)
- One-click copy to clipboard
This linter includes special rules for Provenir quirks:
-
provenir/prefer-loose-equality-for-isnull(error)- Custom
eqeqeqrule that enforces==instead of===forProvenir.isNull()comparisons (and allows null comparisons and typeof checks) - Auto-fixes
===to==
- Custom
-
provenir/require-comparison-for-isnull(warning)- Require explicit == true or == false comparison for Provenir.isNull()
-
provenir/no-direct-script-return-coercion(warning)- Warns against direct type coercion on script returns
- Example:
Number(config.Business_Logic...())should be offloaded first
-
provenir/no-unused-vars-except-main(error)- Ignores outter function wrapper required by Provenir scripts
-
provenir/eqeqeq-except-provenir- Require === except for Provenir.isNull() comparisons
-
provenir/require-return-statement- Require all wrapper and child functions to have a
return.
- Require all wrapper and child functions to have a
-
And a bonus function
convertQuotesToDouble()inserver.js- Converts single quotes to double quotes
- Preserves single quotes inside strings (for XPath, etc.)
- Runs after beautification
- The server runs locally on your machine (no internet required after setup)
- Your code never leaves your computer
- All formatting/linting happens instantly
- Works with all Provenir-specific globals (Provenir, DocumentHelper, config, etc.)
- Tab indentation per your style guide
- Enforces MAC team best practices automatically
- Blank line preservation: js-beautify automatically pads blank lines with 4 spaces to ensure Provenir Studio preserves visual spacing when you paste formatted code
Port already in use? or can't start?
- Run
Stop-Process -Name node -Force 2>$null; Start-Sleep -Seconds 1; npm start - Change the PORT in
server.js(line 13) to something else like 3001
Can't connect?
- Make sure the server is running (
npm start) - Check you're going to the correct URL (
http://localhost:3000)
Installation errors?
- Make sure you have Node.js 18 or higher:
node --version - Try deleting
node_modulesfolder and runningnpm installagain
To update ESLint rules or beautify settings:
- Edit
eslint.config.mjsor.jsbeautifyrc - Edit custom Provenir rules in
eslint-rules/provenir-rules.js - Update style guide in
style-guide.md - Restart the server (
Ctrl+Cthennpm start) - Refresh the browser
Made with ❤️ for the MAC team