npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

syntax-checker-new

v1.0.1

Published

This package is aimed at providing a basic syntax check for many languages (listed below) to ensure correct syntax.

Downloads

53

Readme

Code Syntax Checker (New)


This package is aimed at providing a basic syntax check for many languages (listed below) to ensure correct syntax.

You do need to install a few things for each one to work on your system. Click on the languages to scroll to point.

Check syntax via string or file!

Supported Languages


Installing

To install this package use the below command. Reference each language below for those steps.

npm i syntax-checker-new

Examples & Usage for checkSyntaxString()

  • codeString: The string of code you wish to validate.
  • language: The language your string of code is. This is the language file extension. For example C++ would be cpp.
  • callback: The functions call back object.
    • passed: Boolean of whether or not the code passed.
    • error: The error code for the syntax error if passed = false. This is currently not used.
checkSyntaxString(codeString, language, function(syntaxReturn){
    console.log(syntaxReturn.passed);
    console.log(syntaxReturn.error);
});

Javascript Example.

const syntaxchecker = require("syntax-checker-new");
let jscode = `console.log(syntaxReturn);`;
syntaxchecker.checkSyntaxString(jscode, "js", function(syntaxReturn){
    console.log(syntaxReturn.passed) // Expected result: true
});

PHP Example.

const syntaxchecker = require("syntax-checker-new");
let phpcode = `<?php echo 'test message; ?>`;
syntaxchecker.checkSyntaxString(phpcode, "php", function(syntaxReturn){
    console.log(syntaxReturn.passed) // Expected result: false (as the quote is not closed)
});

Examples & Usage for checkSyntaxFile()

  • filePath: The file path of the file to check.
  • language: The language your string of code is. This is the language file extension. For example C++ would be cpp.
  • callback: The functions call back object.
    • passed: Boolean of whether or not the code passed.
    • error: The error code for the syntax error if passed = false. This is currently not used.
checkSyntaxFile(filePath, language, function(syntaxReturn){
    console.log(syntaxReturn.passed);
    console.log(syntaxReturn.error);
});

Javascript Example.

const syntaxchecker = require("syntax-checker-new");
let jspath = `/root/test.js`;
syntaxchecker.checkSyntaxFile(jspath, "js", function(syntaxReturn){
    console.log(syntaxReturn.passed)
});

PHP Example.

const syntaxchecker = require("syntax-checker-new");
let phppath = `/root/test.php`;
syntaxchecker.checkSyntaxFile(phppath, "php", function(syntaxReturn){
    console.log(syntaxReturn.passed)
});

Specific Languages

Each language you wish to syntax check may require that language to be installed on your system.

PHP

If you intend to use PHP syntax checking you will need to install PHP on your system. See the PHP website below for instructions.

https://www.php.net/manual/en/install.php

Ruby

To use ruby in syntax checking you need to install Ruby. See the below site for more.

https://www.ruby-lang.org/en/documentation/installation/

Python

To syntax check Python scripts install Python

https://www.python.org/downloads/

Perl

If you want to syntax check Perl, install Perl.

https://www.perl.org/get.html

Lua

If you intend to syntax check for Lua errors you need to have Lua installed

http://www.lua.org/download.html

Bash

Install Bash to syntax check bash scripts.

https://www.gnu.org/software/bash/

C And C++

These use the same program as the languages are very alike. See the below link.

https://gcc.gnu.org/install/

Javascript

You're in luck! Javascript uses node for syntax checking so if you have Node.Js installed (which you likely do) then you're fine!


Support

If you need support create a comment on GitHub or if you use Discord talk to the creator (FAXES & Beefer)

Discord