import-js / eslint-plugin-import

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

[no-unused-modules] The "path" argument must be of type string. Received undefined #1931

Closed exodus4d closed 3 years ago

exodus4d commented 3 years ago

After ESLint upgrade 7.11.07.12.0 I noticed an error:

Oops! Something went wrong! :(

ESLint: 7.12.0

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:124:11)
    at Object.extname (path.js:752:5)
    at loadConfigFile (G:\webpages\pathfinder\node_modules\@eslint\eslintrc\lib\config-array-factory.js:305:18)
    at ConfigArrayFactory._loadConfigData (G:\webpages\pathfinder\node_modules\@eslint\eslintrc\lib\config-array-factory.js:613:42)
    at ConfigArrayFactory._loadExtendedBuiltInConfig (G:\webpages\pathfinder\node_modules\@eslint\eslintrc\lib\config-array-factory.js:803:25)
    at ConfigArrayFactory._loadExtends (G:\webpages\pathfinder\node_modules\@eslint\eslintrc\lib\config-array-factory.js:780:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (G:\webpages\pathfinder\node_modules\@eslint\eslintrc\lib\config-array-factory.js:724:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (G:\webpages\pathfinder\node_modules\@eslint\eslintrc\lib\config-array-factory.js:669:20)
    at _normalizeObjectConfigData.next (<anonymous>)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! pathfinder-eve@2.0.0 eslint: `eslint ".eslintrc.json" ".\js\app\conf\appConfig.mjs"`
npm ERR! Exit status 2

The origin issue (https://github.com/eslint/eslint/issues/13789) was opened inESLint project, because it was unclear where it came from.
I could narrow the Error down to import/no-unused-modules:

 "import/no-unused-modules": [
      "warn",    // <== change to "off" works :)
      {
        "missingExports": false,
        "unusedExports": true
      }
    ]

Im willing to provide you any additional info or console.debug() output that could help :D Let me know


Config details (if nedded):

Configuration `.eslintrc.json` ```json { "env": { "browser": true, "es6": true, "es2021": true, "amd": true, "node": true }, "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:jsdoc/recommended" ], "globals": {}, "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": 2020, "sourceType": "module", "ecmaFeatures": { "impliedStrict": true }, "project": "./tsconfig.eslint.json", "extraFileExtensions": [".mjs", ".d.ts", ".json"] }, "plugins": [ "@typescript-eslint", "import", "jsdoc", "json" ], "reportUnusedDisableDirectives": true, "root": true, "rules": { "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": [ "error", { "allow": ["ok", "pf", "brand", "info", "warn", "error", "debug", "group", "groupCollapsed", "groupEnd", "table"] } ], "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-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-unexpected-multiline": "error", "no-unreachable": "error", "no-unreachable-loop": [ "off", { "ignore": [] } ], "no-unsafe-finally": "error", "no-unsafe-negation": "error", "no-useless-backreference": "off", "require-atomic-updates": "off", "use-isnan": "error", "valid-typeof": [ "error", { "requireStringLiterals": true } ], "accessor-pairs": "off", "array-callback-return": [ "error", { "allowImplicit": true } ], "block-scoped-var": "error", "class-methods-use-this": [ "error", { "exceptMethods": [] } ], "complexity": [ "off", 11 ], "consistent-return": "off", "curly": ["error", "multi-line"], "default-case": [ "error", { "commentPattern": "^no default$" } ], "default-case-last": "off", "dot-location": ["error", "property"], "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-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-floating-decimal": "error", "no-global-assign": [ "error", { "exceptions": [] } ], "no-implicit-coercion": [ "off", { "boolean": false, "number": true, "string": true, "allow": [] } ], "no-implicit-globals": "off", "no-implied-eval": "error", "no-iterator": "error", "no-labels": [ "error", { "allowLoop": false, "allowSwitch": false } ], "no-lone-blocks": "error", "no-loop-func": "error", "no-multi-spaces": [ "error", { "ignoreEOLComments": true, "exceptions": { "VariableDeclarator": true, "ImportDeclaration": true } } ], "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": [ "warn", { "props": false } ], "no-proto": "error", "no-restricted-properties": [ "error", { "property": "__defineGetter__", "message": "Please use Object.defineProperty instead." }, { "property": "__defineSetter__", "message": "Please use Object.defineProperty instead." }, { "object": "global", "property": "isFinite", "message": "Please use Number.isFinite instead" }, { "object": "global", "property": "isNaN", "message": "Please use Number.isNaN instead" }, { "object": "window", "property": "isFinite", "message": "Please use Number.isFinite instead" }, { "object": "window", "property": "isNaN", "message": "Please use Number.isNaN instead" }, { "object": "self", "property": "isFinite", "message": "Please use Number.isFinite instead" }, { "object": "self", "property": "isNaN", "message": "Please use Number.isNaN instead" }, { "object": "arguments", "property": "callee", "message": "arguments.callee is deprecated" }, { "object": "Math", "property": "pow", "message": "Use the exponentiation operator (**) instead." } ], "no-return-assign": ["error", "except-parens"], "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-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": [ "off", { "allowEmptyReject": true } ], "prefer-named-capture-group": "off", "prefer-regex-literals": "off", "radix": "error", "require-unicode-regexp": "off", "vars-on-top": "error", "wrap-iife": [ "error", "outside", { "functionPrototypeMethods": false } ], "yoda": "error", "strict": ["error", "never"], "no-delete-var": "error", "no-label-var": "error", "no-restricted-globals": [ "error", "isFinite", "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-restricted-names": "error", "no-undef": [ "error", { "typeof": false } ], "no-undef-init": "error", "no-undefined": "off", "array-bracket-newline": [ "off", "consistent" ], "array-bracket-spacing": [ "error", "never" ], "array-element-newline": [ "off", { "multiline": true, "minItems": 3 } ], "block-spacing": [ "error", "always" ], "camelcase": [ "error", { "properties": "never", "ignoreDestructuring": false } ], "capitalized-comments": [ "off", "never", { "line": { "ignorePattern": ".*", "ignoreInlineComments": true, "ignoreConsecutiveComments": true }, "block": { "ignorePattern": ".*", "ignoreInlineComments": true, "ignoreConsecutiveComments": true } } ], "comma-dangle": [ "error", "never" ], "comma-style": [ "error", "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": [ "error", "never" ], "consistent-this": "off", "eol-last": "off", "func-name-matching": [ "off", "always", { "includeCommonJSModuleExports": false, "considerPropertyDescriptor": true } ], "func-names": [ "error", "as-needed", { "generators": "as-needed" } ], "func-style": [ "off", "expression" ], "function-call-argument-newline": [ "off", "consistent" ], "function-paren-newline": [ "error", "consistent" ], "id-blacklist": "off", "id-denylist": "off", "id-length": "off", "id-match": "off", "implicit-arrow-linebreak": [ "error", "beside" ], "jsx-quotes": [ "off", "prefer-single" ], "key-spacing": [ "error", { "singleLine": { "beforeColon": false, "afterColon": true, "mode": "strict" }, "multiLine": { "beforeColon": false, "afterColon": true, "mode": "strict", "align": "value" } } ], "line-comment-position": [ "off", { "position": "above", "ignorePattern": "", "applyDefaultPatterns": true } ], "linebreak-style": [ "error", "unix" ], "lines-around-comment": "off", "lines-around-directive": [ "error", { "before": "always", "after": "always" } ], "max-depth": [ "off", 4 ], "max-len": [ "error", { "code": 140, "tabWidth": 4, "comments": 200, "ignoreUrls": true, "ignoreComments": false, "ignoreTrailingComments": true, "ignoreRegExpLiterals": true, "ignoreStrings": true, "ignoreTemplateLiterals": true } ], "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" ], "multiline-ternary": [ "off", "never" ], "new-cap": [ "error", { "newIsCap": true, "newIsCapExceptions": [], "capIsNew": false, "capIsNewExceptions": [ "Immutable.Map", "Immutable.Set", "Immutable.List" ] } ], "new-parens": "error", "newline-after-var": "off", "newline-before-return": "off", "newline-per-chained-call": [ "error", { "ignoreChainWithDepth": 4 } ], "no-bitwise": "error", "no-continue": "error", "no-inline-comments": "off", "no-lonely-if": "error", "no-mixed-operators": [ "error", { "groups": [ [ "%", "**" ], [ "%", "+" ], [ "%", "-" ], [ "%", "*" ], [ "%", "/" ], [ "/", "*" ], [ "&", "|", "<<", ">>", ">>>" ], [ "==", "!=", "===", "!==" ], [ "&&", "||" ] ], "allowSamePrecedence": true } ], "no-mixed-spaces-and-tabs": "error", "no-multi-assign": [ "error" ], "no-multiple-empty-lines": [ "error", { "max": 2, "maxBOF": 0, "maxEOF": 0 } ], "no-negated-condition": "off", "no-nested-ternary": "off", "no-new-object": "error", "no-plusplus": "off", "no-restricted-syntax": [ "error", { "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-spaced-func": "error", "no-tabs": "error", "no-ternary": "off", "no-trailing-spaces": [ "error", { "skipBlankLines": false, "ignoreComments": false } ], "no-underscore-dangle": [ "error", { "allowAfterThis": true, "allowAfterSuper": false, "allowAfterThisConstructor": false, "enforceInMethodNames": false, "allowFunctionParams": false } ], "no-unneeded-ternary": [ "error", { "defaultAssignment": false } ], "no-whitespace-before-property": "error", "nonblock-statement-body-position": [ "error", "beside", { "overrides": { "while": "below" } } ], "object-curly-newline": [ "error", { "ObjectExpression": { "minProperties": 5, "multiline": true, "consistent": true }, "ObjectPattern": { "minProperties": 5, "multiline": true, "consistent": true }, "ImportDeclaration": { "minProperties": 5, "multiline": true, "consistent": true }, "ExportDeclaration": { "minProperties": 5, "multiline": true, "consistent": true } } ], "object-curly-spacing": [ "error", "never" ], "object-property-newline": [ "error", { "allowAllPropertiesOnSameLine": true } ], "one-var": [ "error", "never" ], "one-var-declaration-per-line": [ "error", "always" ], "operator-assignment": [ "error", "always" ], "operator-linebreak": [ "error", "after", { "overrides": { "=": "none" } } ], "padded-blocks": [ "error", { "classes": "always", "blocks": "never", "switches": "never" }, { "allowSingleLineBlocks": true } ], "padding-line-between-statements": [ "error", { "blankLine": "always", "prev": "class", "next": "*" }, { "blankLine": "never", "prev": "return", "next": "block" } ], "prefer-exponentiation-operator": "off", "prefer-object-spread": "warn", "quote-props": [ "error", "as-needed", { "keywords": false, "unnecessary": true, "numbers": false } ], "require-jsdoc": "off", "semi-spacing": [ "error", { "before": false, "after": true } ], "semi-style": [ "error", "last" ], "sort-keys": [ "off", "asc", { "caseSensitive": false, "natural": true } ], "sort-vars": "off", "space-before-blocks": "error", "space-in-parens": [ "error", "never" ], "space-infix-ops": "error", "space-unary-ops": [ "error", { "words": true, "nonwords": false, "overrides": {} } ], "spaced-comment": [ "error", "always", { "line": { "exceptions": [ "-", "+" ], "markers": [ "=", "!", "/" ] }, "block": { "exceptions": [ "-", "+" ], "markers": [ "=", "!", ":", "::" ], "balanced": true } } ], "switch-colon-spacing": [ "error", { "after": true, "before": false } ], "template-tag-spacing": [ "error", "never" ], "unicode-bom": [ "error", "never" ], "wrap-regex": "off", "arrow-body-style": "off", "arrow-spacing": [ "error", { "before": true, "after": true } ], "arrow-parens": "off", "constructor-super": "error", "generator-star-spacing": [ "error", { "before": false, "after": true } ], "no-class-assign": "error", "no-confusing-arrow": [ "error", { "allowParens": true } ], "no-const-assign": "error", "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-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-rest-params": "error", "prefer-spread": "error", "prefer-template": "error", "require-yield": "error", "rest-spread-spacing": ["error", "never"], "sort-imports": [ "off", { "ignoreCase": false, "ignoreDeclarationSort": false, "ignoreMemberSort": false, "memberSyntaxSortOrder": ["none", "all", "multiple", "single"] } ], "symbol-description": "error", "template-curly-spacing": "error", "yield-star-spacing": ["error", "after"], "brace-style": "off", "@typescript-eslint/brace-style": [ "error", "1tbs", { "allowSingleLine": true } ], "comma-spacing": "off", "@typescript-eslint/comma-spacing": [ "error", { "before": false, "after": true } ], "default-param-last": "off", "@typescript-eslint/default-param-last": ["error"], "dot-notation": "off", "@typescript-eslint/dot-notation": [ "error", { "allowKeywords": true } ], "func-call-spacing": "off", "@typescript-eslint/func-call-spacing": ["error", "never"], "indent": "off", "@typescript-eslint/indent": [ "error", 4, { "ArrayExpression": 1, "CallExpression": { "arguments": 1 }, "FunctionDeclaration": { "parameters": 1, "body": 1 }, "FunctionExpression": { "parameters": 1, "body": 1 }, "ImportDeclaration": 1, "ObjectExpression": 1, "SwitchCase": 1, "VariableDeclarator": { "var": 2, "let": 2, "const": 3 }, "flatTernaryExpressions": false, "ignoreComments": false, "ignoredNodes": [], "outerIIFEBody": 1 } ], "init-declarations": "off", "@typescript-eslint/init-declarations": ["off"], "keyword-spacing": "off", "@typescript-eslint/keyword-spacing": [ "error", { "before": true, "after": true, "overrides": { "return": { "after": true }, "throw": { "after": true }, "case": { "after": true } } } ], "lines-between-class-members": "off", "@typescript-eslint/lines-between-class-members": [ "error", "always", { "exceptAfterSingleLine": false } ], "no-array-constructor": "off", "@typescript-eslint/no-array-constructor": ["off"], "no-dupe-class-members": "off", "@typescript-eslint/no-dupe-class-members": ["error"], "no-duplicate-imports": "off", "@typescript-eslint/no-duplicate-imports": ["error"], "no-empty-function": "off", "@typescript-eslint/no-empty-function": [ "error", { "allow": ["arrowFunctions", "functions", "methods"] } ], "no-extra-parens": "off", "@typescript-eslint/no-extra-parens": [ "off", "all", { "conditionalAssign": true, "nestedBinaryExpressions": true, "returnAssign": false, "enforceForArrowConditionals": false } ], "no-extra-semi": "off", "@typescript-eslint/no-extra-semi": ["error"], "no-invalid-this": "off", "@typescript-eslint/no-invalid-this": ["error"], "no-loss-of-precision": "off", "@typescript-eslint/no-loss-of-precision": ["error"], "no-magic-numbers": "off", "@typescript-eslint/no-magic-numbers": [ "off", { "ignore": [], "ignoreArrayIndexes": true, "enforceConst": true, "detectObjects": false } ], "no-redeclare": "off", "@typescript-eslint/no-redeclare": ["error"], "no-shadow": "off", "@typescript-eslint/no-shadow": ["off", { "builtinGlobals": true, "hoist": "never", "ignoreTypeValueShadow": false, "ignoreFunctionTypeParameterNameValueShadow": false }], "no-unused-expressions": "off", "@typescript-eslint/no-unused-expressions": [ "error", { "allowShortCircuit": false, "allowTernary": false, "allowTaggedTemplates": false } ], "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": [ "warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": true, "argsIgnorePattern": "[iI]gnored" } ], "no-use-before-define": "off", "@typescript-eslint/no-use-before-define": [ "error", { "functions": true, "classes": true, "variables": true, "typedefs": true } ], "no-useless-constructor": "off", "@typescript-eslint/no-useless-constructor": ["error"], "quotes": "off", "@typescript-eslint/quotes": [ "error", "single", { "allowTemplateLiterals": true } ], "require-await": "off", "@typescript-eslint/require-await": "error", "no-return-await": "off", "@typescript-eslint/return-await": ["error", "in-try-catch"], "semi": "off", "@typescript-eslint/semi": ["error", "always"], "space-before-function-paren": "off", "@typescript-eslint/space-before-function-paren": ["error", "never"], "@typescript-eslint/explicit-module-boundary-types": "off", "import/default": "error", "import/named": "error", "import/namespace": "error", "import/no-absolute-path": "error", "import/no-cycle": "error", "import/no-internal-modules": "off", "import/no-self-import": "error", "import/no-unresolved": "error", "import/no-useless-path-segments": [ "error", { "noUselessIndex": true } ], "import/export": "error", "import/no-deprecated": "warn", "import/no-mutable-exports": "warn", "import/no-named-as-default": "warn", "import/no-named-as-default-member": "warn", "import/no-unused-modules": [ "warn", { "missingExports": false, "unusedExports": true } ], "import/unambiguous": "warn", "import/no-amd": "warn", "import/extensions": [ "error", "ignorePackages", { "js": "never", "mjs": "never", "jsx": "never", "ts": "never", "tsx": "never" } ], "import/first": "error", "import/group-exports": "error", "import/newline-after-import": [ "error", { "count": 1 } ], "import/no-default-export": "error", "import/no-duplicates": "warn", "import/prefer-default-export": "off", "jsdoc/check-types": ["warn", { "unifyParentAndChildTypeChecks": true }], "jsdoc/require-jsdoc": [ "warn", { "checkConstructors": false, "checkGetters": true, "checkSetters": true, "contexts": ["ClassProperty"], "require": { "ArrowFunctionExpression": true, "ClassDeclaration": true, "ClassExpression": true, "FunctionDeclaration": true, "FunctionExpression": true, "MethodDefinition": true }, "enableFixer": true } ], "jsdoc/check-line-alignment": ["warn", "always"], "jsdoc/check-indentation": "warn", "jsdoc/check-param-names": [ "error", { "checkRestProperty": true, "enableFixer": true, "checkDestructured": true } ], "jsdoc/check-property-names": [ "error", { "enableFixer": true } ], "jsdoc/check-syntax": "warn", "jsdoc/empty-tags": "error", "jsdoc/require-hyphen-before-param-description": ["warn", "never"], "jsdoc/require-description": [ "warn", { "contexts": [ "ClassDeclaration" ], "descriptionStyle": "any", "checkGetters": false, "checkSetters": false } ], "jsdoc/require-param": [ "error", { "enableFixer": true, "enableRootFixer": true, "enableRestElementFixer": true, "checkRestProperty": true, "autoIncrementBase": 0, "checkConstructors": true, "checkGetters": true, "checkSetters": true, "checkDestructured": true } ], "jsdoc/require-param-type": "warn", "jsdoc/require-param-description": "off", "jsdoc/require-returns": [ "warn", { "checkConstructors": false, "checkGetters": true, "forceRequireReturn": false, "forceReturnsWithAsync": false } ], "jsdoc/require-returns-check": "warn", "jsdoc/require-returns-type": "error", "jsdoc/require-returns-description": "off" }, "settings": { "import/cache": { "lifetime": 5 }, "import/extensions": [".js", ".mjs", ".ts", ".d.ts", ".json"], "import/external-module-folders": ["node_modules", "node_modules/@types"], "import/parsers": { "@typescript-eslint/parser": [".ts", ".d.ts"] }, "import/resolver": { "node": { "extensions": [".js", ".mjs", ".ts", ".d.ts",".json"] } }, "jsdoc": { "mode": "typescript", "ignorePrivate": true, "tagNamePreference": { "inheritDoc": { "message": "Lowercase is prefered", "replacement": "inheritdoc" } } } } } ```
Configuration `tsconfig.eslint.json` ```json { "extends": "./tsconfig.base.json", "include": [ "js/**/*", ".eslintrc.json", "tsconfig.json", "tsconfig.base.json", "tsconfig.eslint.json", "gulpfile.js", "jsdoc.json" ], "exclude": ["node_modules"] } ```
Configuration `tsconfig.base.json` ```json { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "ESNext", // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. "module": "ESNext", // Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. "lib": [ // Specify library files to be included in the compilation. "ES2020", "DOM", "WebWorker" ], "allowJs": true, // Allow javascript files to be compiled. "checkJs": true, // Report errors in .js files. //"outDir": "build", // Redirect output structure to the directory. //"rootDir": ".", // Specify the root directory of input files. Use to control the output directory structure with --outDir. // Strict Checks "alwaysStrict": true, // Parse in strict mode and emit "use strict" for each source file "strict": true, // Enable all strict type-checking options. "noImplicitAny": true, // Raise error on expressions and declarations with an implied 'any' type. "strictPropertyInitialization": true, // Module Resolution Options "esModuleInterop": false, // Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. // Advanced Options "resolveJsonModule": true // Include modules imported with '.json' extension //"skipLibCheck": true //"baseUrl": "." }, "include": ["./js/**/*"] } ```
package.json ```json { "name": "pathfinder-eve", "version": "2.0.0", "engines": { "node": "12.x" }, "description": "Pathfinder is a system mapping tool for EVE ONLINE", "root": true, "main": "index.php", "type": "module", "dependencies": { "easytimer.js": "^4.3.0", "jquery": "^3.5.1", "localforage": "^1.9.0", "mustache": "^4.0.1", "pnotify": "^5.1.2", "velocity-animate": "^2.0.6" }, "devDependencies": { "@types/node": "^14.14.2", "@typescript-eslint/eslint-plugin": "^4.5.0", "@typescript-eslint/parser": "^4.5.0", "ansi-colors": "^4.1.1", "eslint": "^7.12.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jsdoc": "^30.7.3", "eslint-plugin-json": "^2.x.x", "fancy-log": "^1.3.3", "file-extension": "^4.0.5", "flat": "^5.0.2", "gulp": "^4.0.2", "gulp-autoprefixer": "^7.0.1", "gulp-brotli": "^3.0.0", "gulp-bytediff": "1.0.x", "gulp-clean-css": "^4.3.0", "gulp-debug": "^4.0.0", "gulp-filter": "^6.0.0", "gulp-gzip": "1.x.x", "gulp-if": "^3.0.0", "gulp-image-resize": "^0.13.1", "gulp-imagemin": "^7.1.0", "gulp-jshint": "2.1.x", "gulp-rename": "^2.0.0", "gulp-requirejs-optimize": "1.3.x", "gulp-sass": "^4.1.0", "gulp-sourcemaps": "^2.6.5", "gulp-uglify": "^3.0.2", "imagemin-webp": "^6.0.0", "jshint": "^2.12.0", "jshint-stylish": "^2.x.x", "lodash.padend": "4.6.x", "module-lookup-amd": "^6.2.0", "node-notifier": "^8.0.0", "node-sass": "^4.14.1", "pretty-bytes": "^5.4.1", "promised-del": "1.0.x", "rollup": "^2.32.1", "rollup-plugin-amd": "^4.0.0", "slash": "^3.0.0", "terminal-table": "0.0.x", "typescript": "^4.0.3", "uglify-es": "^3.0.x" }, "scripts": { "gulp": "gulp", "eslint": "eslint", "eslint-find-option-rules": "eslint-find-rules" }, "repository": { "type": "git", "url": "git+https://github.com/exodus4d/pathfinder.git" }, "browserslist": [ "last 2 versions", "> 2%", "not dead", "not IE 11" ], "keywords": [ "pathfinder", "exodus 4d", "eve online", "wormhole", "mapping" ], "author": "Exodus 4D (https://github.com/exodus4d)", "license": "MIT", "bugs": { "url": "https://github.com/exodus4d/pathfinder/issues", "email": "pathfinder@exodus4d.de" }, "homepage": "https://github.com/exodus4d/pathfinder#readme", "private": true } ```
ljharb commented 3 years ago

Thanks for the report! A PR with a failing test case would be most helpful.

btmills commented 3 years ago

@ljharb I took a quick look at this in the process of diagnosing https://github.com/eslint/eslint/issues/13789. The eslint-plugin-import build will fail when tested against eslint v7.12.0. I just released v7.12.1, which also included a fix for some missing constructor defaults in an internal API. This exception no longer repros after that change.

While end users won't hit the exception described here anymore, the FileEnumerator class that no-unused-modules reaches into is not part of our public API. I expect it's something we'll explicitly hide as part of https://github.com/eslint/eslint/issues/13654. I also suspect but have not confirmed that there are some edge cases around ignored files that behave incorrectly when calling FileEnumerator that way.

This use case seems worthy of an RFC for a first-class supported API. Could it fit as part of the pre-linting hook for plugins that's been discussed in the parallel linting RFC? The import and TypeScript plugins are the two I'm aware of that most need an API for that, but I'm not yet sufficiently familiar with their respective implementation details to know exactly what's needed. That's been on my to-do list since it's at least a friction point if not a blocker for parallel linting.

ljharb commented 3 years ago

@btmills thanks a lot for confirming - I'm glad v7.12.1 fixes it.

I would love an officially supported API so we don't have to use internals any more. I'm not sure when I'll have time to write an RFC; hopefully I have a good chunk of time before v8 is imminent :-)

lavor commented 3 years ago

@ljharb I have a similar issue in the latest releases (eslint@7.15.0, eslint-plugin-import@2.22.1, eslint-import-resolver-webpack@0.13.0), but in my case, the received type is boolean (not undefined):

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type boolean (false)
Occurred while linting D:\++projects\++datlowe\ui\datlowe-layout\build_utils\webpack.config.babel.js:3

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type boolean (false)
    at Object.statSync (fs.js:1012:10)
    at Function.ExportMap.for (D:\++projects\++datlowe\ui\datlowe-layout\node_modules\eslint-plugin-import\src\ExportMap.js:305:20)
    at Function.get (D:\++projects\++datlowe\ui\datlowe-layout\node_modules\eslint-plugin-import\src\ExportMap.js:293:10)
    at forEach (D:\++projects\++datlowe\ui\datlowe-layout\node_modules\eslint-plugin-import\src\rules\namespace.js:49:35)
    at Array.forEach (<anonymous>)
    at Program (D:\++projects\++datlowe\ui\datlowe-layout\node_modules\eslint-plugin-import\src\rules\namespace.js:81:14)
    at D:\++projects\++datlowe\ui\datlowe-layout\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (D:\++projects\++datlowe\ui\datlowe-layout\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (D:\++projects\++datlowe\ui\datlowe-layout\node_modules\eslint\lib\linter\node-event-generator.js:254:26)
Process finished with exit code -1

I am using also eslint-import-resolver-webpack.

I think that this issue is connected to this breaking change in webpack 5.

The error occurs after I upgraded webpack to version 5. Webpack 5 does not provides polyfills now so I added fallbacks for node libraries like this:

resolve: {
            fallback: {
                fs: false,
                path: false, // path fallbacks as boolean
                stream: require.resolve('stream-browserify')
            }
        }

When I fallback path with polyfill (previously used in webpack 4), the error will disappear:

npm i -D path-browserify
resolve: {
            fallback: {
                fs: false,
                path: require.resolve('path-browserify'), // path fallbacks as polyfill
                stream: require.resolve('stream-browserify')
            }
        }
lavor commented 3 years ago

@btmills @ljharb What do you think about my above comment? Should I create new issue for that?

EDIT: above workaround (path fallbacks as polyfill) is working only in one of my libraries, but it is not working in two others. Resolving in same error as it is in the name of this issue:

ESLint: Resolve error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined (import/namespace)

These libraries have the same dependecies with regards to eslint:

$ npm ls eslint eslint-config-airbnb eslint-import-resolver-webpack eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-mocha eslint-plugin-react eslint-plugin-react-hooks babel-eslint
+-- babel-eslint@10.1.0
+-- eslint@7.15.0
+-- eslint-config-airbnb@18.2.1
+-- eslint-import-resolver-webpack@0.13.0
+-- eslint-plugin-import@2.22.1
+-- eslint-plugin-jsx-a11y@6.4.1
+-- eslint-plugin-mocha@8.0.0
+-- eslint-plugin-react@7.21.5
`-- eslint-plugin-react-hooks@4.2.0
lavor commented 3 years ago

I finally found out, what is probably going on. There is an issue in eslint-import-resolver-webpack, it is probably not compatible with webpack 5.

My library where the mentioned workaround is working does not use a function as external. But my two others libararie does, so there was an issue with passing undefined (and not string) to the argument of path.join.

For compatibility issue of eslint-import-resolver-webpack I am creating new issue https://github.com/benmosher/eslint-plugin-import/issues/1966, as I am getting new error now:

ESLint: 
Resolve error: TypeError: callback is not a function
    at D:\++projects\++datlowe\ui\datlowe-core\src\js\/externals.js:102:13
    at findExternal (D:\++projects\++datlowe\ui\datlowe-core\node_modules\eslint-import-resolver-webpack\index.js:330:15)
    at D:\++projects\++datlowe\ui\datlowe-core\node_modules\eslint-import-resolver-webpack\index.js:321:49
    at Array.some (<anonymous>)
    at findExternal (D:\++projects\++datlowe\ui\datlowe-core\node_modules\eslint-import-resolver-webpack\index.js:321:22)
    at Object.exports.resolve (D:\++projects\++datlowe\ui\datlowe-core\node_modules\eslint-import-resolver-webpack\index.js:135:7)
    at v2 (D:\++projects\++datlowe\ui\datlowe-core\node_modules\eslint-module-utils\resolve.js:117:23)
    at withResolver (D:\++projects\++datlowe\ui\datlowe-core\node_modules\eslint-module-utils\resolve.js:122:16)
    at fullResolve (D:\++projects\++datlowe\ui\datlowe-core\node_modules\eslint-module-utils\resolve.js:139:22)
    at relative (D:\++projects\++datlowe\ui\datlowe-core\node_modules\eslint-module-utils\resolve.js:84:10)
(import/namespace)

My function for resolving external is looking like this:

// there was change of API in webpack 5
// webpack 4 version looks line this
// function(context, request, callback) {
function({context, request}, callback) {
            const modulePath = path.join(context || '', request || '');
            if (/node_modules[/\\]/.test(modulePath)) {
                const splittedPath = modulePath.split(/node_modules[/\\]/);
                if (splittedPath && splittedPath.length > 0) {
                    // if request is not a relative path starting with dot (.), use request instead of the whole module path
                    const externalModulePath = /^\./.test(request) ? splittedPath[splittedPath.length - 1] : request;
                    // the externalized module is referenced as a commonjs module
                    return callback(null, `commonjs ${externalModulePath}`);
                }
            }

            // Continue without externalizing the import
            callback();
        }
ljharb commented 3 years ago

Closing, since the original issue is resolved.