[P3A Documentation — Do Not Merge] JSHint Static Analysis Integration#70
Open
[P3A Documentation — Do Not Merge] JSHint Static Analysis Integration#70
Conversation
Author
Why This PR ExistsThe original implementation of this work was merged into This new PR is opened from the original |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR exists solely as documentation of a completed Project 3A deliverable.
The original implementation was merged in #63 and subsequently reverted from main via revert commit b8bc637 because our team decided to integrate only one tool for Project 3B. Per TA guidance, we are preserving this branch as an open, non-merging PR for grading and documentation purposes.
What This PR Does
Resolves: #64
NodeBB already lists
jshintas a devDependency but it was never configured or wired up. This PR completes that integration by adding the necessary config files and an npm script so developers can run it locally.JSHint flags suspicious JavaScript patterns — catching issues like undeclared variables, accidental
==instead of===, and unused variables before they reach production.Files Changed
package.json"lint:jshint": "jshint ."to the scripts sectionjshint ^2.13.6was already present in devDependencies — no new package needed.jshintrc(new)esversion: 6,node: true,browser: truefor NodeBB's mixed environmentundef: true,unused: true,eqeqeq: true,curly: trueindent: 2andmaxlen: 100.jshintignore(new)node_modules/,dist/, andcoverage/How to Run
The existing
npm run lint(ESLint) is unchanged.Evidence of Execution
jshint-output.txtwas generated by runningnpm run lint:jshinton the fullrepository. See the full output at:
https://github.com/CMU-313/nodebb-spring-26-team-4/blob/main/jshint-output.txt
Tool Analysis (Project 3B)
What is JSHint?
A community-driven static analysis tool for JavaScript. It scans source code without executing it, flagging suspicious patterns, style violations, and potential bugs based on configurable rules.
Analysis Type
Static — no tests or runtime needed.
What It Caught on This Repo (1,424 JS files)
==instead of===(type coercion risk)*See False Positives section below.
Pros
==vs===bugs and 88 missing curly brace risksCons
--fix, all violations require manual remediationFalse Positives & Negatives
False positives (significant): 11,730 undefined variable warnings stem from
NodeBB's client-side globals (
socket,ajaxify,app,config) not beingdeclared in
.jshintrc. Another 5,823 ES version warnings appear because configis set to
esversion: 6while the codebase uses ES8+ (async/await).False negatives: JSHint won't catch runtime logic errors, async/Promise
mistakes, complex type bugs, or security vulnerabilities.
True positives we may not act on: The 17,903 line length violations are
technically real but have no auto-fix and may not reflect team standards —
they create noise that buries more actionable warnings.
Customization Notes
Critical (must fix before trusting output):
esversionto at least8to stop async/await false positivesglobalsblock to.jshintrcfor NodeBB's client-side globalsIncremental improvements:
maxlengiven NodeBB's existing stylemaxcomplexityover time/* jshint ignore:line */for known acceptable exceptionsRecommended Integration Strategy
Given 17,000+ existing issues, a gradual adoption approach makes most sense:
==/===and undeclared variable issues