import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.58k stars 1.57k forks source link

Core module subpaths are not supported #1975

Closed clshortfuse closed 3 years ago

clshortfuse commented 3 years ago

Trying to use import modules that specify a subpath aren't supported and I haven't been able to find a way to work around it.

Error:

Unable to resolve path to module 'path/posix'. eslint(import/no-unresolved)

Example:

import { join, parse, relative } from 'path/posix';
import { readFile, writeFile } from 'fs/promises';

I tried the following with this plugin to no avail:

"rules": {
  "import/no-unresolved": ["error", {
      "ignore": ["path/posix", "path\/posix", "path\\/posix"]
    }],
},
"settings": {
    "import/core-modules": ["path/posix", "path\/posix", "path\\/posix"]
}

Similarly, this problem exists with node/no-missing-import but I can use the following workaround:

"node/no-missing-import": ["error", {
  "allowModules": ["path/posix"] 
}]
clshortfuse commented 3 years ago

Realized path/posix doesn't work with ES6. That's another issue entirely.

ljharb commented 3 years ago

path/posix is a core module as of node 15.3 and this plugin will recognize it as such on the appropriate node version.

nathanhannig commented 3 years ago

On node 15.8.0 and receiving an error Unable to resolve path to module 'fs/promises'. eslint import/no-unresolved

ljharb commented 3 years ago

@nathanhannig if you're using the latest version of eslint-plugin-import (and of resolve or is-core-module, which it depends on) it will work fine.

thernstig commented 3 years ago

@ljharb I am using "eslint-plugin-import": "2.22.1", and still get this:

fspromises

