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

Fix SyntaxError: The requested module 'table'... #8325

Merged
merged 3 commits into from
Jan 25, 2025

Conversation

denisx
Copy link
Contributor

@denisx denisx commented Jan 16, 2025

Vendor "table" not work with default import at mjs.
Fixed to named import

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link

changeset-bot bot commented Jan 16, 2025

🦋 Changeset detected

Latest commit: 3b8f8cb

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

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

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

4: { alignment: 'left', width: columnWidths[4], paddingRight: 0 },
},
drawHorizontalLine: () => false,
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this file: auto format

@@ -1,9 +1,9 @@
import { relative, sep } from 'node:path';
import process from 'node:process';

import { getBorderCharacters, table } from 'table';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes 1: import

wrapWord: messageWidth > 1 && !hasNonAsciiChar,
},
4: { alignment: 'left', width: columnWidths[4], paddingRight: 0 },
output += table(cleanedMessages, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes 2: use currenct func

},
4: { alignment: 'left', width: columnWidths[4], paddingRight: 0 },
output += table(cleanedMessages, {
border: getBorderCharacters('void'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes 3: use currenct func

4: { alignment: 'left', width: columnWidths[4], paddingRight: 0 },
},
drawHorizontalLine: () => false,
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

other: auto format

@jeddy3 jeddy3 changed the title Fix: "table" imports not work at mjs Fix table imports for ESM Jan 17, 2025
@jeddy3
Copy link
Member

jeddy3 commented Jan 17, 2025

@denisx Thank you for wanting to contribute to Stylelint.

Please can you open a bug report so that we can better understand what this PR fixes, particularly the questions around the reproducible steps and the outcome you get (e.g. error messages).

@denisx
Copy link
Contributor Author

denisx commented Jan 17, 2025

jeddy3 check other stylelint code - this 'table' import writen identically. but not at this file

@jeddy3
Copy link
Member

jeddy3 commented Jan 21, 2025

jeddy3 check other stylelint code - this 'table' import writen identically. but not at this file

@denisx Am I right in thinking this is a refactor to use named exports rather than a fix?

Vendor "table" not work with default import at mjs.

If it's a fix, please provide the error message you're getting and the reproducible steps.

This will help correctly write and categorise the changeset entry.

@denisx
Copy link
Contributor Author

denisx commented Jan 21, 2025

stylelint "**/*.css" --allow-empty-input --ignore-path .gitignore --ignore-path .stylelintignore
file:///Users/ ... /node_modules/stylelint/lib/formatters/stringFormatter.mjs:6
import table from 'table';
       ^^^^^
SyntaxError: The requested module 'table' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
    at async standalone (file:///Users/ ... /node_modules/stylelint/lib/standalone.mjs:96:23)

@jeddy3
Copy link
Member

jeddy3 commented Jan 21, 2025

@denisx Thank you for the error message.

In your project directory, can you also run:

npm list table stylelint

Do you have "type": "module" in your package.json?

@denisx
Copy link
Contributor Author

denisx commented Jan 21, 2025

Screenshot 2025-01-21 at 15 16 19

@jeddy3
Copy link
Member

jeddy3 commented Jan 21, 2025

@denisx Do you get the error on the latest version of Stylelint?

npm i stylelint@latest

I'm unable to replicate the error locally with stylelint@16.8.1. However, I assume it has something to do with local project configuration and perhaps the change introduced to table in gajus/table#227.

As named exports is the documented way to use table, I think we'll want to merge the change. Just need to gather some more information to know if this needs a changeset entry or not.

@jeddy3 jeddy3 changed the title Fix table imports for ESM Fix The requested module 'table' does not provide an export named 'default' syntax error Jan 25, 2025
@jeddy3 jeddy3 changed the title Fix The requested module 'table' does not provide an export named 'default' syntax error Fix SyntaxError: The requested module 'table'... Jan 25, 2025
Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

Approving and merging for the upcoming release as:

  • it aligns with the package's docs
  • is consistent with how we use the package in the TIMING feature
  • likely fixes a syntax error in some combination of a local environment or set of packages

@jeddy3 jeddy3 merged commit f24921c into stylelint:main Jan 25, 2025
17 checks passed
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Jan 26, 2025
| datasource | package   | from    | to      |
| ---------- | --------- | ------- | ------- |
| npm        | stylelint | 16.13.0 | 16.14.0 |


## [v16.14.0](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16140---2025-01-25)

It fixes 8 bugs and adds features to our `Warning` type.

-   Added: replaced text and corresponding range to `Warning` type ([#8234](stylelint/stylelint#8234)) ([@romainmenke](https://github.com/romainmenke)).
-   Fixed: `SyntaxError: The requested module 'table'...` ([#8325](stylelint/stylelint#8325)) ([@denisx](https://github.com/denisx)).
-   Fixed: `RuleContext['fix']` type ([#8309](stylelint/stylelint#8309)) ([@Mouvedia](https://github.com/Mouvedia)).
-   Fixed: `declaration-property-value-keyword-no-deprecated` autofix of `border-color` and `overflow` ([#8346](stylelint/stylelint#8346)) ([@Mouvedia](https://github.com/Mouvedia)).
-   Fixed: `declaration-property-value-keyword-no-deprecated` false negatives for `overflow-x` and `overflow-y` ([#8340](stylelint/stylelint#8340)) ([@Mouvedia](https://github.com/Mouvedia)).
-   Fixed: `declaration-property-value-keyword-no-deprecated` false negatives for `scrollbar-color` ([#8346](stylelint/stylelint#8346)) ([@Mouvedia](https://github.com/Mouvedia)).
-   Fixed: `declaration-property-value-keyword-no-deprecated` false positives for non-standard syntax values ([#8329](stylelint/stylelint#8329)) ([@Mouvedia](https://github.com/Mouvedia)).
-   Fixed: `declaration-property-value-keyword-no-deprecated` warning message for `overflow: <keyword> <keyword>` ([#8340](stylelint/stylelint#8340)) ([@Mouvedia](https://github.com/Mouvedia)).
-   Fixed: `selector-pseudo-class-no-unknown` false positives for `:has-slotted` ([#8332](stylelint/stylelint#8332)) ([@Mouvedia](https://github.com/Mouvedia)).


## [v16.13.2](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16132---2025-01-14)

It fixes a regression bug with `--fix`.

-   Fixed: `--fix` CLI flag raising unknown value error ([#8313](stylelint/stylelint#8313)) ([@ybiquitous](https://github.com/ybiquitous)).


## [v16.13.1](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16131---2025-01-13)

It fixes one bug due to an upstream change in our `ignore` dependency.

-   Fixed: `ignore.default is not a function` ([#8305](stylelint/stylelint#8305)) ([@romainmenke](https://github.com/romainmenke)).
@denisx denisx deleted the fix/table_16-01-25 branch January 26, 2025 18:46
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.

None yet

2 participants