Skip to content

feat: add types for the @eslint/js package#19010

Merged
mdjermanovic merged 8 commits intomainfrom
feat/rtpes-eslint-js
Nov 1, 2024
Merged

feat: add types for the @eslint/js package#19010
mdjermanovic merged 8 commits intomainfrom
feat/rtpes-eslint-js

Conversation

@snitin315
Copy link
Copy Markdown
Contributor

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain: Add types

What changes did you make? (Give an overview)

Fix #18998

Is there anything you'd like reviewers to focus on?

I have defined eslint as a dependency because of it's usage in types similar to #18938

@eslint-github-bot eslint-github-bot Bot added the feature This change adds a new feature to ESLint label Oct 11, 2024
@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 11, 2024

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 4937c80
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/6724f683ae0a670007fc1322

@snitin315
Copy link
Copy Markdown
Contributor Author

I'm not sure how to fix the trunk check. Looking into it.

@snitin315 snitin315 marked this pull request as ready for review October 11, 2024 07:38
@snitin315 snitin315 requested a review from a team as a code owner October 11, 2024 07:38
Comment thread packages/js/package.json Outdated
@mdjermanovic mdjermanovic added the accepted There is consensus among the team that this change meets the criteria for inclusion label Oct 13, 2024
*/

import type { Linter } from "eslint";
import js from "../../";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
import js from "../../";
import js = require("@eslint/js");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This throws an error because it resolves to the published version inside node_module where types don't exist.

Screenshot 2024-10-26 at 6 12 57 PM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@snitin315 That's weird, that should not be the case, what do you see when you hover over "@eslint/js" in import js = require("@eslint/js")?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same error on hovering too.

Screenshot 2024-10-26 at 6 25 50 PM Even in DefinitelyTyped repo. Screenshot 2024-10-26 at 6 25 00 PM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It should be fine as long as we are pointing to the correct path.

Copy link
Copy Markdown
Contributor

@aryaemami59 aryaemami59 Oct 26, 2024

Choose a reason for hiding this comment

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

I guess then it that case we should have:

import js = require("../../types/index.js");

Another way to fix that is to add this to package.json of @eslint/js:

"devDependencies": {
    "@eslint/js": "file:."
  },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

import js = require("../../types/index.js");

I don't think it should be types because we have ...js.configs.recommended usage below.

"@eslint/js": "file:."

This is the same as import js from "../../";.

@nzakas
Copy link
Copy Markdown
Member

nzakas commented Oct 23, 2024

Please check the lint error.

@snitin315 snitin315 force-pushed the feat/rtpes-eslint-js branch from 1bf25e5 to ba4791a Compare October 26, 2024 12:54
@snitin315 snitin315 force-pushed the feat/rtpes-eslint-js branch from 1ec4222 to 4134281 Compare October 27, 2024 04:14
@snitin315
Copy link
Copy Markdown
Contributor Author

@nzakas @mdjermanovic I've fixed the lint issues and removed eslint as a dependency.

nzakas
nzakas previously approved these changes Nov 1, 2024
Copy link
Copy Markdown
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Would like another review before merging.

Comment thread eslint.config.js Outdated
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Copy link
Copy Markdown
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted There is consensus among the team that this change meets the criteria for inclusion feature This change adds a new feature to ESLint github actions

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

Change Request: Include types for @eslint/js in the package

4 participants