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

migrating import/default rule to parsers.all function #2482

Draft
wants to merge 3 commits into
base: parsers
Choose a base branch
from

Conversation

greatsage-raphael
Copy link

@greatsage-raphael greatsage-raphael commented Jun 22, 2022

Migration of import/default rule to parsers.all function

Closes #2498.

@codecov
Copy link

codecov bot commented Jun 22, 2022

Codecov Report

Merging #2482 (00b5737) into parsers (dd74311) will not change coverage.
The diff coverage is n/a.

❗ Current head 00b5737 differs from pull request most recent head efa7e9d. Consider uploading reports for the commit efa7e9d to get more accurate results

@@           Coverage Diff            @@
##           parsers    #2482   +/-   ##
========================================
  Coverage    95.03%   95.03%           
========================================
  Files           66       66           
  Lines         2799     2799           
  Branches       940      940           
========================================
  Hits          2660     2660           
  Misses         139      139           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

// eslint-disable-next-line global-require, import/no-dynamic-require, import/no-unresolved
const getESLintCoreRule = (ruleId) => (isESLintV8 ? require('eslint/use-at-your-own-risk').builtinRules.get(ruleId) : require(`eslint/lib/rules/${ruleId}`));

module.exports = getESLintCoreRule;
Copy link
Member

Choose a reason for hiding this comment

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

what is this used for?

Copy link
Author

Choose a reason for hiding this comment

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

It was an oversight. It wasn't meant to be pushed

@ljharb ljharb changed the base branch from main to parsers June 23, 2022 17:52
@ljharb
Copy link
Member

ljharb commented Jun 23, 2022

(I changed the base of this so it's into a "parsers" branch)

@greatsage-raphael
Copy link
Author

Am I going in the right direction ? @ljharb

@ljharb
Copy link
Member

ljharb commented Jun 23, 2022

Pulling in the parsers.all helper is great :-) but the rule tests haven't been touched yet, and that'd be the important part.

@ljharb ljharb marked this pull request as draft June 23, 2022 18:51
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Looks like the right approach overall :-)

tests/src/rules/default.js Outdated Show resolved Hide resolved
import { RuleTester } from 'eslint';
import semver from 'semver';
import { version as tsEslintVersion } from 'typescript-eslint-parser/package.json';

import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve';

const ruleTester = new RuleTester();
const RuleTester = require('eslint').RuleTester;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const RuleTester = require('eslint').RuleTester;

this is already imported

ruleTester.run('default', rule, {
valid: [].concat(
test({ code: 'import "./malformed.js"' }),
Copy link
Member

Choose a reason for hiding this comment

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

do we no longer need the test function? that function is highly specific to the import plugin, so i wouldn't want its logic to live inside parsers.all

Copy link
Author

Choose a reason for hiding this comment

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

Oh okay. I'll add them back

Copy link
Member

Choose a reason for hiding this comment

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

We could also do .map(x => test(x)) on the array, if they don't pass any options to test - up to you. might be better to minimize the diff here.

tests/src/rules/default.js Outdated Show resolved Hide resolved
Comment on lines 126 to 127
// #311: import of mismatched case
if (!CASE_SENSITIVE_FS) {
Copy link
Member

Choose a reason for hiding this comment

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

it would also be ideal to combine this so that the entire file has a single list of "valid" and "invalid" cases, rather than multiples.

Copy link
Author

Choose a reason for hiding this comment

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

Would this also include the context function. It has valid and invalid cases too

Copy link
Member

Choose a reason for hiding this comment

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

yep

@ljharb ljharb force-pushed the parsers branch 2 times, most recently from fc4875f to 5cff58e Compare July 2, 2022 04:04
greatsage-raphael and others added 2 commits July 6, 2022 12:58
Co-authored-by: Lubwama Collins <bizzicole87@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Lubwama Collins <bizzicole87@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
@ljharb ljharb force-pushed the default-rule branch 2 times, most recently from e2d8e6a to efa7e9d Compare August 24, 2022 05:30
@ljharb
Copy link
Member

ljharb commented Aug 24, 2022

This is looking great! We're down to a manageable number of failures :-)

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.

2 participants