ADVPL Linter
raw JSON → 7.0.3 verified Fri May 01 auth: no javascript
A linting tool for ADVPL (Advanced Protheus Language) source code, providing static analysis and error detection for .prw files. Current stable version is 7.0.3, released with TypeScript support. It integrates directly into Node.js workflows, offering programmatic control through a Linter class. Key differentiators include its focus on the niche ADVPL ecosystem and file-level analysis rather than real-time IDE feedback. Alternative tools are scarce, making this the primary linter for ADVPL developers using Protheus/Totvs environments.
Common errors
error Cannot find module 'advpl-lint' ↓
cause Package not installed or import path incorrect in TypeScript (missing resolution).
fix
Run 'npm install advpl-lint' and ensure tsconfig.json has 'moduleResolution': 'node'.
error TypeError: linter.runAnalisys is not a function ↓
cause Spelling mismatch due to typo in method name 'runAnalisys' (should be 'runAnalysis' in future versions).
fix
Ensure you are calling the exact method name 'runAnalisys' as provided in v7.x. Update package when renamed.
error Error: Invalid file content: expected a string ↓
cause File content passed is not a string (e.g., undefined or Buffer).
fix
Read file synchronously with proper encoding: fs.readFileSync(path, 'latin1').toString() or ensure string.
error TypeError: Cannot read properties of undefined (reading 'errors') ↓
cause Running 'runAnalisys' is async; accessing 'linter.sourceList[0].errors' before promise resolves.
fix
Access errors inside the .then() callback or await the promise.
Warnings
breaking Method name typo: 'runAnalisys' is misspelled (should be 'runAnalysis'). ↓
fix Update to version 8.0.0+ where the method is renamed to 'runAnalysis' or manually call the correct method name.
gotcha File encoding must be 'latin1' (ISO-8859-1) for ADVPL files; UTF-8 may cause incorrect parsing. ↓
fix Always read files with encoding 'latin1' (e.g., fs.readFileSync(path, 'latin1')).
gotcha The Linter constructor expects an array of objects with 'name' and 'content' properties; omitting either will cause runtime errors. ↓
fix Provide exactly { name: string, content: string } for each file.
deprecated The 'sourceList' property may be deprecated in future versions; use the return value of 'runAnalisys' instead. ↓
fix Access errors directly from the promise result or via a new API if introduced.
Install
npm install advpl-lint yarn add advpl-lint pnpm add advpl-lint Imports
- Linter wrong
const Linter = require('advpl-lint').Lintercorrectimport { Linter } from 'advpl-lint' - Linter
import type { Linter } from 'advpl-lint' - default import wrong
const advplLint = require('advpl-lint')correctimport advplLint from 'advpl-lint'
Quickstart
import { Linter } from 'advpl-lint';
import * as fs from 'fs';
const content = fs.readFileSync('file.prw', 'latin1');
const linter = new Linter([{
name: 'file.prw',
content: content,
}]);
linter.runAnalisys().then(() => {
console.log(linter.sourceList[0].errors);
});