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: Allow node access to "./lib/rules" directory #15176

Closed
wants to merge 1 commit into from
Closed

Fix: Allow node access to "./lib/rules" directory #15176

wants to merge 1 commit into from

Conversation

salortiz
Copy link

What is the purpose of this pull request? (put an "X" next to an item)

[ X ] Bug fix (template)

What changes did you make? (Give an overview)

Add access to ./lib/rules directory in package.json's exports

After update to v8.0.1 my vscode console show the error attached bellow.
The proposed patch fixed that.

Prerequisites checklist

Tell us about your environment

  • ESLint Version:
    8.0.1

  • Node Version:
    My vscode uses v14.16.0, outside I use v16

  • npm Version:
    8.0.0
    What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using?
    Both of them

Please show your full configuration:

Configuration
module.exports = {
    root: true,
    extends: [
        'eslint:recommended'
    ],
    env: {
        node: true,
        es2021: true
    },
    ignorePatterns: [ '**/lib/*.js' ],
    rules: {
        'no-unused-vars': [
            'warn', {
                vars: 'local',
                argsIgnorePattern: 'ev|res'
            }
        ],
        'no-mixed-spaces-and-tabs': 0,
        'require-atomic-updates': 0,
        'no-control-regex': 0,
        'object-shorthand': 1
    },
    parserOptions: {
        //sourceType: 'script',  BUG!?
        ecmaVersion: 2021,
    },
    overrides: [{
        files: [ '**/src/*.js', '**/ComProvs/*.js' ],
        plugins: [ '@babel', 'flowtype' ],
        extends: [ 'plugin:flowtype/recommended' ],
        parser: '@babel/eslint-parser',
        parserOptions: {
            //'source-type': 'script',
            //sourceType: 'script', // BUG!?
            ecmaVersion: 2021,
            babelOptions: { rootMode: 'upward' }
        },
        rules: {
            '@babel/new-cap': [
                'warn', { properties: false }
            ],
            '@babel/no-invalid-this': 0,
            '@babel/object-curly-spacing': 1,
            '@babel/semi': [
                'error',
                'always', { 'omitLastInOneLineBlock': true }
            ],
            '@babel/no-unused-expressions': 1,
        }
    }, {
        files: ['types/*.d.ts', '**/src/*.ts'],
        plugins: [ '@typescript-eslint' ],
        extends: [ 'plugin:@typescript-eslint/recommended' ]
    }, {
        files: [ '**/config/*.json5' ],
        plugins: [ 'json5' ],
    }, {
        files: [ '**/*.json' ],
        plugins: [ 'json' ],
        extends: [ 'plugin:json/recommended' ]
    }]
};

What did you do? Please include the actual source code causing the issue.
After updating eslint in my workspace (via yarn) and start vscode, eslint don't start.

What did you expect to happen?
Eslint works

What actually happened? Please include the actual, raw output from ESLint.

[Info  - 4:38:37 PM] ESLint server running in node v14.16.0
[Info  - 4:38:37 PM] ESLint server is running.
[Info  - 4:38:37 PM] ESLint library loaded from: /home/sog/work/projects/urbit/node_modules/eslint/lib/api.js
(node:18882) UnhandledPromiseRejectionWarning: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/rules/no-unused-expressions' is not defined by "exports" in /home/sog/work/projects/urbit/node_modules/eslint/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:513:3)
    at resolveExports (internal/modules/cjs/loader.js:439:36)
    …

@eslint-github-bot eslint-github-bot bot added the triage An ESLint team member will look at this issue soon label Oct 16, 2021
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 16, 2021

CLA Signed

The committers are authorized under a signed CLA.

@eslint-github-bot
Copy link

Hi @salortiz!, thanks for the Pull Request

The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag must be one of the following:

    The Tag is one of the following:

    • Fix - for a bug fix.
    • Update - either for a backwards-compatible enhancement or for a rule change that adds reported problems.
    • New - implements a new feature.
    • Breaking - for a backwards-incompatible enhancement or feature.
    • Docs - changes to documentation only.
    • Build - changes to build process only.
    • Upgrade - for a dependency upgrade.
    • Chore - for anything that isn't user-facing (for example, refactoring, adding tests, etc.).

    You can use the labels of the issue you are working on to determine the best tag.

  • There should be a space following the initial tag and colon, for example 'New: Message'.

Read more about contributing to ESLint here

After update to v8.0.1 found an error in vscode output:

```
(node:18882) UnhandledPromiseRejectionWarning: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/rules/no-unused-expressions' is not defined by "exports" in /home/sog/work/projects/urbit/node_modules/eslint/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:513:3)
    at resolveExports (internal/modules/cjs/loader.js:439:36)
    …
```
The proposed patch fixed that.
@mdjermanovic
Copy link
Member

Hi @salortiz, thanks for the PR!

Add access to ./lib/rules directory in package.json's exports

This was intentionally removed in v8.0.0 per eslint/rfcs#80, because it isn't ESLint's public API.

Rules can still be accessed, but through the use-at-your-own-risk entry point. Plugins that are extending core rules just need to update this path and release new versions compatible with ESLint v8.

[Info - 4:38:37 PM] ESLint server running in node v14.16.0
[Info - 4:38:37 PM] ESLint server is running.
[Info - 4:38:37 PM] ESLint library loaded from: /home/sog/work/projects/urbit/node_modules/eslint/lib/api.js
(node:18882) UnhandledPromiseRejectionWarning: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/rules/no-unused-expressions' is not defined by "exports" in /home/sog/work/projects/urbit/node_modules/eslint/package.json
at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
at packageExportsResolve (internal/modules/esm/resolve.js:513:3)
at resolveExports (internal/modules/cjs/loader.js:439:36)

This is most likely caused by loading eslint-plugin-flowtype, and will be fixed by gajus/eslint-plugin-flowtype#496 (on this line)

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Apr 15, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion triage An ESLint team member will look at this issue soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants