0

这个错误是什么意思?我该如何解决?:

/home/jmunsch/PycharmProjects/testing/node_modules/gulp-eslint/node_modules/eslint/lib/eslint.js:706
                    throw ex;
                    ^

TypeError: Error while loading rule 'react/jsx-key': ruleCreator is not a function
    at /home/jmunsch/PycharmProjects/testing/node_modules/gulp-eslint/node_modules/eslint/lib/eslint.js:692:28
    at Array.forEach (<anonymous>)
    at EventEmitter.module.exports.api.verify (/home/jmunsch/PycharmProjects/testing/node_modules/gulp-eslint/node_modules/eslint/lib/eslint.js:671:16)
    at processText (/home/jmunsch/PycharmProjects/testing/node_modules/gulp-eslint/node_modules/eslint/lib/cli-engine.js:230:27)
    at CLIEngine.executeOnText (/home/jmunsch/PycharmProjects/testing/node_modules/gulp-eslint/node_modules/eslint/lib/cli-engine.js:686:26)
    at verify (/home/jmunsch/PycharmProjects/testing/node_modules/gulp-eslint/index.js:20:23)
    at Transform._transform (/home/jmunsch/PycharmProjects/testing/node_modules/gulp-eslint/index.js:68:18)
    at Transform._read (_stream_transform.js:186:10)
    at Transform._write (_stream_transform.js:174:12)
    at doWrite (_stream_writable.js:396:12)
    at writeOrBuffer (_stream_writable.js:382:5)
    at Transform.Writable.write (_stream_writable.js:290:11)
    at write (/home/jmunsch/PycharmProjects/testing/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/home/jmunsch/PycharmProjects/testing/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (/home/jmunsch/PycharmProjects/testing/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:664:5)
    at emitNone (events.js:106:13)
    at DestroyableTransform.emit (events.js:208:7)
    at emitReadable_ (/home/jmunsch/PycharmProjects/testing/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:448:10)
    at emitReadable (/home/jmunsch/PycharmProjects/testing/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:444:5)
    at readableAddChunk (/home/jmunsch/PycharmProjects/testing/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:187:9)
    at DestroyableTransform.Readable.push (/home/jmunsch/PycharmProjects/testing/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:149:10)
    at DestroyableTransform.Transform.push (/home/jmunsch/PycharmProjects/testing/node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_transform.js:145:32)
4

1 回答 1

0

我发布了一个问题和答案,因为没有太多地方可以找到有关 eslint 的信息ruleCreator,以及这个特定错误的含义。

但是,请参阅:

例如查看我定义的规则类型,我在 eslint.js 中添加了一个 console.log:

[11:50:44] Starting 'lintTest'...
comma-dangle
no-cond-assign
no-console
no-constant-condition
no-control-regex
no-debugger
no-dupe-args
no-dupe-keys
no-duplicate-case
no-empty
no-ex-assign
no-extra-boolean-cast
no-extra-semi
no-func-assign
no-inner-declarations
no-invalid-regexp
no-irregular-whitespace
no-negated-in-lhs
no-obj-calls
no-regex-spaces
no-sparse-arrays
no-unreachable
use-isnan
valid-jsdoc
valid-typeof
consistent-return
curly
default-case
dot-notation
eqeqeq
guard-for-in
no-alert
no-caller
no-div-regex
no-empty-label
no-eq-null
no-eval
no-extend-native
no-extra-bind
no-fallthrough
no-floating-decimal
no-implied-eval
no-iterator
no-labels
no-lone-blocks
no-loop-func
no-multi-spaces
no-multi-str
no-native-reassign
no-new
no-new-func
no-new-wrappers
no-octal
no-octal-escape
no-param-reassign
no-process-env
no-proto
no-redeclare
no-script-url
no-self-compare
no-sequences
no-throw-literal
no-unused-expressions
no-void
no-with
vars-on-top
wrap-iife
no-catch-shadow
no-delete-var
no-label-var
no-shadow
no-shadow-restricted-names
no-undef
no-undef-init
no-undefined
no-unused-vars
no-use-before-define
jsx-quotes
indent
brace-style
comma-spacing
comma-style
consistent-this
eol-last
key-spacing
max-nested-callbacks
new-cap
new-parens
no-array-constructor
no-lonely-if
no-mixed-spaces-and-tabs
no-multiple-empty-lines
no-nested-ternary
no-new-object
no-spaced-func
no-trailing-spaces
one-var
padded-blocks
quote-props
quotes
semi
semi-spacing
space-after-keywords
space-before-blocks
space-before-function-paren
space-in-parens
space-infix-ops
space-unary-ops
no-var
generator-star-spacing
max-depth
max-len
max-params
react/jsx-key
/home/jmunsch/PycharmProjects/testing/node_modules/gulp-eslint/node_modules/eslint/lib/eslint.js:706
                    throw ex;
                    ^

这表明在配置中定义了一个规则“re​​act/jsx-key”,但 eslint 不知道如何查找该规则。

我意识到我缺少规则定义/模式的依赖关系。

我通过以下方式解决了我的问题:

rm -rf node_modules
npm i
npm i --save-dev eslint-plugin-react

有关更多详细信息,请参阅:

于 2019-04-11T17:30:43.990 回答