The dependents I have:

    "resolve": {
      "version": "1.19.0",
    "is-core-module": {
      "version": "2.2.0",

Suppose I am not using the latest of the dependencies and that is why it does not work.

ljharb commented 3 years ago

@thernstig what version of node are you using? fs/promises is only a core module in node v14+.

thernstig commented 3 years ago
~/code/projectA (PROMISESCOOL)> node --version
v14.15.1
thernstig commented 3 years ago

I've also set this in my package.json:

"engines": {
    "node": "14.15.1"
  },
ljharb commented 3 years ago

Can you share your eslint config? You need to be using the node resolver to resolve node core modules.

thernstig commented 3 years ago

Scaled it down to an example that still gives the error:

{
  "root": true,
  "parserOptions": {
    "ecmaVersion": 2020
  },
  "env": {
    "node": true,
    "es2020": true,
    "jest": true
  },
  "extends": [
    "airbnb-base",
    "plugin:node/recommended",
    "plugin:jest/recommended",
    "plugin:jest/style",
    "plugin:jsdoc/recommended",
    "prettier"
  ],
  "rules": {
    "node/exports-style": ["error", "module.exports"],
    "node/prefer-promises/dns": "error"
  }
}
ljharb commented 3 years ago

@thernstig and you're getting that error on the CLI as well, or only in your editor?

thernstig commented 3 years ago

CLI as well.

thernstig commented 3 years ago

Could it be that I have to update these?

    "resolve": {
      "version": "1.19.0",
    "is-core-module": {
      "version": "2.2.0",
ljharb commented 3 years ago

No, those are late enough that it should work properly.

can you run eslint with the show config option, to print out the fully flattened config being used for the file being warned?

thernstig commented 3 years ago

@ljharb Here you go:

```jsonc // .eslintrc.json { "root": true, "env": { "node": true }, "extends": ["airbnb-base", "plugin:node/recommended"] } ``` ```js // server/server.js const fsp = require('fs/promises'); ``` ```jsonc // eslint --print-config server/server.js { "env": { "node": true, "es2020": true, "jest": true, "jest/globals": true, "es6": true }, "globals": { "ArrayBuffer": "readonly", "Atomics": "readonly", "BigInt": "readonly", "BigInt64Array": "readonly", "BigUint64Array": "readonly", "DataView": "readonly", "Float32Array": "readonly", "Float64Array": "readonly", "Int16Array": "readonly", "Int32Array": "readonly", "Int8Array": "readonly", "Map": "readonly", "Promise": "readonly", "Proxy": "readonly", "Reflect": "readonly", "Set": "readonly", "SharedArrayBuffer": "readonly", "Symbol": "readonly", "Uint16Array": "readonly", "Uint32Array": "readonly", "Uint8Array": "readonly", "Uint8ClampedArray": "readonly", "WeakMap": "readonly", "WeakSet": "readonly", "globalThis": "readonly", "Intl": "readonly", "TextDecoder": "readonly", "TextEncoder": "readonly", "URL": "readonly", "URLSearchParams": "readonly", "WebAssembly": "readonly", "clearInterval": "readonly", "clearTimeout": "readonly", "console": "readonly", "queueMicrotask": "readonly", "setInterval": "readonly", "setTimeout": "readonly", "Buffer": "readonly", "GLOBAL": "readonly", "clearImmediate": "readonly", "global": "readonly", "process": "readonly", "root": "readonly", "setImmediate": "readonly", "__dirname": "readonly", "__filename": "readonly", "exports": "writable", "module": "readonly", "require": "readonly" }, "parser": null, "parserOptions": { "ecmaVersion": 2020, "ecmaFeatures": { "globalReturn": true, "generators": false, "objectLiteralDuplicateProperties": false }, "sourceType": "script" }, "plugins": ["import", "node", "jest", "jsdoc"], "rules": { "node/exports-style": ["error", "module.exports"], "node/prefer-promises/dns": ["error"], "curly": [0, "multi-line"], "lines-around-comment": [0], "max-len": [ 0, 100, 2, { "ignoreUrls": true, "ignoreComments": false, "ignoreRegExpLiterals": true, "ignoreStrings": true, "ignoreTemplateLiterals": true } ], "no-confusing-arrow": [ 0, { "allowParens": true } ], "no-mixed-operators": [ 0, { "groups": [ ["%", "**"], ["%", "+"], ["%", "-"], ["%", "*"], ["%", "/"], ["/", "*"], ["&", "|", "<<", ">>", ">>>"], ["==", "!=", "===", "!=="], ["&&", "||"] ], "allowSamePrecedence": false } ], "no-tabs": [0], "no-unexpected-multiline": [0], "quotes": [ 0, "single", { "avoidEscape": true } ], "array-bracket-newline": ["off", "consistent"], "array-bracket-spacing": ["off", "never"], "array-element-newline": [ "off", { "multiline": true, "minItems": 3 } ], "arrow-parens": ["off", "always"], "arrow-spacing": [ "off", { "before": true, "after": true } ], "block-spacing": ["off", "always"], "brace-style": [ "off", "1tbs", { "allowSingleLine": true } ], "comma-dangle": [ "off", { "arrays": "always-multiline", "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", "functions": "always-multiline" } ], "comma-spacing": [ "off", { "before": false, "after": true } ], "comma-style": [ "off", "last", { "exceptions": { "ArrayExpression": false, "ArrayPattern": false, "ArrowFunctionExpression": false, "CallExpression": false, "FunctionDeclaration": false, "FunctionExpression": false, "ImportDeclaration": false, "ObjectExpression": false, "ObjectPattern": false, "VariableDeclaration": false, "NewExpression": false } } ], "computed-property-spacing": ["off", "never"], "dot-location": ["off", "property"], "eol-last": ["off", "always"], "func-call-spacing": ["off", "never"], "function-call-argument-newline": ["off", "consistent"], "function-paren-newline": ["off", "consistent"], "generator-star": ["off"], "generator-star-spacing": [ "off", { "before": false, "after": true } ], "implicit-arrow-linebreak": ["off", "beside"], "indent": [ "off", 2, { "SwitchCase": 1, "VariableDeclarator": 1, "outerIIFEBody": 1, "FunctionDeclaration": { "parameters": 1, "body": 1 }, "FunctionExpression": { "parameters": 1, "body": 1 }, "CallExpression": { "arguments": 1 }, "ArrayExpression": 1, "ObjectExpression": 1, "ImportDeclaration": 1, "flatTernaryExpressions": false, "ignoredNodes": [ "JSXElement", "JSXElement > *", "JSXAttribute", "JSXIdentifier", "JSXNamespacedName", "JSXMemberExpression", "JSXSpreadAttribute", "JSXExpressionContainer", "JSXOpeningElement", "JSXClosingElement", "JSXFragment", "JSXOpeningFragment", "JSXClosingFragment", "JSXText", "JSXEmptyExpression", "JSXSpreadChild" ], "ignoreComments": false, "offsetTernaryExpressions": false } ], "jsx-quotes": ["off", "prefer-double"], "key-spacing": [ "off", { "beforeColon": false, "afterColon": true } ], "keyword-spacing": [ "off", { "before": true, "after": true, "overrides": { "return": { "after": true }, "throw": { "after": true }, "case": { "after": true } } } ], "linebreak-style": ["off", "unix"], "multiline-ternary": ["off", "never"], "newline-per-chained-call": [ "off", { "ignoreChainWithDepth": 4 } ], "new-parens": ["off"], "no-arrow-condition": ["off"], "no-comma-dangle": ["off"], "no-extra-parens": [ "off", "all", { "conditionalAssign": true, "nestedBinaryExpressions": false, "returnAssign": false, "ignoreJSX": "all", "enforceForArrowConditionals": false } ], "no-extra-semi": ["off"], "no-floating-decimal": ["off"], "no-mixed-spaces-and-tabs": ["off"], "no-multi-spaces": [ "off", { "ignoreEOLComments": false } ], "no-multiple-empty-lines": [ "off", { "max": 1, "maxBOF": 0, "maxEOF": 0 } ], "no-reserved-keys": ["off"], "no-space-before-semi": ["off"], "no-trailing-spaces": [ "off", { "skipBlankLines": false, "ignoreComments": false } ], "no-whitespace-before-property": ["off"], "no-wrap-func": ["off"], "nonblock-statement-body-position": [ "off", "beside", { "overrides": {} } ], "object-curly-newline": [ "off", { "ObjectExpression": { "minProperties": 4, "multiline": true, "consistent": true }, "ObjectPattern": { "minProperties": 4, "multiline": true, "consistent": true }, "ImportDeclaration": { "minProperties": 4, "multiline": true, "consistent": true }, "ExportDeclaration": { "minProperties": 4, "multiline": true, "consistent": true } } ], "object-curly-spacing": ["off", "always"], "object-property-newline": [ "off", { "allowAllPropertiesOnSameLine": true, "allowMultiplePropertiesPerLine": false } ], "one-var-declaration-per-line": ["off", "always"], "operator-linebreak": [ "off", "before", { "overrides": { "=": "none" } } ], "padded-blocks": [ "off", { "blocks": "never", "classes": "never", "switches": "never" }, { "allowSingleLineBlocks": true } ], "quote-props": [ "off", "as-needed", { "keywords": false, "unnecessary": true, "numbers": false } ], "rest-spread-spacing": ["off", "never"], "semi": ["off", "always"], "semi-spacing": [ "off", { "before": false, "after": true } ], "semi-style": ["off", "last"], "space-after-function-name": ["off"], "space-after-keywords": ["off"], "space-before-blocks": ["off"], "space-before-function-paren": [ "off", { "anonymous": "always", "named": "never", "asyncArrow": "always" } ], "space-before-function-parentheses": ["off"], "space-before-keywords": ["off"], "space-in-brackets": ["off"], "space-in-parens": ["off", "never"], "space-infix-ops": ["off"], "space-return-throw-case": ["off"], "space-unary-ops": [ "off", { "words": true, "nonwords": false, "overrides": {} } ], "space-unary-word-ops": ["off"], "switch-colon-spacing": [ "off", { "after": true, "before": false } ], "template-curly-spacing": ["off"], "template-tag-spacing": ["off", "never"], "unicode-bom": ["off", "never"], "wrap-iife": [ "off", "outside", { "functionPrototypeMethods": false } ], "wrap-regex": ["off"], "yield-star-spacing": ["off", "after"], "indent-legacy": ["off"], "no-spaced-func": ["off"], "jsdoc/check-access": ["warn"], "jsdoc/check-alignment": ["warn"], "jsdoc/check-examples": ["off"], "jsdoc/check-indentation": ["off"], "jsdoc/check-line-alignment": ["off"], "jsdoc/check-param-names": ["warn"], "jsdoc/check-property-names": ["warn"], "jsdoc/check-syntax": ["off"], "jsdoc/check-tag-names": ["warn"], "jsdoc/check-types": ["warn"], "jsdoc/check-values": ["warn"], "jsdoc/empty-tags": ["warn"], "jsdoc/implements-on-classes": ["warn"], "jsdoc/match-description": ["off"], "jsdoc/newline-after-description": ["warn"], "jsdoc/no-bad-blocks": ["off"], "jsdoc/no-defaults": ["off"], "jsdoc/no-types": ["off"], "jsdoc/no-undefined-types": ["warn"], "jsdoc/require-description": ["off"], "jsdoc/require-description-complete-sentence": ["off"], "jsdoc/require-example": ["off"], "jsdoc/require-file-overview": ["off"], "jsdoc/require-hyphen-before-param-description": ["off"], "jsdoc/require-jsdoc": ["warn"], "jsdoc/require-param": ["warn"], "jsdoc/require-param-description": ["warn"], "jsdoc/require-param-name": ["warn"], "jsdoc/require-param-type": ["warn"], "jsdoc/require-property": ["warn"], "jsdoc/require-property-description": ["warn"], "jsdoc/require-property-name": ["warn"], "jsdoc/require-property-type": ["warn"], "jsdoc/require-returns": ["warn"], "jsdoc/require-returns-check": ["warn"], "jsdoc/require-returns-description": ["warn"], "jsdoc/require-returns-type": ["warn"], "jsdoc/require-throws": ["off"], "jsdoc/require-yields": ["warn"], "jsdoc/require-yields-check": ["warn"], "jsdoc/valid-types": ["warn"], "jest/no-alias-methods": ["warn"], "jest/prefer-to-be-null": ["error"], "jest/prefer-to-be-undefined": ["error"], "jest/prefer-to-contain": ["error"], "jest/prefer-to-have-length": ["error"], "jest/expect-expect": ["warn"], "jest/no-commented-out-tests": ["warn"], "jest/no-conditional-expect": ["error"], "jest/no-deprecated-functions": ["error"], "jest/no-disabled-tests": ["warn"], "jest/no-done-callback": ["error"], "jest/no-export": ["error"], "jest/no-focused-tests": ["error"], "jest/no-identical-title": ["error"], "jest/no-interpolation-in-snapshots": ["error"], "jest/no-jasmine-globals": ["error"], "jest/no-jest-import": ["error"], "jest/no-mocks-import": ["error"], "jest/no-standalone-expect": ["error"], "jest/no-test-prefixes": ["error"], "jest/no-try-expect": ["error"], "jest/valid-describe": ["error"], "jest/valid-expect-in-promise": ["error"], "jest/valid-expect": ["error"], "jest/valid-title": ["error"], "no-process-exit": ["error"], "node/no-deprecated-api": ["error"], "node/no-extraneous-import": ["error"], "node/no-extraneous-require": ["error"], "node/no-exports-assign": ["error"], "node/no-missing-import": ["error"], "node/no-missing-require": ["error"], "node/no-unpublished-bin": ["error"], "node/no-unpublished-import": ["error"], "node/no-unpublished-require": ["error"], "node/no-unsupported-features/es-builtins": ["error"], "node/no-unsupported-features/es-syntax": [ "error", { "ignores": [] } ], "node/no-unsupported-features/node-builtins": ["error"], "node/process-exit-as-throw": ["error"], "node/shebang": ["error"], "strict": ["error", "never"], "import/no-unresolved": [ "error", { "commonjs": true, "caseSensitive": true } ], "import/named": ["error"], "import/default": ["off"], "import/namespace": ["off"], "import/export": ["error"], "import/no-named-as-default": ["error"], "import/no-named-as-default-member": ["error"], "import/no-deprecated": ["off"], "import/no-extraneous-dependencies": [ "error", { "devDependencies": [ "test/**", "tests/**", "spec/**", "**/__tests__/**", "**/__mocks__/**", "test.{js,jsx}", "test-*.{js,jsx}", "**/*{.,_}{test,spec}.{js,jsx}", "**/jest.config.js", "**/jest.setup.js", "**/vue.config.js", "**/webpack.config.js", "**/webpack.config.*.js", "**/rollup.config.js", "**/rollup.config.*.js", "**/gulpfile.js", "**/gulpfile.*.js", "**/Gruntfile{,.js}", "**/protractor.conf.js", "**/protractor.conf.*.js", "**/karma.conf.js" ], "optionalDependencies": false } ], "import/no-mutable-exports": ["error"], "import/no-commonjs": ["off"], "import/no-amd": ["error"], "import/no-nodejs-modules": ["off"], "import/first": ["error"], "import/imports-first": ["off"], "import/no-duplicates": ["error"], "import/no-namespace": ["off"], "import/extensions": [ "error", "ignorePackages", { "js": "never", "mjs": "never", "jsx": "never" } ], "import/order": [ "error", { "groups": [["builtin", "external", "internal"]] } ], "import/newline-after-import": ["error"], "import/prefer-default-export": ["error"], "import/no-restricted-paths": ["off"], "import/max-dependencies": [ "off", { "max": 10 } ], "import/no-absolute-path": ["error"], "import/no-dynamic-require": ["error"], "import/no-internal-modules": [ "off", { "allow": [] } ], "import/unambiguous": ["off"], "import/no-webpack-loader-syntax": ["error"], "import/no-unassigned-import": ["off"], "import/no-named-default": ["error"], "import/no-anonymous-default-export": [ "off", { "allowArray": false, "allowArrowFunction": false, "allowAnonymousClass": false, "allowAnonymousFunction": false, "allowLiteral": false, "allowObject": false } ], "import/exports-last": ["off"], "import/group-exports": ["off"], "import/no-default-export": ["off"], "import/no-named-export": ["off"], "import/no-self-import": ["error"], "import/no-cycle": [ "error", { "maxDepth": "∞", "ignoreExternal": false } ], "import/no-useless-path-segments": [ "error", { "commonjs": true } ], "import/dynamic-import-chunkname": [ "off", { "importFunctions": [], "webpackChunknameFormat": "[0-9a-zA-Z-_/.]+" } ], "import/no-relative-parent-imports": ["off"], "import/no-unused-modules": [ "off", { "ignoreExports": [], "missingExports": true, "unusedExports": true } ], "arrow-body-style": [ "error", "as-needed", { "requireReturnForObjectLiteral": false } ], "constructor-super": ["error"], "no-class-assign": ["error"], "no-const-assign": ["error"], "no-dupe-class-members": ["error"], "no-duplicate-imports": ["off"], "no-new-symbol": ["error"], "no-restricted-exports": [ "off", { "restrictedNamedExports": ["default", "then"] } ], "no-restricted-imports": [ "off", { "paths": [], "patterns": [] } ], "no-this-before-super": ["error"], "no-useless-computed-key": ["error"], "no-useless-constructor": ["error"], "no-useless-rename": [ "error", { "ignoreDestructuring": false, "ignoreImport": false, "ignoreExport": false } ], "no-var": ["error"], "object-shorthand": [ "error", "always", { "ignoreConstructors": false, "avoidQuotes": true } ], "prefer-arrow-callback": [ "error", { "allowNamedFunctions": false, "allowUnboundThis": true } ], "prefer-const": [ "error", { "destructuring": "any", "ignoreReadBeforeAssign": true } ], "prefer-destructuring": [ "error", { "VariableDeclarator": { "array": false, "object": true }, "AssignmentExpression": { "array": true, "object": false } }, { "enforceForRenamedProperties": false } ], "prefer-numeric-literals": ["error"], "prefer-reflect": ["off"], "prefer-rest-params": ["error"], "prefer-spread": ["error"], "prefer-template": ["error"], "require-yield": ["error"], "sort-imports": [ "off", { "ignoreCase": false, "ignoreDeclarationSort": false, "ignoreMemberSort": false, "memberSyntaxSortOrder": ["none", "all", "multiple", "single"] } ], "symbol-description": ["error"], "init-declarations": ["off"], "no-catch-shadow": ["off"], "no-delete-var": ["error"], "no-label-var": ["error"], "no-restricted-globals": [ "error", { "name": "isFinite", "message": "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite" }, { "name": "isNaN", "message": "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan" }, "addEventListener", "blur", "close", "closed", "confirm", "defaultStatus", "defaultstatus", "event", "external", "find", "focus", "frameElement", "frames", "history", "innerHeight", "innerWidth", "length", "location", "locationbar", "menubar", "moveBy", "moveTo", "name", "onblur", "onerror", "onfocus", "onload", "onresize", "onunload", "open", "opener", "opera", "outerHeight", "outerWidth", "pageXOffset", "pageYOffset", "parent", "print", "removeEventListener", "resizeBy", "resizeTo", "screen", "screenLeft", "screenTop", "screenX", "screenY", "scroll", "scrollbars", "scrollBy", "scrollTo", "scrollX", "scrollY", "self", "status", "statusbar", "stop", "toolbar", "top" ], "no-shadow": ["error"], "no-shadow-restricted-names": ["error"], "no-undef": ["error"], "no-undef-init": ["error"], "no-undefined": ["off"], "no-unused-vars": [ "error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": true } ], "no-use-before-define": [ "error", { "functions": true, "classes": true, "variables": true } ], "camelcase": [ "error", { "properties": "never", "ignoreDestructuring": false, "ignoreImports": false, "ignoreGlobals": false } ], "capitalized-comments": [ "off", "never", { "line": { "ignorePattern": ".*", "ignoreInlineComments": true, "ignoreConsecutiveComments": true }, "block": { "ignorePattern": ".*", "ignoreInlineComments": true, "ignoreConsecutiveComments": true } } ], "consistent-this": ["off"], "func-name-matching": [ "off", "always", { "includeCommonJSModuleExports": false, "considerPropertyDescriptor": true } ], "func-names": ["warn"], "func-style": ["off", "expression"], "id-blacklist": ["off"], "id-denylist": ["off"], "id-length": ["off"], "id-match": ["off"], "line-comment-position": [ "off", { "position": "above", "ignorePattern": "", "applyDefaultPatterns": true } ], "lines-between-class-members": [ "error", "always", { "exceptAfterSingleLine": false } ], "lines-around-directive": [ "error", { "before": "always", "after": "always" } ], "max-depth": ["off", 4], "max-lines": [ "off", { "max": 300, "skipBlankLines": true, "skipComments": true } ], "max-lines-per-function": [ "off", { "max": 50, "skipBlankLines": true, "skipComments": true, "IIFEs": true } ], "max-nested-callbacks": ["off"], "max-params": ["off", 3], "max-statements": ["off", 10], "max-statements-per-line": [ "off", { "max": 1 } ], "multiline-comment-style": ["off", "starred-block"], "new-cap": [ "error", { "newIsCap": true, "newIsCapExceptions": [], "capIsNew": false, "capIsNewExceptions": [ "Immutable.Map", "Immutable.Set", "Immutable.List" ], "properties": true } ], "newline-after-var": ["off"], "newline-before-return": ["off"], "no-array-constructor": ["error"], "no-bitwise": ["error"], "no-continue": ["error"], "no-inline-comments": ["off"], "no-lonely-if": ["error"], "no-multi-assign": ["error"], "no-negated-condition": ["off"], "no-nested-ternary": ["error"], "no-new-object": ["error"], "no-plusplus": ["error"], "no-restricted-syntax": [ "error", { "selector": "ForInStatement", "message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array." }, { "selector": "ForOfStatement", "message": "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations." }, { "selector": "LabeledStatement", "message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand." }, { "selector": "WithStatement", "message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize." } ], "no-ternary": ["off"], "no-underscore-dangle": [ "error", { "allow": [], "allowAfterThis": false, "allowAfterSuper": false, "enforceInMethodNames": true, "allowAfterThisConstructor": false, "allowFunctionParams": true } ], "no-unneeded-ternary": [ "error", { "defaultAssignment": false } ], "one-var": ["error", "never"], "operator-assignment": ["error", "always"], "padding-line-between-statements": ["off"], "prefer-exponentiation-operator": ["off"], "prefer-object-spread": ["error"], "require-jsdoc": ["off"], "sort-keys": [ "off", "asc", { "caseSensitive": false, "natural": true } ], "sort-vars": ["off"], "spaced-comment": [ "error", "always", { "line": { "exceptions": ["-", "+"], "markers": ["=", "!", "/"] }, "block": { "exceptions": ["-", "+"], "markers": ["=", "!", ":", "::"], "balanced": true } } ], "callback-return": ["off"], "global-require": ["error"], "handle-callback-err": ["off"], "no-buffer-constructor": ["error"], "no-mixed-requires": ["off", false], "no-new-require": ["error"], "no-path-concat": ["error"], "no-process-env": ["off"], "no-restricted-modules": ["off"], "no-sync": ["off"], "for-direction": ["error"], "getter-return": [ "error", { "allowImplicit": true } ], "no-async-promise-executor": ["error"], "no-await-in-loop": ["error"], "no-compare-neg-zero": ["error"], "no-cond-assign": ["error", "always"], "no-console": ["warn"], "no-constant-condition": ["warn"], "no-control-regex": ["error"], "no-debugger": ["error"], "no-dupe-args": ["error"], "no-dupe-else-if": ["off"], "no-dupe-keys": ["error"], "no-duplicate-case": ["error"], "no-empty": ["error"], "no-empty-character-class": ["error"], "no-ex-assign": ["error"], "no-extra-boolean-cast": ["error"], "no-func-assign": ["error"], "no-import-assign": ["off"], "no-inner-declarations": ["error"], "no-invalid-regexp": ["error"], "no-irregular-whitespace": ["error"], "no-loss-of-precision": ["off"], "no-misleading-character-class": ["error"], "no-obj-calls": ["error"], "no-promise-executor-return": ["off"], "no-prototype-builtins": ["error"], "no-regex-spaces": ["error"], "no-setter-return": ["off"], "no-sparse-arrays": ["error"], "no-template-curly-in-string": ["error"], "no-unreachable": ["error"], "no-unreachable-loop": [ "off", { "ignore": [] } ], "no-unsafe-finally": ["error"], "no-unsafe-negation": ["error"], "no-useless-backreference": ["off"], "no-negated-in-lhs": ["off"], "require-atomic-updates": ["off"], "use-isnan": ["error"], "valid-jsdoc": ["off"], "valid-typeof": [ "error", { "requireStringLiterals": true } ], "accessor-pairs": ["off"], "array-callback-return": [ "error", { "allowImplicit": true, "checkForEach": false } ], "block-scoped-var": ["error"], "complexity": ["off", 11], "class-methods-use-this": [ "error", { "exceptMethods": [] } ], "consistent-return": ["error"], "default-case": [ "error", { "commentPattern": "^no default$" } ], "default-case-last": ["off"], "default-param-last": ["off"], "dot-notation": [ "error", { "allowKeywords": true, "allowPattern": "" } ], "eqeqeq": [ "error", "always", { "null": "ignore" } ], "grouped-accessor-pairs": ["off"], "guard-for-in": ["error"], "max-classes-per-file": ["error", 1], "no-alert": ["warn"], "no-caller": ["error"], "no-case-declarations": ["error"], "no-constructor-return": ["off"], "no-div-regex": ["off"], "no-else-return": [ "error", { "allowElseIf": false } ], "no-empty-function": [ "error", { "allow": ["arrowFunctions", "functions", "methods"] } ], "no-empty-pattern": ["error"], "no-eq-null": ["off"], "no-eval": ["error"], "no-extend-native": ["error"], "no-extra-bind": ["error"], "no-extra-label": ["error"], "no-fallthrough": ["error"], "no-global-assign": [ "error", { "exceptions": [] } ], "no-native-reassign": ["off"], "no-implicit-coercion": [ "off", { "boolean": false, "number": true, "string": true, "allow": [] } ], "no-implicit-globals": ["off"], "no-implied-eval": ["error"], "no-invalid-this": ["off"], "no-iterator": ["error"], "no-labels": [ "error", { "allowLoop": false, "allowSwitch": false } ], "no-lone-blocks": ["error"], "no-loop-func": ["error"], "no-magic-numbers": [ "off", { "ignore": [], "ignoreArrayIndexes": true, "enforceConst": true, "detectObjects": false } ], "no-multi-str": ["error"], "no-new": ["error"], "no-new-func": ["error"], "no-new-wrappers": ["error"], "no-octal": ["error"], "no-octal-escape": ["error"], "no-param-reassign": [ "error", { "props": true, "ignorePropertyModificationsFor": [ "acc", "accumulator", "e", "ctx", "context", "req", "request", "res", "response", "$scope", "staticContext" ] } ], "no-proto": ["error"], "no-redeclare": ["error"], "no-restricted-properties": [ "error", { "object": "arguments", "property": "callee", "message": "arguments.callee is deprecated" }, { "object": "global", "property": "isFinite", "message": "Please use Number.isFinite instead" }, { "object": "self", "property": "isFinite", "message": "Please use Number.isFinite instead" }, { "object": "window", "property": "isFinite", "message": "Please use Number.isFinite instead" }, { "object": "global", "property": "isNaN", "message": "Please use Number.isNaN instead" }, { "object": "self", "property": "isNaN", "message": "Please use Number.isNaN instead" }, { "object": "window", "property": "isNaN", "message": "Please use Number.isNaN instead" }, { "property": "__defineGetter__", "message": "Please use Object.defineProperty instead." }, { "property": "__defineSetter__", "message": "Please use Object.defineProperty instead." }, { "object": "Math", "property": "pow", "message": "Use the exponentiation operator (**) instead." } ], "no-return-assign": ["error", "always"], "no-return-await": ["error"], "no-script-url": ["error"], "no-self-assign": [ "error", { "props": true } ], "no-self-compare": ["error"], "no-sequences": ["error"], "no-throw-literal": ["error"], "no-unmodified-loop-condition": ["off"], "no-unused-expressions": [ "error", { "allowShortCircuit": false, "allowTernary": false, "allowTaggedTemplates": false } ], "no-unused-labels": ["error"], "no-useless-call": ["off"], "no-useless-catch": ["error"], "no-useless-concat": ["error"], "no-useless-escape": ["error"], "no-useless-return": ["error"], "no-void": ["error"], "no-warning-comments": [ "off", { "terms": ["todo", "fixme", "xxx"], "location": "start" } ], "no-with": ["error"], "prefer-promise-reject-errors": [ "error", { "allowEmptyReject": true } ], "prefer-named-capture-group": ["off"], "prefer-regex-literals": ["off"], "radix": ["error"], "require-await": ["off"], "require-unicode-regexp": ["off"], "vars-on-top": ["error"], "yoda": ["error"] }, "settings": { "import/resolver": { "node": { "extensions": [".mjs", ".js", ".json"] } }, "import/extensions": [".js", ".mjs", ".jsx"], "import/core-modules": [], "import/ignore": ["node_modules", "\\.(coffee|scss|css|less|hbs|svg|json)$"] }, "ignorePatterns": ["/build/", "/test-output/"] } ```
ljharb commented 3 years ago

@thernstig thanks; with that exact setup, on node v14.15.1, i'm unable to reproduce your issue. i only get 1:7 error 'fsp' is assigned a value but never used no-unused-vars.

To confirm, you're seeing this error in a real terminal, not in vscode's fake terminal?

thernstig commented 3 years ago

@ljharb I am getting it both in the terminal running eslint as well as in VS Code. Let me try to track down what the real fault is then.

thernstig commented 3 years ago

@ljharb first of all, I want to say that I apologize for wasting your time with thinking this also happened in the CLI. It does not. I did not look at the correct package in package-lock.json when saying I had the right version of `"resolve"´. Normally a mistake I do not do, and feel bad for wasting your precious time.

With that said, it does work now, except in VS Code (restarted it and all). Is that known?

screen

ljharb commented 3 years ago

vscode has its own version of node built in, and it might not be v14 - I’m not entirely sure, but I’d expect you can configure it to use your local version, and then eslint should work the same.

thernstig commented 3 years ago

Hm, the built-in version should not be related to what ESLint reports there. It should use the one we have in the environment. But I will investigate further and let this thread die. At least eslint-plugin-import works :)

ljharb commented 3 years ago

eslint can't know what node versions are in your environment, it only knows what it's being ran with.

thernstig commented 3 years ago

I submitted an issue on the VS Code ESLint plugin to ask about this, because e.g. in Python, the linters can know via the environment what version of Python is used. Albeit that is Python and not Node.js.

ljharb commented 3 years ago

right - the version of node it's using is what it knows.

nosvalds commented 3 years ago

For anyone that finds this still. VSCode still ships with v12 Node where fs/promises is not available.

You can solve this by adding the following VSCode setting, to use your system node.

{
     "eslint.runtime": "node"
}

https://github.com/microsoft/vscode-eslint/issues/1097

thernstig commented 3 years ago

And for even more info, that config above cannot be used in your User config (only remote config or workspace config). For this discussion check https://github.com/microsoft/vscode-eslint/issues/1188, which then lead to me creating a VS Code issue, see https://github.com/microsoft/vscode/issues/119183. If they fix that one, you will be able to set the above in your User settings as well.