Hey,
based on:
https://github.com/jlongster/prettier-atom/issues/85#issuecomment-286129306
there is something wrong with reading eslint configuration.
prettier-atom: TypeError: Cannot read property 'indexOf' of undefined
TypeError: Cannot read property 'indexOf' of undefined
at isAlways (/Users/patrykpeas/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:187:13)
at Array.some (native)
at getValFromObjectConfig (/Users/patrykpeas/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:131:33)
at getTrailingComma (/Users/patrykpeas/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:118:14)
at /Users/patrykpeas/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:91:50
at Array.reduce (native)
at getPrettierOptionsFromESLintRules (/Users/patrykpeas/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:87:37)
at getOptionsForFormatting (/Users/patrykpeas/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/utils.js:34:18)
at format (/Users/patrykpeas/.atom/packages/prettier-atom/node_modules/prettier-eslint/dist/index.js:79:62)
at /Users/patrykpeas/.atom/packages/prettier-atom/dist/executePrettier.js:33:16
at exports.allowUnsafeNewFunction (/Users/patrykpeas/.atom/packages/prettier-atom/node_modules/loophole/lib/loophole.js:25:14)
at executePrettier (/Users/patrykpeas/.atom/packages/prettier-atom/dist/executePrettier.js:32:14)
at executePrettierOnBufferRange (/Users/patrykpeas/.atom/packages/prettier-atom/dist/executePrettier.js:45:21)
at formatOnSaveIfAppropriate (/Users/patrykpeas/.atom/packages/prettier-atom/dist/formatOnSave.js:36:5)
at lazyFormatOnSave (/Users/patrykpeas/.atom/packages/prettier-atom/dist/main.js:31:15)
at /Users/patrykpeas/.atom/packages/prettier-atom/dist/main.js:45:12
at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:129:28)
at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1059:20)
at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1048:19)
at TextEditor.module.exports.TextEditor.save (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:915:26)
at Pane.module.exports.Pane.saveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:753:18)
at Pane.saveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:3:59)
at Pane.module.exports.Pane.saveActiveItem (/Applications/Atom.app/Contents/Resources/app.asar/src/pane.js:736:19)
at Workspace.module.exports.Workspace.saveActivePaneItem (/Applications/Atom.app/Contents/Resources/app.asar/src/workspace.js:693:35)
at atom-workspace.core:save (/Applications/Atom.app/Contents/Resources/app.asar/src/register-default-commands.js:225:32)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:259:29)
at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:59
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:599:16)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:390:22)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:106:36)
at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:3:59)
Used configuration
{
"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"settings": {
"import/resolver": {
"webpack": {
"config": "config/webpack/config.js"
}
}
},
"env": {
"es6": true,
"browser": true
},
"plugins": [
],
"globals": {
"document": false,
"window": false
},
"rules": {
"no-cond-assign": "error",
"no-console": ["error", {
"allow": ["warn", "error", "info"]
}],
"no-constant-condition": "error",
"no-debugger": "error",
"no-alert": "error",
"no-dupe-args": "error",
"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-extra-parens": "error",
"no-extra-semi": "error",
"no-func-assign": "error",
"no-invalid-regexp": "error",
"no-irregular-whitespace": ["error", {
"skipComments": true,
"skipStrings": true,
"skipTemplates": true
}],
"no-obj-calls": "error",
"no-regex-spaces": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-unreachable": "error",
"no-unsafe-finally": "error",
"array-callback-return": "error",
"curly": "error",
"default-case": "error",
"dot-location": ["error", "property"],
"no-caller": "error",
"no-empty-function": "error",
"no-empty-pattern": "error",
"no-fallthrough": "error",
"no-global-assign": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-octal": "error",
"no-redeclare": "error",
"no-return-assign": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "error",
"yoda": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-unused-vars": "error",
"no-use-before-define": "error",
"array-bracket-spacing": ["error", "never"],
"block-spacing": "error",
"brace-style": ["error", "1tbs", {
"allowSingleLine": true
}],
"comma-spacing": "error",
"comma-style": ["error", "last"],
"computed-property-spacing": "error",
"eol-last": "error",
"func-call-spacing": "error",
"indent": ["error", 2],
"jsx-quotes": ["error", "prefer-double"],
"key-spacing": "error",
"keyword-spacing": "error",
"new-parens": "error",
"no-multiple-empty-lines": ["error", {
"max": 1,
"maxEOF": 1,
"maxBOF": 0
}],
"no-trailing-spaces": "error",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"object-curly-newline": "error",
"object-curly-spacing": "error",
"object-property-newline": ["error", {
"allowMultiplePropertiesPerLine": true
}],
"one-var": ["error", "never"],
"quotes": "error",
"semi": "error",
"semi-spacing": "error",
"space-before-function-paren": ["error", "never"],
"space-in-parens": "error",
"space-infix-ops": "error",
"template-tag-spacing": "error",
"arrow-body-style": ["error", "as-needed"],
"arrow-parens": ["error", "as-needed"],
"arrow-spacing": "error",
"no-const-assign": "error",
"no-dupe-class-members": "error",
"no-duplicate-imports": "error",
"no-this-before-super": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"prefer-const": "error",
"prefer-template": "error",
"require-yield": "error",
"rest-spread-spacing": "error",
"yield-star-spacing": "error",
"generator-star-spacing": ["error", {
"before": false,
"after": true
}],
"no-unsafe-negation": "error",
"use-isnan": "error",
"consistent-return": "error",
"no-case-declarations": "error",
"no-implicit-globals": "error",
"no-undefined": "error",
"camelcase": "error",
"comma-dangle": ["error", {
"imports": "never",
"exports": "never"
}],
"indent": ["error", 2],
"quotes": ["error", "double"]
}
}
and output from prettier-eslint-cli:
prettier-eslint-cli [ERROR]: There was an error formatting "./app/frontend/rails_ujs.js":
TypeError: Cannot read property 'indexOf' of undefined
at isAlways (/Users/patrykpeas/code/***/node_modules/prettier-eslint/dist/utils.js:187:13)
at Array.some (native)
at getValFromObjectConfig (/Users/patrykpeas/code/***/node_modules/prettier-eslint/dist/utils.js:131:33)
at getTrailingComma (/Users/patrykpeas/code/***/node_modules/prettier-eslint/dist/utils.js:118:14)
at /Users/patrykpeas/code/***/node_modules/prettier-eslint/dist/utils.js:91:50
at Array.reduce (native)
at getPrettierOptionsFromESLintRules (/Users/patrykpeas/code/***/node_modules/prettier-eslint/dist/utils.js:87:37)
at getOptionsForFormatting (/Users/patrykpeas/code/***/node_modules/prettier-eslint/dist/utils.js:34:18)
at format (/Users/patrykpeas/code/***/node_modules/prettier-eslint/dist/index.js:79:62)
at MapSubscriber.project (/Users/patrykpeas/code/***/node_modules/prettier-eslint-cli/dist/format-files.js:276:55)
failure formatting 1 file with prettier-eslint
Hi there! Here's the problem. These should probably have a default value (learn more about destructuring here, learn about default values specifically here). arrays, objects, and functions should default to an empty string. Either that, or we should add a default param here (learn more about that here) where val defaults to an empty string.
How would you like to add another test case or two here and implement those fixes?
Thanks!
@kentcdodds sounds like a plan for spare time at the weekend ;)
That line of code has moved to here do you still wanna do this?
@kentcdodds sure but unfortunately I didn't have spare time, I will do it this week
@kentcdodds is there any way of testing if my code is fixing that in action and I probably will need your help with test coverage :)
Add a test case or so here: https://github.com/prettier/prettier-eslint/blob/a7cc1de8c534432fa4ffb8ffe47973c978737f33/src/utils.test.js#L170
Thanks!
@kentcdodds thanks for opportunity and apologize for delay :)