Skip to content
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

Add support for *-deprecation command-line flags of Node.js #7550

Conversation

fpetrakov
Copy link
Contributor

Which issue, if any, is this issue related to?

Closes #7533

Is there anything in the PR that needs further explanation?

No, it's self-explanatory.

Copy link

changeset-bot bot commented Mar 10, 2024

🦋 Changeset detected

Latest commit: 47c57d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
stylelint Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@fpetrakov fpetrakov requested a review from ybiquitous March 10, 2024 18:40
lib/augmentConfig.mjs Outdated Show resolved Hide resolved
rollup.config.mjs Outdated Show resolved Hide resolved
lib/augmentConfig.mjs Outdated Show resolved Hide resolved
Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

@fpetrakov Thanks for the pull request!

As @Mouvedia commented, 'DeprecationWarning' is required to affect the *-deprecation CLI flags of Node.js. Can you address the comment, please?

Ref https://nodejs.org/api/process.html#event-warning

lib/__tests__/standalone-deprecations.test.mjs Outdated Show resolved Hide resolved
lib/augmentConfig.mjs Outdated Show resolved Hide resolved
@ybiquitous ybiquitous changed the title Use process.emitWarning() instead of console.warn() Add support for the *-deprecation command-line flags of Node.js Mar 11, 2024
@ybiquitous ybiquitous changed the title Add support for the *-deprecation command-line flags of Node.js Add support for *-deprecation command-line flags of Node.js Mar 11, 2024
@Mouvedia
Copy link
Member

Mouvedia commented Mar 14, 2024

If we can settle on

  • whether sentences should end with a period
  • if the arbitrary order that I have chosen for the codes is fine

then this PR could be merged.

@ybiquitous
Copy link
Member

ybiquitous commented Mar 14, 2024

@Mouvedia Thanks for the good points 👍🏼

I think having a period is better as the Node.js API does:

$ node -e "new Buffer('')" --throw-deprecation
node:internal/process/warning:185
        throw warning;
        ^

DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    at showFlaggedDeprecation (node:buffer:188:11)
    at new Buffer (node:buffer:266:3)
    at [eval]:1:1
    at runScriptInThisContext (node:internal/vm:209:10)
    at node:internal/process/execution:109:14
    at [eval]-wrapper:6:24
    at runScript (node:internal/process/execution:92:62)
    at evalScript (node:internal/process/execution:123:10)
    at node:internal/main/eval_string:51:3 {
  code: 'DEP0005'
}

Node.js v21.7.1

Also, I'm fine if the code order is like stylelint:001, stylelint:002, ... 👍🏼

Ref https://nodejs.org/api/deprecations.html


Besides, although it is not required, adding a utility might be helpful, e.g.

const CODES = {
  '001': {message: 'Message 1', detail: '...'},
  '002': {message: 'Message 2'},
  // ...
};

/**
 * @param {keyof CODES} code
 */
function emitDeprecation(code) {
  const {message, detail} = CODES[code];
  process.emitWarning(message, {type: 'DeprecationWarning', code: `stylelint:${code}`, detail});
}

@Mouvedia
Copy link
Member

I think having a period is better as…

The suggestions have been updated.

I'm fine if the code order…

OK

@Mouvedia
Copy link
Member

Mouvedia commented Mar 15, 2024

@fpetrakov @ybiquitous npm build needs to be run again and the tests need to be updated after the code review suggestions commit.

@fpetrakov fpetrakov force-pushed the use-process-emit-warning-instead-of-console-warn branch from 7e5c3cd to 500bd8f Compare March 15, 2024 12:18
@fpetrakov fpetrakov requested a review from ybiquitous March 15, 2024 12:33
Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

@fpetrakov Sorry for the late response, and thank you for addressing the reviews!
I've pushed a commit (47c57d1) about the code style, but it's a trivial change.

LGTM 👍🏼

@ybiquitous
Copy link
Member

@Mouvedia Do you have any thoughts left?

Copy link
Member

@Mouvedia Mouvedia left a comment

Choose a reason for hiding this comment

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

@Mouvedia Do you have any thoughts left?

Maybe add a task to #7396 that says we need to run tests using --throw-deprecation before releasing. For the rest it LGTM.

@ybiquitous
Copy link
Member

Maybe add a task to #7396 that says we need to run tests using --throw-deprecation before releasing.

Sounds good. Can you open an issue and add it to the list?

@ybiquitous ybiquitous merged commit a02e4dd into stylelint:main Mar 19, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Use process.emitWarning() instead of console.warn()
3 participants