Skip to content

Conversation

@mdjermanovic
Copy link
Member

Prerequisites checklist

What is the purpose of this pull request?

Simplifies the way eslint-scope and espree are exporting version.

What changes did you make? (Give an overview)

Removed prepublish step that updates version, and configured release-please to update it similar to how we're doing that in other projects (eslint/rewrite, eslint/json, eslint/markdown, eslint/css). Also added tests that should catch any problems with this when we manage to run CI on release-please PRs (#713).

Related Issues

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

"scripts": {
"build": "rollup -c",
"build:update-version": "node tools/update-version.js",
"prepublishOnly": "npm run build:update-version && npm run build",
Copy link
Member Author

Choose a reason for hiding this comment

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

We're already running build before publishing:

- run: |
npm install
npm run build
if: ${{ steps.release.outputs.releases_created == 'true' }}

@fasttime fasttime moved this from Needs Triage to Triaging in Triage Dec 19, 2025
@fasttime fasttime moved this from Triaging to Implementing in Triage Dec 19, 2025
@lumirlumir lumirlumir self-requested a review December 19, 2025 09:12
Comment on lines +12 to +19
import { fileURLToPath } from "node:url";
import path from "node:path";
import fs from "node:fs";

// eslint-disable-next-line no-underscore-dangle -- Conventional
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const { version } = JSON.parse(fs.readFileSync(`${__dirname}/../package.json`, "utf8"));
Copy link
Member

Choose a reason for hiding this comment

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

A note that this could be simplified:

Suggested change
import { fileURLToPath } from "node:url";
import path from "node:path";
import fs from "node:fs";
// eslint-disable-next-line no-underscore-dangle -- Conventional
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const { version } = JSON.parse(fs.readFileSync(`${__dirname}/../package.json`, "utf8"));
import packageJson from "../package.json" with { type: "json" };
const { version } = packageJson;

Or, similarly:

Suggested change
import { fileURLToPath } from "node:url";
import path from "node:path";
import fs from "node:fs";
// eslint-disable-next-line no-underscore-dangle -- Conventional
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const { version } = JSON.parse(fs.readFileSync(`${__dirname}/../package.json`, "utf8"));
const { default: { version } } = await import("../package.json", { with: { type: "json" } });

Per https://nodejs.org/api/esm.html#import-attributes, import attributes have been supported since Node.js v20.10.0.

Comment on lines +12 to +19
import path from "node:path";
import fs from "node:fs";
import assert from "node:assert";

// eslint-disable-next-line no-underscore-dangle -- Conventional
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const { version } = JSON.parse(fs.readFileSync(`${__dirname}/../../package.json`, "utf8"));
Copy link
Member

Choose a reason for hiding this comment

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

Same note as #714 (comment).

Copy link
Member

@lumirlumir lumirlumir 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! I don't have any further comments.

(I didn't move it to second review needed since there are pending comments.)

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

Projects

Status: Implementing

Development

Successfully merging this pull request may close these issues.

4 participants