@fullstackcraftllc/syntax-spy
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

syntax-spy

Simultaneously detect and syntax check any code snippet with ease.

syntax-spy is a powerful TypeScript / JavaScript tool that combines the powers of vscode-languagedetection , ts-morph, and a variety of other AST and linting tools to simultaneously identify and syntax check any snippet of code.

Installation

npm install @fullstackcraftllc/syntax-spy

Usage

import { identifyAndValidateCode } from '@fullstackcraftllc/syntax-spy';

const code = `
// here's a comment in TypeScript
const testFunction = (someParam: string) => {
    const myStringArray: string[] = ['Hello', 'World'];
    console.log(someParam); 
    blahblahsomesyntaxerror
}
`;

async function main() {
    try {
        const { language, isValid, error } = await identifyAndValidateCode(code);
        if (error) {
            console.error('Error:', error);
        } else {
            console.log('Detected language:', language);
            console.log('Syntax is valid:', isValid);
        }
    } catch (error) {
        console.error('Error:', error);
    }
}

main();

TODOs

  • Add support for more programming languages.

Package Sidebar

Install

npm i @fullstackcraftllc/syntax-spy

Weekly Downloads

6

Version

1.0.4

License

MIT

Unpacked Size

15.8 kB

Total Files

15

Last publish

Collaborators

  • fullstackcraftllc