Skip to content

Use ESLint on JavaScript #1890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: gh-pages
Choose a base branch
from

Conversation

bdkopen
Copy link
Contributor

@bdkopen bdkopen commented May 1, 2025

  • Updates the test script to run on JS files.
  • Whitelists browser and jquery as environments so their variables are seen as defined.
  • Resolves all the ESLint errors.

Copy link

netlify bot commented May 1, 2025

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit b04cb65
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/684593b1af2a940008662663
😎 Deploy Preview https://deploy-preview-1890--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

package.json Outdated
@@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
"test": "eslint --ignore-path .gitignore --ignore-pattern _includes/readmes/ \"**/*.md\""
"test": "eslint . --ignore-path .gitignore --ignore-pattern _includes/readmes/ \"**/*.md\""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the ., ESLint doesn't actually run on any files.

@bdkopen bdkopen marked this pull request as ready for review May 1, 2025 22:44
@bdkopen bdkopen requested review from a team as code owners May 1, 2025 22:44
Copy link
Member

@ShubhamOulkar ShubhamOulkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bdkopen, thank you for taking up this issue. Overall, the changes looks good! However, I would suggest moving the eslintConfig section from package.json into a separate file.

@bdkopen bdkopen force-pushed the fix-eslint-test branch from 01cd4b4 to 4c5af70 Compare May 15, 2025 01:29
@bdkopen
Copy link
Contributor Author

bdkopen commented May 15, 2025

Hi @bdkopen, thank you for taking up this issue. Overall, the changes looks good! However, I would suggest moving the eslintConfig section from package.json into a separate file.

I moved the ESLint config into a new file. I responded to your other comments as well. Thanks for reviewing!

@bdkopen bdkopen requested a review from ShubhamOulkar May 15, 2025 01:40
Copy link
Member

@ShubhamOulkar ShubhamOulkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you for suggesting those options. Switching to ESLint's default configuration instead of eslint-config-standard makes sense, and updating ESLint to 9.x in a separate PR is a good approach.
Let's see if other team members have additional suggestions on this approach

@bdkopen
Copy link
Contributor Author

bdkopen commented May 21, 2025

I fixed the test command so both Markdown and JS files are linted. Please let me know if there's anything else you'd like done in this PR.

Copy link
Member

@ctcpip ctcpip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the very least, we still should have semicolons in code

@bdkopen
Copy link
Contributor Author

bdkopen commented May 21, 2025

at the very least, we still should have semicolons in code

Sure, I added a rule that overrides the standard default no semicolon rule.

@bdkopen bdkopen requested a review from ctcpip May 21, 2025 23:58
@ctcpip
Copy link
Member

ctcpip commented May 22, 2025

oh... I didn't realize there would be so many missing semicolons. to unblock this, what we would ask is to change the configured rules such that the minimal amount of code change via --fix would apply. we don't want to blow up the git history right away. (maybe in the future though)

in other words, let's focus this PR so that linting is executing, but let's not change rules/files as part of it. or if that is not possible, which is understandable, this will need to wait till we resolve our future direction on linting

@bdkopen bdkopen force-pushed the fix-eslint-test branch from 61bf883 to d518250 Compare May 22, 2025 01:54
@bdkopen
Copy link
Contributor Author

bdkopen commented May 22, 2025

@ctcpip I dropped the commit enforcing semicolons. Without modifying the lint rules, the linting will remove semicolons in a few files since that is what the standard config defines.

This PR can be focused on requiring linting execution as long you're comfortable with enforcing the existing rules. If we don't want to enforce the existing rules, it seems like this PR will be blocked until the direction of linting is determined.

@bjohansebas
Copy link
Member

I think you could make it so that only JavaScript files have semicolons, and markdown files don’t have semicolons.

@bdkopen bdkopen force-pushed the fix-eslint-test branch from d518250 to bd4386c Compare May 31, 2025 13:12
@bdkopen bdkopen force-pushed the fix-eslint-test branch from bd4386c to 703282f Compare May 31, 2025 13:14
@bdkopen
Copy link
Contributor Author

bdkopen commented May 31, 2025

I think you could make it so that only JavaScript files have semicolons, and markdown files don’t have semicolons.

@bjohansebas that seems like a good intermediate solution. Updated!

@bdkopen bdkopen changed the title Fix ESLint Test Use ESLint on JavaScript Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants