question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Eslint config based prettying

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sirpeascommented, Apr 17, 2017

@kentcdodds sure but unfortunately I didn’t have spare time, I will do it this week

1reaction
sirpeascommented, Mar 14, 2017

@kentcdodds sounds like a plan for spare time at the weekend 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

pvdlg/eslint-config-pretty - GitHub
A set of shareable eslint configs. Contribute to pvdlg/eslint-config-pretty development by creating an account on GitHub.
Read more >
eslint-config-pretty - npm
Modular ESLint configuration that works well with prettier. Latest version: 2.1.1, last published: 5 years ago.
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Setting up efficient workflows with ESLint, Prettier and ...
On a Linux-based operating system just type mkdir lint-examples in the command-line and then change to this directory with cd lint-examples . Install...
Read more >
How to use Prettier with ESLint - Robin Wieruch
The Prettier configuration file itself and the "format on save"-feature should be pretty similar in most environments.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found