Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Eslint config based prettying #85

Closed
sirpeas opened this issue Mar 13, 2017 · 3 comments
Closed

Eslint config based prettying #85

sirpeas opened this issue Mar 13, 2017 · 3 comments
Labels

Comments

@sirpeas
Copy link

sirpeas commented Mar 13, 2017

Hey, there is something wrong with reading eslint configuration I guess.

Greetings

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 eslint 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"]
  }
}
@robwise
Copy link
Collaborator

robwise commented Mar 13, 2017

Hey @Belir, thanks for reporting! It looks from the stack trace that this is coming out of prettier-eslint, so this might be an error with that package as opposed to the plugin. If you install the prettier-eslint-cli and run it directly (instead of using atom-prettier), does it still happen?

@sirpeas
Copy link
Author

sirpeas commented Mar 13, 2017

@robwise unfortunately yes, here's an output:

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

@robwise
Copy link
Collaborator

robwise commented Mar 13, 2017

@Belir Okay in that case, can you post this over at that repo since it's not actually a problem with the plugin's code? I will close this since it's a prettier-eslint issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants