infctr / eslint-plugin-typescript-sort-keys

A linter plugin to require sorting interface and string enum keys
ISC License
144 stars 28 forks source link

ESLint couldn't find the plugin "eslint-plugin-typescript-sort-keys" #17

Closed C0ZEN closed 4 years ago

C0ZEN commented 4 years ago

Since today.

Command:

npm run eslint --fix --ext .js,.ts --cache scripts/ src/ jest.config.js config.ts

The stack trace:

ESLint couldn't find the plugin "eslint-plugin-typescript-sort-keys".

(The package "eslint-plugin-typescript-sort-keys" was not found when loaded as a Node module from the directory "D:\cozen\Documents\sonia\il-est-midi-discord".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-typescript-sort-keys@latest --save-dev

The plugin "eslint-plugin-typescript-sort-keys" was referenced from the config file in ".eslintrc".

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @sonia-corporation/il-est-midi-discord@1.49.1 lint: `eslint --fix --ext .js,.ts --cache scripts/ src/ jest.config.js config.ts`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @sonia-corporation/il-est-midi-discord@1.49.1 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\cozen\AppData\Roaming\npm-cache\_logs\2020-05-22T15_27_39_621Z-debug.log

Process finished with exit code 2

Environments:

"@typescript-eslint/eslint-plugin": "3.0.0"
"@typescript-eslint/parser": "3.0.0"
"eslint": "7.1.0"
"eslint": "7.1.0"
"eslint-config-google": "0.14.0"
"eslint-config-prettier": "6.11.0"
"eslint-config-recommended": "4.0.0"
"eslint-plugin-import": "2.20.2"
"eslint-plugin-jest": "23.13.1"
"eslint-plugin-prettier": "3.1.3"
"eslint-plugin-rxjs": "0.0.2-beta.22"
"eslint-plugin-typescript-sort-keys": "1.0.2"

.eslintrc:

root: true
env:
  es6: true
  node: true
  jest/globals: true
extends:
  - 'eslint:recommended'
  - google
  - 'plugin:@typescript-eslint/eslint-recommended'
  - 'plugin:@typescript-eslint/recommended'
  - 'plugin:import/errors'
  - 'plugin:import/warnings'
  - 'plugin:import/typescript'
  - 'plugin:jest/style'
  - 'plugin:jest/all'
  - 'plugin:prettier/recommended'
globals:
  Atomics: readonly
  SharedArrayBuffer: readonly
parserOptions:
  ecmaVersion: 2018
  sourceType: module
  project: ./tsconfig.json
parser: '@typescript-eslint/parser'
plugins:
  - '@typescript-eslint'
  - typescript-sort-keys
  - jest
  - prettier
settings:
  import/extensions:
    - .js
    - .ts
  import/parsers:
    '@typescript-eslint/parser':
      - .ts
  import/cache:
    lifetime: Infinity
rules:
  jest/no-test-callback: 'off'
  jest/no-disabled-tests: 'off'
  '@typescript-eslint/member-ordering':
    - error
    - default:
        - signature
        - public-static-field
        - protected-static-field
        - private-static-field
        - public-static-method
        - protected-static-method
        - private-static-method
        - public-abstract-field
        - protected-abstract-field
        - private-abstract-field
        - public-instance-field
        - protected-instance-field
        - private-instance-field
        - public-constructor
        - protected-constructor
        - private-constructor
        - public-instance-method
        - protected-instance-method
        - private-instance-method
        - public-abstract-method
        - protected-abstract-method
        - private-abstract-method
  prettier/prettier: error
  jest/lowercase-name:
    - error
    - ignore:
        - describe
  jest/no-hooks:
    - error
    - allow:
        - beforeAll
        - beforeEach
        - afterAll
        - afterEach
  typescript-sort-keys/interface:
    - error
    - asc
    - caseSensitive: true
      natural: true
  typescript-sort-keys/string-enum:
    - error
    - asc
    - caseSensitive: true
      natural: true
  quotes:
    - error
    - backtick
  no-else-return:
    - error
    - allowElseIf: true
  sort-keys:
    - error
    - asc
    - caseSensitive: true
      natural: true
      minKeys: 2
  '@typescript-eslint/no-var-requires': 'off'
  '@typescript-eslint/explicit-function-return-type': 'off'
  '@typescript-eslint/no-unused-vars':
    - error
    - argsIgnorePattern: ^_
  import/no-namespace: 'off'
  import/first: error
  import/exports-last: error
  import/no-duplicates: error
  indent: 'off'
  '@typescript-eslint/naming-convention':
    - error
    - selector: default
      format:
        - camelCase
    - selector: variable
      format:
        - camelCase
        - UPPER_CASE
    - selector: variable
      types:
        - boolean
      format:
        - PascalCase
      prefix:
        - is
        - has
        - should
        - contains
        - as
    - selector: parameter
      format:
        - camelCase
      leadingUnderscore: allow
    - selector: parameter
      types:
        - boolean
      format:
        - PascalCase
      leadingUnderscore: allow
      prefix:
        - is
        - has
        - should
        - contains
        - as
    - selector: function
      format:
        - camelCase
    - selector: memberLike
      modifiers:
        - private
      format:
        - camelCase
      leadingUnderscore: require
    - selector: memberLike
      modifiers:
        - protected
      format:
        - camelCase
      leadingUnderscore: require
    - selector: typeLike
      format:
        - PascalCase
    - selector: typeParameter
      format:
        - PascalCase
      prefix:
        - T
    - selector: interface
      format:
        - PascalCase
      prefix:
        - I
    - selector: enumMember
      format:
        - UPPER_CASE
    - selector: enum
      format:
        - PascalCase
      suffix:
        - Enum
  '@typescript-eslint/no-explicit-any':
    - error
    - fixToUnknown: false
      ignoreRestArgs: false
  object-curly-spacing:
    - error
    - always
  linebreak-style: 'off'
  computed-property-spacing:
    - error
    - never
  array-bracket-spacing: 'off'
  prefer-rest-params: 'off'
  require-jsdoc: 'off'
  max-len: 'off'
  comma-dangle: 'off'
overrides:
  - files:
      - '*.ts'
    rules:
      '@typescript-eslint/explicit-function-return-type':
        - error
        - allowExpressions: false
          allowTypedFunctionExpressions: false
          allowHigherOrderFunctions: false
      '@typescript-eslint/no-var-requires':
        - error
infctr commented 4 years ago

I'll investigate, try rolling back to previous stable version as a workaround 0.10.0

C0ZEN commented 4 years ago

@infctr thank you and let me know if you need more information.

C0ZEN commented 4 years ago

@infctr the 0.10.0 is working fine.

C0ZEN commented 4 years ago

@infctr updated to add more information about the command I run and the dependencies.

infctr commented 4 years ago

@C0ZEN Could you please give 1.1.0-rc1 build under next tag a try?

C0ZEN commented 4 years ago

@infctr with 1.1.0-rc1 😢

> eslint --fix --ext .js,.ts --cache scripts/ src/ jest.config.js config.ts

(node:956) ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at any time

Oops! Something went wrong! :(

ESLint: 7.1.0

ESLint couldn't find the plugin "eslint-plugin-typescript-sort-keys".

(The package "eslint-plugin-typescript-sort-keys" was not found when loaded as a Node module from the directory "D:\cozen\Documents\sonia\il-est-midi-discord".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-typescript-sort-keys@latest --save-dev

The plugin "eslint-plugin-typescript-sort-keys" was referenced from the config file in ".eslintrc".

If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team.
infctr commented 4 years ago

@C0ZEN Well, that's unexpected 🤔

What's your version of npm and node? Mind setting up a repro? I've tried setting up a repro based on your eslint config and indeed there was a missing sub-dependency, but I'm kinda out of clues here

C0ZEN commented 4 years ago

@infctr ok I will try to create a minimal repro today.

infctr commented 4 years ago

@C0ZEN What's your eslint script btw?

C0ZEN commented 4 years ago

@infctr I added it on the issue.

npm run eslint --fix --ext .js,.ts --cache scripts/ src/ jest.config.js config.ts

Environment:

| software         | version(s)
| ---------------- | -------
| node             | 13.7.0
| npm              | 6.14.4
| Operating System | Windows 10 64bits

But the error is also happening on the GitHub Actions.

infctr commented 4 years ago

Not the config, but npm script, the command you run here https://github.com/infctr/eslint-plugin-typescript-sort-keys/issues/17#issue-623291374

And what's your npm and node version?

C0ZEN commented 4 years ago

@infctr So far when trying to create a reproduction I encountered this new error when installing the next 1.1.0-rc1 version.

Error: Failed to load plugin 'typescript-sort-keys' declared in '.eslintrc': No valid exports main found for 'D:\cozen\Documents\eslint\eslint-plugin-typescript-sort-keys-issue-468\node_modules\eslint-plugin-typescript-sort-keys'
Require stack:
- D:\cozen\Documents\eslint\eslint-plugin-typescript-sort-keys-issue-468\__placeholder__.js
C0ZEN commented 4 years ago

@infctr maybe you could try it yourself: https://github.com/C0ZEN/eslint-plugin-typescript-sort-keys-issue-468

infctr commented 4 years ago

Doesn't seem to reproduce for me on

❯ npm -v
6.14.4
❯ node -v
v12.16.3

@C0ZEN What versions are you on?

infctr commented 4 years ago

So this seems to be the node version issue as explained here https://github.com/jaydenseric/extract-files/issues/13#issuecomment-610324961

Try updating node version to other than v13.0.0 - v13.6 range

C0ZEN commented 4 years ago

@infctr nice catch about the node problem, it was the least expected from my point of view.

Environment with the error:

| software         | version(s)
| ---------------- | -------
| node             | 13.7.0
| npm              | 6.14.4
| Operating System | Windows 10 64bits

After upgrading to node 14.3.0 the issue was solved. Nevertheless I have now another issue in the reproduction:

Invalid "exports" main target "lib/index.cjs.js" defined in the package config /D:/cozen/Documents/eslint/eslint-plugin-typescript-sort-keys-issue-468/node_modules/eslint-plugin-typescript-sort-k
eys\package.json; targets must start with "./"

But I will try to upgrade the version of this dependency in my real project to see if this is alright.

C0ZEN commented 4 years ago

@infctr same error with my real project. Do you know if this is somehow related to node or did you change something on the 1.1.0 version of higher?

Edit: The GitHub CI do not have the problem. This is again related to node sadly. So, both 13.7.0 and 14.3.0 are not working well 😭

infctr commented 4 years ago

@C0ZEN The error on node 14.3.0 is fixable, I'll make a release shortly

infctr commented 4 years ago

Please try latest version v1.2.0

C0ZEN commented 4 years ago

@infctr indeed the 1.2.0 fixed the last error. Nice work dude.