Get started with jshint CDN

MIT licensed

JSHint: popular tool, identifies, corrects JS coding errors and inconsistencies.

Tags:
  • detect
  • code-analysis

Stable version

Copied!

How to start using jshint CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with jshint CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/jshint/dist/jshint.min.js"></script>
  <script src="https://cdn.cdnhub.io/jshint/2.13.6/jshint.min.js"></script>
  <script>
    const sourceCode = `
      function add(a, b) {
        return a + b;
      }

      function multiply(a, b) {
        return a * b;
      }

      const result = add(multiply(2, 3), 5);
      console.log(result);
    `;

    const options = {
      esversion: 6,
    };

    const ast = JSHINT.parse(sourceCode, options, 'esnext');
    const errors = JSHINT.findErrors(ast);

    if (errors.length > 0) {
      console.log('JSHint Errors:');
      errors.forEach((error) => console.log(error.reason));
    } else {
      console.log('No JSHint Errors');
    }

    try {
      eval(sourceCode);
      console.log('Code executed without errors');
    } catch (error) {
      console.log('Code execution failed:', error.message);
    }
  </script>
</head>
<body></body>
</html>
Copied!
Copied!

All versions