Skip to content

test: enable linter on test.js#275

Merged
aduh95 merged 2 commits intonodejs:mainfrom
aduh95:lint-test-module
Oct 11, 2021
Merged

test: enable linter on test.js#275
aduh95 merged 2 commits intonodejs:mainfrom
aduh95:lint-test-module

Conversation

@aduh95
Copy link
Copy Markdown
Contributor

@aduh95 aduh95 commented Oct 1, 2021

No description provided.

@aduh95 aduh95 requested review from Trott and nschonni October 1, 2021 14:41
@aduh95
Copy link
Copy Markdown
Contributor Author

aduh95 commented Oct 1, 2021

The CI failure seem to be related to mysticatea/eslint-plugin-node#277, which was merged but hasn't been published yet.

@Trott
Copy link
Copy Markdown
Member

Trott commented Oct 1, 2021

The approach seems OK to me if you can get the linter to succeed on test.js. Maybe include a comment in fixturesUrl.js explaining that it's there because current ESLint can't parse import.meta and that it can be removed when ESLint supports import.meta.

@aduh95
Copy link
Copy Markdown
Contributor Author

aduh95 commented Oct 1, 2021

The CI failure seem to be related to mysticatea/eslint-plugin-node#277, which was merged but hasn't been published yet.

Removing node: prefix for now, we can add it back later when a new version of eslint-plugin-node has been released – and potentially add unicorn/prefer-node-protocol to the ESLint config to enforce it.

Comment thread test/test.js
Comment thread test/test.js Outdated
// Test that correctly-formatted markdown is ok.
(async () => {
const file = await read(new URL("./fixtures/ok.md", import.meta.url));
const file = await read(new URL("./ok.md", fixturesUrl));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is the fixtures being dropped from the path here? Is it related to the move of that import?

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.

We're importing the fixturesUrl, which is a file: URL leading to the fixtures/ folder, so yes it is related to the move of that import :) (import.meta.url is an absolute URL leading to the module where it's executed, not relative to the cwd or the module importing it).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK, maybe that is just more confusing for me 😄
Would pulling it back up to the test root, and just ignoreing the file path in eslintignore (instead of the directory) make sense? Don't feel strongly about it, but it wouldn't be obvious on why the paths worked like this if I was going to write a new test

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.

Would it help if we renamed fixturesUrl into something else? Something that makes it obvious that the relative URL is based on the fixtures directory.

@aduh95 aduh95 merged commit 40605fa into nodejs:main Oct 11, 2021
@aduh95 aduh95 deleted the lint-test-module branch October 11, 2021 15:29
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.

3 participants