prettier / prettier-eslint Goto Github PK
View Code? Open in Web Editor NEWCode :arrow_right: prettier :arrow_right: eslint --fix :arrow_right: Formatted Code :sparkles:
Home Page: http://npm.im/prettier-eslint
License: MIT License
Code :arrow_right: prettier :arrow_right: eslint --fix :arrow_right: Formatted Code :sparkles:
Home Page: http://npm.im/prettier-eslint
License: MIT License
Hi,
Comments made are automatically in moved to a new line but without //.
I hope there could be a fix for that!
Thanks!
When using prettier-eslint with my .eslintrc I get an error. Any thoughts on what it may be? I used the trace loglevel and got the output below. This is not all the output, but the inferred options and the file that was being linted. I am also using eslint-plugin-prettier. I have a rule for it in .eslintrc:
"prettier/prettier": [
"error",
{
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120
}
]
prettier-eslint [DEBUG]: inferred options: Object {
"eslintConfig": Object {
"ecmaFeatures": Object {
"jsx": true,
},
"env": Object {
"browser": true,
"es6": true,
"node": true,
},
"extends": Array [
"airbnb",
"plugin:flowtype/recommended",
"/Users/awesome/Sites/maggie/node_modules/eslint-config-airbnb/rules/react.js",
"/Users/awesome/Sites/maggie/node_modules/eslint-config-airbnb/rules/react-a11y.js",
"/Users/awesome/Sites/maggie/node_modules/eslint-config-airbnb-base/rules/variables.js",
"/Users/awesome/Sites/maggie/node_modules/eslint-config-airbnb-base/rules/es6.js",
"/Users/awesome/Sites/maggie/node_modules/eslint-config-airbnb-base/rules/imports.js",
],
"fix": true,
"globals": Array [],
"parser": "/Users/awesome/Sites/maggie/node_modules/babel-eslint/index.js",
"parserOptions": Object {
"ecmaFeatures": Object {
"experimentalObjectRestSpread": true,
"generators": false,
"globalReturn": true,
"jsx": true,
"objectLiteralDuplicateProperties": false,
},
"ecmaVersion": 6,
"sourceType": "module",
},
"plugins": Array [
"import",
"react",
"jsx-a11y",
"prettier",
"flowtype",
],
"rules": Object {
"accessor-pairs": "off",
"array-bracket-spacing": Array [
"error",
"never",
],
"array-callback-return": "error",
"arrow-body-style": Array [
2,
"as-needed",
],
"arrow-parens": Array [
"error",
"as-needed",
],
"arrow-spacing": Array [
"error",
Object {
"after": true,
"before": true,
},
],
"block-scoped-var": "error",
"block-spacing": Array [
"error",
"always",
],
"brace-style": Array [
"error",
"1tbs",
Object {
"allowSingleLine": true,
},
],
"callback-return": "off",
"camelcase": Array [
"error",
Object {
"properties": "never",
},
],
"class-methods-use-this": Array [
0,
Object {
"exceptMethods": Array [
"render",
"getInitialState",
"getDefaultProps",
"getChildContext",
"componentWillMount",
"componentDidMount",
"componentWillReceiveProps",
"shouldComponentUpdate",
"componentWillUpdate",
"componentDidUpdate",
"componentWillUnmount",
],
},
],
"comma-dangle": Array [
2,
"always-multiline",
],
"comma-spacing": Array [
"error",
Object {
"after": true,
"before": false,
},
],
"comma-style": Array [
"error",
"last",
],
"complexity": Array [
"off",
11,
],
"computed-property-spacing": Array [
"error",
"never",
],
"consistent-return": "error",
"consistent-this": "off",
"constructor-super": "error",
"curly": Array [
"error",
"multi-line",
],
"default-case": Array [
"error",
Object {
"commentPattern": "^no default$",
},
],
"dot-location": Array [
"error",
"property",
],
"dot-notation": Array [
"error",
Object {
"allowKeywords": true,
},
],
"eol-last": Array [
"error",
"always",
],
"eqeqeq": Array [
"error",
"allow-null",
],
"flowtype/boolean-style": Array [
2,
"boolean",
],
"flowtype/define-flow-type": 1,
"flowtype/delimiter-dangle": 0,
"flowtype/generic-spacing": Array [
2,
"never",
],
"flowtype/no-weak-types": 0,
"flowtype/object-type-delimiter": Array [
2,
"comma",
],
"flowtype/require-parameter-type": 0,
"flowtype/require-return-type": 0,
"flowtype/require-valid-file-annotation": 0,
"flowtype/semi": 0,
"flowtype/space-after-type-colon": Array [
2,
"always",
],
"flowtype/space-before-generic-bracket": Array [
2,
"never",
],
"flowtype/space-before-type-colon": Array [
2,
"never",
],
"flowtype/type-id-match": 0,
"flowtype/union-intersection-spacing": Array [
2,
"always",
],
"flowtype/use-flow-type": 1,
"flowtype/valid-syntax": 1,
"func-call-spacing": Array [
"error",
"never",
],
"func-name-matching": Array [
"off",
"always",
Object {
"includeCommonJSModuleExports": false,
},
],
"func-names": "warn",
"func-style": Array [
"off",
"expression",
],
"generator-star-spacing": Array [
"error",
Object {
"after": true,
"before": false,
},
],
"guard-for-in": "error",
"handle-callback-err": "off",
"id-blacklist": "off",
"id-length": "off",
"id-match": "off",
"import/default": "off",
"import/export": "error",
"import/extensions": Array [
0,
"always",
Object {
"js": "never",
"jsx": "never",
},
],
"import/first": Array [
"error",
"absolute-first",
],
"import/imports-first": 0,
"import/max-dependencies": Array [
"off",
Object {
"max": 10,
},
],
"import/named": "off",
"import/namespace": "off",
"import/newline-after-import": 0,
"import/no-absolute-path": "error",
"import/no-amd": "error",
"import/no-commonjs": "off",
"import/no-deprecated": "off",
"import/no-duplicates": "error",
"import/no-dynamic-require": 0,
"import/no-extraneous-dependencies": Array [
0,
Object {
"devDependencies": Array [
"spec/**",
"test/**",
"tests/**",
"**/__tests__/**",
],
"optionalDependencies": false,
},
],
"import/no-internal-modules": Array [
"off",
Object {
"allow": Array [],
},
],
"import/no-mutable-exports": "error",
"import/no-named-as-default": 0,
"import/no-named-as-default-member": "error",
"import/no-named-default": "error",
"import/no-namespace": "off",
"import/no-nodejs-modules": "off",
"import/no-restricted-paths": "off",
"import/no-unassigned-import": "off",
"import/no-unresolved": Array [
0,
Object {
"caseSensitive": true,
"commonjs": true,
},
],
"import/no-webpack-loader-syntax": "error",
"import/order": Array [
"off",
Object {
"groups": Array [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
"newlines-between": "never",
},
],
"import/prefer-default-export": 0,
"import/unambiguous": "off",
"indent": Array [
0,
"tab",
Object {
"SwitchCase": 1,
},
],
"init-declarations": "off",
"jsx-a11y/anchor-has-content": Array [
"error",
Array [
"",
],
],
"jsx-a11y/aria-props": 2,
"jsx-a11y/aria-proptypes": "error",
"jsx-a11y/aria-role": "error",
"jsx-a11y/aria-unsupported-elements": "error",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/heading-has-content": Array [
0,
Array [
"",
],
],
"jsx-a11y/href-no-hash": Array [
2,
Array [
"a",
],
],
"jsx-a11y/html-has-lang": "error",
"jsx-a11y/img-has-alt": "error",
"jsx-a11y/img-redundant-alt": "error",
"jsx-a11y/label-has-for": Array [
2,
Array [
"label",
],
],
"jsx-a11y/lang": "error",
"jsx-a11y/mouse-events-have-key-events": 2,
"jsx-a11y/no-access-key": "error",
"jsx-a11y/no-marquee": "error",
"jsx-a11y/no-onchange": "off",
"jsx-a11y/no-static-element-interactions": "error",
"jsx-a11y/onclick-has-focus": "off",
"jsx-a11y/onclick-has-role": "off",
"jsx-a11y/role-has-required-aria-props": 2,
"jsx-a11y/role-supports-aria-props": 2,
"jsx-a11y/scope": "error",
"jsx-a11y/tabindex-no-positive": "error",
"jsx-quotes": Array [
"error",
"prefer-double",
],
"key-spacing": Array [
"error",
Object {
"afterColon": true,
"beforeColon": false,
},
],
"keyword-spacing": Array [
"error",
Object {
"after": true,
"before": true,
"overrides": Object {
"case": Object {
"after": true,
},
"return": Object {
"after": true,
},
"throw": Object {
"after": true,
},
},
},
],
"line-comment-position": Array [
"off",
Object {
"applyDefaultPatterns": true,
"ignorePattern": "",
"position": "above",
},
],
"linebreak-style": Array [
"error",
"unix",
],
"lines-around-comment": "off",
"lines-around-directive": Array [
"error",
Object {
"after": "always",
"before": "always",
},
],
"max-depth": Array [
"off",
4,
],
"max-len": Array [
0,
100,
2,
Object {
"ignoreComments": false,
"ignoreRegExpLiterals": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreUrls": true,
},
],
"max-lines": Array [
"off",
Object {
"max": 300,
"skipBlankLines": true,
"skipComments": true,
},
],
"max-nested-callbacks": "off",
"max-params": Array [
"off",
3,
],
"max-statements": Array [
"off",
10,
],
"max-statements-per-line": Array [
"off",
Object {
"max": 1,
},
],
"multiline-ternary": Array [
"off",
"never",
],
"new-cap": Array [
"error",
Object {
"capIsNew": false,
"capIsNewExceptions": Array [
"Immutable.Map",
"Immutable.Set",
"Immutable.List",
],
"newIsCap": true,
"newIsCapExceptions": Array [],
},
],
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": Array [
0,
Object {
"ignoreChainWithDepth": 4,
},
],
"no-alert": "warn",
"no-array-constructor": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-case-declarations": "error",
"no-catch-shadow": "off",
"no-class-assign": "error",
"no-cond-assign": Array [
"error",
"always",
],
"no-confusing-arrow": Array [
"error",
Object {
"allowParens": true,
},
],
"no-console": Array [
1,
Object {
"allow": Array [
"warn",
"error",
"debug",
],
},
],
"no-const-assign": "error",
"no-constant-condition": "warn",
"no-continue": "error",
"no-control-regex": "error",
"no-debugger": "error",
"no-delete-var": "error",
"no-div-regex": "off",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": 0,
"no-else-return": "error",
"no-empty": "error",
"no-empty-character-class": "error",
"no-empty-function": Array [
"error",
Object {
"allow": Array [
"arrowFunctions",
"functions",
"methods",
],
},
],
"no-empty-pattern": "error",
"no-eq-null": "off",
"no-eval": "error",
"no-ex-assign": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-boolean-cast": "error",
"no-extra-label": "error",
"no-extra-parens": Array [
"off",
"all",
Object {
"conditionalAssign": true,
"nestedBinaryExpressions": false,
"returnAssign": false,
},
],
"no-extra-semi": "error",
"no-fallthrough": "error",
"no-floating-decimal": "error",
"no-func-assign": "error",
"no-global-assign": Array [
"error",
Object {
"exceptions": Array [],
},
],
"no-implicit-coercion": Array [
"off",
Object {
"allow": Array [],
"boolean": false,
"number": true,
"string": true,
},
],
"no-implicit-globals": "off",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": "error",
"no-invalid-regexp": "error",
"no-invalid-this": "off",
"no-irregular-whitespace": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": Array [
"error",
Object {
"allowLoop": false,
"allowSwitch": false,
},
],
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": Array [
"off",
Object {
"detectObjects": false,
"enforceConst": true,
"ignore": Array [],
"ignoreArrayIndexes": true,
},
],
"no-mixed-operators": Array [
"error",
Object {
"allowSamePrecedence": false,
"groups": Array [
Array [
"+",
"-",
"*",
"/",
"%",
"**",
],
Array [
"&",
"|",
"^",
"~",
"<<",
">>",
">>>",
],
Array [
"==",
"!=",
"===",
"!==",
">",
">=",
"<",
"<=",
],
Array [
"&&",
"||",
],
Array [
"in",
"instanceof",
],
],
},
],
"no-mixed-requires": Array [
"off",
false,
],
"no-mixed-spaces-and-tabs": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": Array [
"error",
Object {
"max": 2,
"maxEOF": 1,
},
],
"no-native-reassign": "off",
"no-negated-condition": "off",
"no-negated-in-lhs": "off",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-symbol": "error",
"no-new-wrappers": "error",
"no-obj-calls": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-param-reassign": Array [
"error",
Object {
"props": true,
},
],
"no-path-concat": "error",
"no-plusplus": "error",
"no-process-env": "off",
"no-process-exit": "off",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-redeclare": "error",
"no-regex-spaces": "error",
"no-restricted-globals": "off",
"no-restricted-imports": "off",
"no-restricted-modules": "off",
"no-restricted-properties": Array [
"error",
Object {
"message": "arguments.callee is deprecated",
"object": "arguments",
"property": "callee",
},
Object {
"message": "Please use Object.defineProperty instead.",
"property": "__defineGetter__",
},
Object {
"message": "Please use Object.defineProperty instead.",
"property": "__defineSetter__",
},
Object {
"message": "Use the exponentiation operator (**) instead.",
"object": "Math",
"property": "pow",
},
],
"no-restricted-syntax": Array [
"error",
"ForInStatement",
"ForOfStatement",
"LabeledStatement",
"WithStatement",
],
"no-return-assign": "error",
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sparse-arrays": "error",
"no-sync": "off",
"no-tabs": 0,
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-this-before-super": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-undefined": "off",
"no-underscore-dangle": Array [
"off",
Object {
"allowAfterThis": false,
},
],
"no-unexpected-multiline": "error",
"no-unmodified-loop-condition": "off",
"no-unneeded-ternary": Array [
"error",
Object {
"defaultAssignment": false,
},
],
"no-unreachable": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-unused-expressions": Array [
"error",
Object {
"allowShortCircuit": false,
"allowTernary": false,
},
],
"no-unused-labels": "error",
"no-unused-vars": Array [
"error",
Object {
"args": "after-used",
"vars": "local",
},
],
"no-use-before-define": 0,
"no-useless-call": "off",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-useless-rename": Array [
"error",
Object {
"ignoreDestructuring": false,
"ignoreExport": false,
"ignoreImport": false,
},
],
"no-useless-return": "error",
"no-void": "error",
"no-warning-comments": Array [
"off",
Object {
"location": "start",
"terms": Array [
"todo",
"fixme",
"xxx",
],
},
],
"no-whitespace-before-property": "error",
"object-curly-newline": Array [
"off",
Object {
"ObjectExpression": Object {
"minProperties": 0,
"multiline": true,
},
"ObjectPattern": Object {
"minProperties": 0,
"multiline": true,
},
},
],
"object-curly-spacing": Array [
"error",
"always",
],
"object-property-newline": Array [
"error",
Object {
"allowMultiplePropertiesPerLine": true,
},
],
"object-shorthand": Array [
"error",
"always",
Object {
"avoidQuotes": true,
"ignoreConstructors": false,
},
],
"one-var": Array [
"error",
"never",
],
"one-var-declaration-per-line": Array [
"error",
"always",
],
"operator-assignment": Array [
"error",
"always",
],
"operator-linebreak": "off",
"padded-blocks": Array [
"error",
"never",
],
"prefer-arrow-callback": Array [
"error",
Object {
"allowNamedFunctions": false,
"allowUnboundThis": true,
},
],
"prefer-numeric-literals": "error",
"prefer-reflect": "off",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": 2,
"prettier/prettier": Array [
"error",
Object {
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all",
},
],
"quote-props": Array [
"error",
"as-needed",
Object {
"keywords": false,
"numbers": false,
"unnecessary": true,
},
],
"quotes": Array [
"error",
"single",
Object {
"avoidEscape": true,
},
],
"radix": "error",
"react/display-name": Array [
"off",
Object {
"ignoreTranspilerName": false,
},
],
"react/forbid-component-props": Array [
"off",
Object {
"forbid": Array [],
},
],
"react/forbid-prop-types": Array [
0,
Object {
"forbid": Array [
"any",
"array",
"object",
],
},
],
"react/jsx-boolean-value": Array [
"error",
"never",
],
"react/jsx-closing-bracket-location": Array [
"error",
"line-aligned",
],
"react/jsx-curly-spacing": Array [
"error",
"never",
Object {
"allowMultiline": true,
},
],
"react/jsx-equals-spacing": Array [
"error",
"never",
],
"react/jsx-filename-extension": Array [
0,
Object {
"extensions": Array [
".jsx",
],
},
],
"react/jsx-first-prop-new-line": Array [
2,
"multiline",
],
"react/jsx-handler-names": Array [
"off",
Object {
"eventHandlerPrefix": "handle",
"eventHandlerPropPrefix": "on",
},
],
"react/jsx-indent": Array [
0,
"tab",
],
"react/jsx-indent-props": Array [
0,
"tab",
],
"react/jsx-key": "off",
"react/jsx-max-props-per-line": Array [
"off",
Object {
"maximum": 1,
},
],
"react/jsx-no-bind": Array [
"error",
Object {
"allowArrowFunctions": true,
"allowBind": false,
"ignoreRefs": true,
},
],
"react/jsx-no-comment-textnodes": "error",
"react/jsx-no-duplicate-props": Array [
"error",
Object {
"ignoreCase": true,
},
],
"react/jsx-no-literals": "off",
"react/jsx-no-target-blank": 0,
"react/jsx-no-undef": "error",
"react/jsx-pascal-case": Array [
"error",
Object {
"allowAllCaps": true,
"ignore": Array [],
},
],
"react/jsx-sort-prop-types": "off",
"react/jsx-sort-props": Array [
"off",
Object {
"callbacksLast": false,
"ignoreCase": true,
"shorthandFirst": false,
"shorthandLast": false,
},
],
"react/jsx-space-before-closing": Array [
"error",
"always",
],
"react/jsx-uses-react": Array [
"error",
],
"react/jsx-uses-vars": "error",
"react/jsx-wrap-multilines": Array [
"error",
Object {
"assignment": true,
"declaration": true,
"return": true,
},
],
"react/no-children-prop": "error",
"react/no-comment-textnodes": "off",
"react/no-danger": "warn",
"react/no-danger-with-children": "error",
"react/no-deprecated": Array [
"error",
],
"react/no-did-mount-set-state": Array [
"error",
],
"react/no-did-update-set-state": Array [
"error",
],
"react/no-direct-mutation-state": "off",
"react/no-find-dom-node": "error",
"react/no-is-mounted": "error",
"react/no-multi-comp": Array [
"error",
Object {
"ignoreStateless": true,
},
],
"react/no-render-return-value": "error",
"react/no-set-state": "off",
"react/no-string-refs": "error",
"react/no-unescaped-entities": "error",
"react/no-unknown-property": "error",
"react/no-unused-prop-types": Array [
"error",
Object {
"customValidators": Array [],
"skipShapeProps": true,
},
],
"react/prefer-es6-class": Array [
"error",
"always",
],
"react/prefer-stateless-function": "error",
"react/prop-types": Array [
"error",
Object {
"customValidators": Array [],
"ignore": Array [],
},
],
"react/react-in-jsx-scope": "error",
"react/require-extension": Array [
0,
Object {
"extensions": Array [
".jsx",
".js",
],
},
],
"react/require-optimization": Array [
"off",
Object {
"allowDecorators": Array [],
},
],
"react/require-render-return": "error",
"react/self-closing-comp": 0,
"react/sort-comp": Array [
2,
Object {
"order": Array [
"type-annotations",
"static-methods",
"lifecycle",
"everything-else",
"render",
],
},
],
"react/sort-prop-types": Array [
"off",
Object {
"callbacksLast": false,
"ignoreCase": true,
"requiredFirst": false,
},
],
"react/style-prop-object": "error",
"react/wrap-multilines": "off",
"require-jsdoc": "off",
"require-yield": "error",
"rest-spread-spacing": Array [
"error",
"never",
],
"semi": Array [
"error",
"always",
],
"semi-spacing": Array [
"error",
Object {
"after": true,
"before": false,
},
],
"sort-imports": Array [
"off",
Object {
"ignoreCase": false,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": Array [
"none",
"all",
"multiple",
"single",
],
},
],
"sort-keys": Array [
"off",
"asc",
Object {
"caseSensitive": false,
"natural": true,
},
],
"sort-vars": "off",
"space-before-blocks": "error",
"space-before-function-paren": Array [
"error",
Object {
"anonymous": "always",
"asyncArrow": "always",
"named": "never",
},
],
"space-in-parens": Array [
"error",
"never",
],
"space-infix-ops": "error",
"space-unary-ops": Array [
"error",
Object {
"nonwords": false,
"overrides": Object {},
"words": true,
},
],
"spaced-comment": Array [
"error",
"always",
Object {
"block": Object {
"balanced": false,
"exceptions": Array [
"-",
"+",
],
"markers": Array [
"=",
"!",
],
},
"line": Object {
"exceptions": Array [
"-",
"+",
],
"markers": Array [
"=",
"!",
],
},
},
],
"strict": Array [
"error",
"never",
],
"symbol-description": "error",
"template-curly-spacing": "error",
"unicode-bom": Array [
"error",
"never",
],
"use-isnan": "error",
"valid-typeof": Array [
"error",
Object {
"requireStringLiterals": true,
},
],
"vars-on-top": "error",
"wrap-iife": Array [
"error",
"outside",
Object {
"functionPrototypeMethods": false,
},
],
"wrap-regex": "off",
"yield-star-spacing": Array [
"error",
"after",
],
"yoda": "error",
},
"settings": Object {
"flowtype": Object {
"onlyFilesWithFlowAnnotation": false,
},
"import/core-modules": Array [],
"import/extensions": Array [
".js",
".jsx",
],
"import/ignore": Array [
"node_modules",
"\\.(coffee|scss|css|less|hbs|svg|json)$",
],
"import/resolver": Object {
"node": Object {
"extensions": Array [
".js",
".jsx",
".json",
],
},
},
"react": Object {
"pragma": "React",
"version": "0.14",
},
},
"useEslintrc": false,
},
"eslintPath": "/Users/awesome/Sites/maggie/node_modules/eslint",
"filePath": "packages/editor/modules/entities/index.js",
"logLevel": "trace",
"prettierOptions": Object {
"bracketSpacing": false,
"parser": "babylon",
"printWidth": 100,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": true,
},
"prettierPath": "/Users/awesome/Sites/maggie/node_modules/prettier",
"text": "// @flow
import * as query from \"shared/query\";
import * as stateKeys from \"modules/entities/stateKeys\";
import resourceReducer from \"./resources\";
import type { StateKey, State } from \"./stateKeys\";
import {
INSERT_ENTITY,
REMOVE_ENTITY,
UPDATE_ENTITY_STYLE,
UPDATE_ENTITY_ORDER,
REMOVE_REFERENCE_FROM_PARENT,
// STORE_ARTICLE,
UPDATE_ARTICLE_WITH_SECTION,
UPDATE_SECTION_WITH_COLUMN_ID,
UPDATE_COLUMN_ITEM_DATA,
UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM,
MOVE_ENTITY_BETWEEN_PARENT
} from \"./constants\";
// fill the initialState dynamically.
const initialState = {};
Object.keys(stateKeys).forEach(key => {
initialState[key] = {
entities: {},
results: []
};
});
export default function entitiesReducer(
state: State = initialState,
action: Object
): State {
switch (action.type) {
case INSERT_ENTITY: {
const entityData = action.payload;
const { type, id } = entityData;
return insertNewEntity(type, id, entityData, state);
}
case UPDATE_ENTITY_STYLE: {
const { sectionId, styleKey, styleValue, type } = action.payload;
return query.upsert$(
[type, \"entities\", sectionId, \"attributes\", \"style\", styleKey],
styleValue,
state
);
}
case REMOVE_ENTITY: {
const { stateKey, id } = action.payload;
return removeEntity(stateKey, id, state);
}
case REMOVE_REFERENCE_FROM_PARENT: {
const { parentType, parentId, childId } = action.payload;
return query.pullByKey$(
[parentType, \"entities\", parentId, \"childItems\"],
\"id\",
childId,
state
);
}
case MOVE_ENTITY_BETWEEN_PARENT: {
const {
curParentId,
nextParentId,
entityId,
parentType
} = action.payload;
return moveEntityBetweenParents(
parentType,
curParentId,
nextParentId,
entityId,
state
);
}
case UPDATE_ENTITY_ORDER: {
const { oldIndex, newIndex, entityId, entityType } = action.payload;
return query.swapIn$(
[entityType, \"entities\", entityId, \"childItems\"],
oldIndex,
newIndex,
state
);
}
case UPDATE_ARTICLE_WITH_SECTION: {
console.debug(
\"%c๐ต UPDATE_ARTICLE_WITH_SECTION must be generalized\",
\"background: blue; color: white; font-size: 1.5em\"
);
const { sectionId, articleId } = action.payload;
return query.append$(
[stateKeys.ARTICLE, \"entities\", articleId, \"childItems\"],
sectionId,
state
);
}
case UPDATE_SECTION_WITH_COLUMN_ID: {
console.debug(
\"%c๐ฎโ UPDATE_SECTION_WITH_COLUMN_ID must be generalized\",
\"background: red; color: white; font-size: 1.5em\"
);
const { sectionId, columnItemId } = action.payload;
return query.append$(
[stateKeys.SECTION, \"entities\", sectionId, \"childItems\"],
columnItemId,
state
);
}
case UPDATE_COLUMN_ITEM_DATA: {
console.debug(
\"%c๐ต UPDATE_COLUMN_ITEM_DATA must be generalized\",
\"background: blue; color: white; font-size: 1.5em\"
);
const {
columnItemId,
columnItemData,
type
} = action.payload;
return query.upsert$(
[type, \"entities\", columnItemId, \"data\"],
columnItemData,
state
);
}
case UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM: {
console.debug(
\"%c๐ต UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM must be generalized\",
\"background: blue; color: white; font-size: 1.5em\"
);
const { columnId, columItemData } = action.payload;
return query.append$(
[stateKeys.SECTION_COLUMN, \"entities\", columnId, \"childItems\"],
columItemData,
state
);
}
default:
return resourceReducer(state, action); // return state;
}
} // *************************** // Reducer helper functions ** // https://github.com/reactjs/redux/issues/1171 => complex logic in // reducers seems fine. // ***************************
const insertNewEntity = (
stateKey: StateKey,
id: String,
entityData: Object,
state: State
) =>
query.upsert$(
[stateKey, \"entities\", id],
entityData,
query.append$([stateKey, \"results\"], id, state)
);
const removeEntity = (stateKey: StateKey, id: String, state: State): State =>
query.omit$(
[stateKey, \"entities\"],
id,
query.pull$([stateKey, \"entities\"], id, state)
);
const moveEntityBetweenParents = (
parentType: StateKey,
curParentId: String,
nextParentId: String,
entityId: String,
state: Object
) => {
const entity = query.findIn$(
[parentType, \"entities\", curParentId, \"childItems\"],
\"id\",
entityId,
state
);
return query.append$(
[stateKeys.SECTION_COLUMN, \"entities\", nextParentId, \"childItems\"],
entity,
query.pullByKey$(
[parentType, \"entities\", curParentId, \"childItems\"],
\"id\",
entityId,
state
)
);
};
",
}
prettier-eslint [DEBUG]: calling prettier on text
Trace: prettier-eslint [TRACE]: prettier input:
// @flow
import * as query from "shared/query";
import * as stateKeys from "modules/entities/stateKeys";
import resourceReducer from "./resources";
import type { StateKey, State } from "./stateKeys";
import {
INSERT_ENTITY,
REMOVE_ENTITY,
UPDATE_ENTITY_STYLE,
UPDATE_ENTITY_ORDER,
REMOVE_REFERENCE_FROM_PARENT,
// STORE_ARTICLE,
UPDATE_ARTICLE_WITH_SECTION,
UPDATE_SECTION_WITH_COLUMN_ID,
UPDATE_COLUMN_ITEM_DATA,
UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM,
MOVE_ENTITY_BETWEEN_PARENT
} from "./constants";
// fill the initialState dynamically.
const initialState = {};
Object.keys(stateKeys).forEach(key => {
initialState[key] = {
entities: {},
results: []
};
});
export default function entitiesReducer(
state: State = initialState,
action: Object
): State {
switch (action.type) {
case INSERT_ENTITY: {
const entityData = action.payload;
const { type, id } = entityData;
return insertNewEntity(type, id, entityData, state);
}
case UPDATE_ENTITY_STYLE: {
const { sectionId, styleKey, styleValue, type } = action.payload;
return query.upsert$(
[type, "entities", sectionId, "attributes", "style", styleKey],
styleValue,
state
);
}
case REMOVE_ENTITY: {
const { stateKey, id } = action.payload;
return removeEntity(stateKey, id, state);
}
case REMOVE_REFERENCE_FROM_PARENT: {
const { parentType, parentId, childId } = action.payload;
return query.pullByKey$(
[parentType, "entities", parentId, "childItems"],
"id",
childId,
state
);
}
case MOVE_ENTITY_BETWEEN_PARENT: {
const {
curParentId,
nextParentId,
entityId,
parentType
} = action.payload;
return moveEntityBetweenParents(
parentType,
curParentId,
nextParentId,
entityId,
state
);
}
case UPDATE_ENTITY_ORDER: {
const { oldIndex, newIndex, entityId, entityType } = action.payload;
return query.swapIn$(
[entityType, "entities", entityId, "childItems"],
oldIndex,
newIndex,
state
);
}
case UPDATE_ARTICLE_WITH_SECTION: {
console.debug(
"%c๐ต UPDATE_ARTICLE_WITH_SECTION must be generalized",
"background: blue; color: white; font-size: 1.5em"
);
const { sectionId, articleId } = action.payload;
return query.append$(
[stateKeys.ARTICLE, "entities", articleId, "childItems"],
sectionId,
state
);
}
case UPDATE_SECTION_WITH_COLUMN_ID: {
console.debug(
"%c๐ฎโ UPDATE_SECTION_WITH_COLUMN_ID must be generalized",
"background: red; color: white; font-size: 1.5em"
);
const { sectionId, columnItemId } = action.payload;
return query.append$(
[stateKeys.SECTION, "entities", sectionId, "childItems"],
columnItemId,
state
);
}
case UPDATE_COLUMN_ITEM_DATA: {
console.debug(
"%c๐ต UPDATE_COLUMN_ITEM_DATA must be generalized",
"background: blue; color: white; font-size: 1.5em"
);
const {
columnItemId,
columnItemData,
type
} = action.payload;
return query.upsert$(
[type, "entities", columnItemId, "data"],
columnItemData,
state
);
}
case UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM: {
console.debug(
"%c๐ต UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM must be generalized",
"background: blue; color: white; font-size: 1.5em"
);
const { columnId, columItemData } = action.payload;
return query.append$(
[stateKeys.SECTION_COLUMN, "entities", columnId, "childItems"],
columItemData,
state
);
}
default:
return resourceReducer(state, action); // return state;
}
} // *************************** // Reducer helper functions ** // https://github.com/reactjs/redux/issues/1171 => complex logic in // reducers seems fine. // ***************************
const insertNewEntity = (
stateKey: StateKey,
id: String,
entityData: Object,
state: State
) =>
query.upsert$(
[stateKey, "entities", id],
entityData,
query.append$([stateKey, "results"], id, state)
);
const removeEntity = (stateKey: StateKey, id: String, state: State): State =>
query.omit$(
[stateKey, "entities"],
id,
query.pull$([stateKey, "entities"], id, state)
);
const moveEntityBetweenParents = (
parentType: StateKey,
curParentId: String,
nextParentId: String,
entityId: String,
state: Object
) => {
const entity = query.findIn$(
[parentType, "entities", curParentId, "childItems"],
"id",
entityId,
state
);
return query.append$(
[stateKeys.SECTION_COLUMN, "entities", nextParentId, "childItems"],
entity,
query.pullByKey$(
[parentType, "entities", curParentId, "childItems"],
"id",
entityId,
state
)
);
};
at Logger.trace (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/log.js:60:24)
at format (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:103:10)
at MapSubscriber.project (/Users/awesome/Sites/maggie/node_modules/prettier-eslint-cli/dist/format-files.js:264:55)
at MapSubscriber._next (/Users/awesome/Sites/maggie/node_modules/rxjs/operator/map.js:77:35)
at MapSubscriber.Subscriber.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subscriber.js:89:18)
at AsyncSubject.Subject.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subject.js:55:25)
at AsyncSubject.complete (/Users/awesome/Sites/maggie/node_modules/rxjs/AsyncSubject.js:46:35)
at handlerFn (/Users/awesome/Sites/maggie/node_modules/rxjs/observable/BoundNodeCallbackObservable.js:193:33)
at tryToString (fs.js:449:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)
Trace: prettier-eslint [TRACE]: requiring prettier module at "/Users/awesome/Sites/maggie/node_modules/prettier"
at Logger.trace (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/log.js:60:24)
at prettify (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:114:12)
at format (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:104:16)
at MapSubscriber.project (/Users/awesome/Sites/maggie/node_modules/prettier-eslint-cli/dist/format-files.js:264:55)
at MapSubscriber._next (/Users/awesome/Sites/maggie/node_modules/rxjs/operator/map.js:77:35)
at MapSubscriber.Subscriber.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subscriber.js:89:18)
at AsyncSubject.Subject.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subject.js:55:25)
at AsyncSubject.complete (/Users/awesome/Sites/maggie/node_modules/rxjs/AsyncSubject.js:46:35)
at handlerFn (/Users/awesome/Sites/maggie/node_modules/rxjs/observable/BoundNodeCallbackObservable.js:193:33)
at tryToString (fs.js:449:3)
Trace: prettier-eslint [TRACE]: calling prettier.format with the text and prettierOptions
at Logger.trace (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/log.js:60:24)
at prettify (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:121:12)
at format (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:104:16)
at MapSubscriber.project (/Users/awesome/Sites/maggie/node_modules/prettier-eslint-cli/dist/format-files.js:264:55)
at MapSubscriber._next (/Users/awesome/Sites/maggie/node_modules/rxjs/operator/map.js:77:35)
at MapSubscriber.Subscriber.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subscriber.js:89:18)
at AsyncSubject.Subject.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subject.js:55:25)
at AsyncSubject.complete (/Users/awesome/Sites/maggie/node_modules/rxjs/AsyncSubject.js:46:35)
at handlerFn (/Users/awesome/Sites/maggie/node_modules/rxjs/observable/BoundNodeCallbackObservable.js:193:33)
at tryToString (fs.js:449:3)
Trace: prettier-eslint [TRACE]: prettier: output === input false
at Logger.trace (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/log.js:60:24)
at prettify (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:123:12)
at format (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:104:16)
at MapSubscriber.project (/Users/awesome/Sites/maggie/node_modules/prettier-eslint-cli/dist/format-files.js:264:55)
at MapSubscriber._next (/Users/awesome/Sites/maggie/node_modules/rxjs/operator/map.js:77:35)
at MapSubscriber.Subscriber.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subscriber.js:89:18)
at AsyncSubject.Subject.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subject.js:55:25)
at AsyncSubject.complete (/Users/awesome/Sites/maggie/node_modules/rxjs/AsyncSubject.js:46:35)
at handlerFn (/Users/awesome/Sites/maggie/node_modules/rxjs/observable/BoundNodeCallbackObservable.js:193:33)
at tryToString (fs.js:449:3)
Trace: prettier-eslint [TRACE]: prettier output (eslint input):
// @flow
import * as query from 'shared/query';
import * as stateKeys from 'modules/entities/stateKeys';
import resourceReducer from './resources';
import type {StateKey, State} from './stateKeys';
import {
INSERT_ENTITY,
REMOVE_ENTITY,
UPDATE_ENTITY_STYLE,
UPDATE_ENTITY_ORDER,
REMOVE_REFERENCE_FROM_PARENT,
// STORE_ARTICLE,
UPDATE_ARTICLE_WITH_SECTION,
UPDATE_SECTION_WITH_COLUMN_ID,
UPDATE_COLUMN_ITEM_DATA,
UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM,
MOVE_ENTITY_BETWEEN_PARENT,
} from './constants';
// fill the initialState dynamically.
const initialState = {};
Object.keys(stateKeys).forEach(key => {
initialState[key] = {
entities: {},
results: [],
};
});
export default function entitiesReducer(state: State = initialState, action: Object): State {
switch (action.type) {
case INSERT_ENTITY: {
const entityData = action.payload;
const {type, id} = entityData;
return insertNewEntity(type, id, entityData, state);
}
case UPDATE_ENTITY_STYLE: {
const {sectionId, styleKey, styleValue, type} = action.payload;
return query.upsert$(
[type, 'entities', sectionId, 'attributes', 'style', styleKey],
styleValue,
state,
);
}
case REMOVE_ENTITY: {
const {stateKey, id} = action.payload;
return removeEntity(stateKey, id, state);
}
case REMOVE_REFERENCE_FROM_PARENT: {
const {parentType, parentId, childId} = action.payload;
return query.pullByKey$(
[parentType, 'entities', parentId, 'childItems'],
'id',
childId,
state,
);
}
case MOVE_ENTITY_BETWEEN_PARENT: {
const {
curParentId,
nextParentId,
entityId,
parentType,
} = action.payload;
return moveEntityBetweenParents(parentType, curParentId, nextParentId, entityId, state);
}
case UPDATE_ENTITY_ORDER: {
const {oldIndex, newIndex, entityId, entityType} = action.payload;
return query.swapIn$(
[entityType, 'entities', entityId, 'childItems'],
oldIndex,
newIndex,
state,
);
}
case UPDATE_ARTICLE_WITH_SECTION: {
console.debug(
'%c๐ต UPDATE_ARTICLE_WITH_SECTION must be generalized',
'background: blue; color: white; font-size: 1.5em',
);
const {sectionId, articleId} = action.payload;
return query.append$(
[stateKeys.ARTICLE, 'entities', articleId, 'childItems'],
sectionId,
state,
);
}
case UPDATE_SECTION_WITH_COLUMN_ID: {
console.debug(
'%c๐ฎโ UPDATE_SECTION_WITH_COLUMN_ID must be generalized',
'background: red; color: white; font-size: 1.5em',
);
const {sectionId, columnItemId} = action.payload;
return query.append$(
[stateKeys.SECTION, 'entities', sectionId, 'childItems'],
columnItemId,
state,
);
}
case UPDATE_COLUMN_ITEM_DATA: {
console.debug(
'%c๐ต UPDATE_COLUMN_ITEM_DATA must be generalized',
'background: blue; color: white; font-size: 1.5em',
);
const {
columnItemId,
columnItemData,
type,
} = action.payload;
return query.upsert$([type, 'entities', columnItemId, 'data'], columnItemData, state);
}
case UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM: {
console.debug(
'%c๐ต UPDATE_SECTION_COLUMN_WITH_COLUMN_ITEM must be generalized',
'background: blue; color: white; font-size: 1.5em',
);
const {columnId, columItemData} = action.payload;
return query.append$(
[stateKeys.SECTION_COLUMN, 'entities', columnId, 'childItems'],
columItemData,
state,
);
}
default:
return resourceReducer(state, action); // return state;
}
} // *************************** // Reducer helper functions ** // https://github.com/reactjs/redux/issues/1171 => complex logic in // reducers seems fine. // ***************************
const insertNewEntity = (stateKey: StateKey, id: String, entityData: Object, state: State) =>
query.upsert$(
[stateKey, 'entities', id],
entityData,
query.append$([stateKey, 'results'], id, state),
);
const removeEntity = (stateKey: StateKey, id: String, state: State): State =>
query.omit$([stateKey, 'entities'], id, query.pull$([stateKey, 'entities'], id, state));
const moveEntityBetweenParents = (
parentType: StateKey,
curParentId: String,
nextParentId: String,
entityId: String,
state: Object,
) => {
const entity = query.findIn$(
[parentType, 'entities', curParentId, 'childItems'],
'id',
entityId,
state,
);
return query.append$(
[stateKeys.SECTION_COLUMN, 'entities', nextParentId, 'childItems'],
entity,
query.pullByKey$([parentType, 'entities', curParentId, 'childItems'], 'id', entityId, state),
);
};
at Logger.trace (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/log.js:60:24)
at format (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:105:10)
at MapSubscriber.project (/Users/awesome/Sites/maggie/node_modules/prettier-eslint-cli/dist/format-files.js:264:55)
at MapSubscriber._next (/Users/awesome/Sites/maggie/node_modules/rxjs/operator/map.js:77:35)
at MapSubscriber.Subscriber.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subscriber.js:89:18)
at AsyncSubject.Subject.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subject.js:55:25)
at AsyncSubject.complete (/Users/awesome/Sites/maggie/node_modules/rxjs/AsyncSubject.js:46:35)
at handlerFn (/Users/awesome/Sites/maggie/node_modules/rxjs/observable/BoundNodeCallbackObservable.js:193:33)
at tryToString (fs.js:449:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)
Trace: prettier-eslint [TRACE]: requiring eslint module at "/Users/awesome/Sites/maggie/node_modules/eslint"
at Logger.trace (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/log.js:60:24)
at getESLintCLIEngine (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:199:12)
at eslintFix (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:132:16)
at format (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:106:21)
at MapSubscriber.project (/Users/awesome/Sites/maggie/node_modules/prettier-eslint-cli/dist/format-files.js:264:55)
at MapSubscriber._next (/Users/awesome/Sites/maggie/node_modules/rxjs/operator/map.js:77:35)
at MapSubscriber.Subscriber.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subscriber.js:89:18)
at AsyncSubject.Subject.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subject.js:55:25)
at AsyncSubject.complete (/Users/awesome/Sites/maggie/node_modules/rxjs/AsyncSubject.js:46:35)
at handlerFn (/Users/awesome/Sites/maggie/node_modules/rxjs/observable/BoundNodeCallbackObservable.js:193:33)
Trace: prettier-eslint [TRACE]: calling eslint.executeOnText with the text
at Logger.trace (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/log.js:60:24)
at eslintFix (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:134:12)
at format (/Users/awesome/Sites/maggie/node_modules/prettier-eslint/dist/index.js:106:21)
at MapSubscriber.project (/Users/awesome/Sites/maggie/node_modules/prettier-eslint-cli/dist/format-files.js:264:55)
at MapSubscriber._next (/Users/awesome/Sites/maggie/node_modules/rxjs/operator/map.js:77:35)
at MapSubscriber.Subscriber.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subscriber.js:89:18)
at AsyncSubject.Subject.next (/Users/awesome/Sites/maggie/node_modules/rxjs/Subject.js:55:25)
at AsyncSubject.complete (/Users/awesome/Sites/maggie/node_modules/rxjs/AsyncSubject.js:46:35)
at handlerFn (/Users/awesome/Sites/maggie/node_modules/rxjs/observable/BoundNodeCallbackObservable.js:193:33)
at tryToString (fs.js:449:3)
prettier-eslint [ERROR]: eslint fix failed due to an eslint error
failure formatting 1 file with prettier-eslint
Given a disabled ESLint rule, e.g.
max-len: 0
โฆ and a fallback setting, e.g.
printWidth: 200
The fallback setting will not be honoured.
Example:
const prettierEslint = require('prettier-eslint');
const filePath = 'foo.js';
const text = `
const x = { foobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarfoobarbaz: "foobarbazfoobarbazfoobarbaz" }`;
const result = prettierEslint({
text,
filePath,
fallbackPrettierOptions: {
printWidth: 200,
},
});
console.log(result);
Actual result:
โฏ node prettier-eslint-test.js
const x = {
foobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarfoobarbaz:
'foobarbazfoobarbazfoobarbaz',
};
Expected result:
const x = { foobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarfoobarbaz: 'foobarbazfoobarbazfoobarbaz' };
I expected this to stay on one line, because of the printWidth: 200
.
When comma-dangle
has a value of always-multiline
, prettier-eslint incorrectly infers the trailing-comma
option to none
:
Line 199 in de44a0a
Can we update it to infer either es5
or all
?
Hi there,
I'm using prettier-eslint both from the cli and through the atom plugin depending on the file/project. With this eslintrc:
{
parser: 'babel-eslint',
extends: 'airbnb'
}
I get some ternary lines being formatted onto a single line, and others are being broken onto multiple lines. It looks like the lines being broken are those over 100 characters. Any ideas why this might be happening and how I can fix it so all ternary statements are single line?
I've tried setting 'multiline-ternary': [2, 'never']
in the rules with no change. I was also trying to extend a different eslint config from standardjs in which case ternary lines aren't being formatted at all regardless of the rules I have set. Is there a prettier config for ternary?
Is it possible to run prettier-eslint inside .vue component?
I've set:
"eslint.options": { "extensions": [ ".js", ".vue" ] }
but it didn't help.
Versions:
prettier-eslint
version: ^6.2.1prettier-atom
version: 0.31.1atom
version:
Atom : 1.17.0
Electron: 1.3.15
Chrome : 52.0.2743.82
Node : 6.5.0
Have you followed the debugging tips?
No (it's being used in prettier-atom)
What I did:
I have a project with the spec-compliant ESLint config filename, such as .eslintrc.json5
What happened:
The config is not loaded by prettier-atom (prettier-eslint)
Suggested solution:
Ensure prettier-eslint is able to load .eslintrc.*
configs.
Right now we ship prettier
and eslint
as dependencies to the project. But we should probably find the most relevant packages instead. Maybe use the first available version:
node_modules
node_modules
node_modules
Any ideas/suggestions are welcome! (This should solve kentcdodds/prettier-eslint-atom#5)
Wrong repo
When running prettier-atom it doesn't seem .eslintignore is being used as it still runs on directories I've ignored.
http://eslint.org/docs/rules/comma-dangle#options
According to the eslint docs, "always-multiline" ignores functions by default. I believe that means that prettier-eslint should set prettier's --trailing-comma
option to es5
rather than all
, unless functions: "always"
is specified in eslint.
Relevant eslint config:
{
"rules": {
"comma-dangle": [2, "always-multiline"],
}
}
Prettier command:
prettier --single-quote --no-semi --trailing-comma es5
Unformatted:
function someFunction(longParamater1, longParamater2, longParamater3, longParamater4) {
return ''
}
Prettier + eslint --fix
output:
function someFunction(
longParamater1,
longParamater2,
longParamater3,
longParamater4 // no comma
) {
return ''
}
Prettier-eslint output:
function someFunction(
longParamater1,
longParamater2,
longParamater3,
longParamater4, // comma
) {
return ''
}
Edit:
It is possible to fix it using prettier-eslint --prettier.trailing-comma es5
, but those options aren't available when using prettier-atom.
That will be awesome to have it for vscode
This is, admittedly, purely needed for prettier-atom. In prettier-atom, if you turn ESlint integration on, it's going to stay on regardless of whether the project you've got open actually has all prettier-related rules set in their config.
If the project doesn't have an ESlint rule needed for prettier, users are wanting to fall back to the prettier setting they've set inside of their prettier-atom config instead of falling back to the default value for that prettier option (which is how it currently works if I'm not mistaken). If I could pass fall-back options to prettier-eslint when using it to format, that would be great. Note that this is different than the current API which only allows manual overrides as opposed to fall-backs.
Any thoughts on adding this to the API?
If I use this rule
"quotes": ["error", "backtick"]
I get errors like this
prettier-eslint [ERROR]: prettier formatting failed due to a prettier error
prettier-eslint-cli [ERROR]: There was an error formatting "packages/gatsby/lib/utils/webpack.config.js":
โ Validation Error:
Option "singleQuote" must be of type:
boolean
but instead received:
string
Example:
{
"singleQuote": false
}
Using prettier-eslint-cli 3.4.2
I really like the idea of this project, but use TypeScript and tslint. Would it be in scope of this project to add tslint support, or would you recommend I fork instead?
I've been having an issue with prettier-eslint via prettier-atom. Basically, my eslint config uses dangling commas, but in some situations, dangling commas don't run correctly. For example, the below code won't work correctly when run in config files that aren't transpiled.
someFunction(
firstArg,
secondArg,
)
prettier-eslint is adding back that comma when I have /* eslint-disable */
at the top of my file. Does prettier-eslint not honor disabling of eslint features via comments?
So we can get everything we need for debugging. From prettier/prettier-eslint-cli#1
We should probably expose a way for you to log out the
eslintConfig
andprettierOptions
that are used for the formatting. Would you be interested in doing that? Would probably just need another option (likesillyLogs
) and add theconsole.log
here that includes theeslintConfig
andprettierOptions
(maybe put it in a separate function and just call it there... Wanna try?
@edm00se's going to give this a try tonight (hopefully)
If file has non-standard syntax, like class properties, prettier-eslint passes source through prettier but silently skips transforming through eslint. This behavior makes file to be formatted with default prettier settings, while the expected behavior is leaving file intact.
Example file:
import React from 'react';
class Example extends React.Component {
state = {
foo: 'bar'
}
render() {
return <div foo='bar'></div>
}
}
if you format this with prettier-eslint rules set to
{
quotes: [
'error',
'single',
{avoidEscape: true, allowTemplateLiterals: true}
],
'jsx-quotes': ['error', 'prefer-single'],
}
the jsx is formatted to double quotes
Hey,
based on:
prettier/prettier-atom#85 (comment)
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
I wrote such npm script in my package.json:
"format-js": "prettier-eslint --print-width 100 --list-different --write 'webpack/**/*.js' 'development/**/*.js'"
it formats my js, but does not print prettified files. Is it possible to use --list-different with --write?
If not, it would be great to))
I know this probably isn't an issue with this project, but I'm wondering if someone here might be able to help me figure out what is going on. For just about everything I'm able to have this remove semi's from my code, however within classes I still seem to get them:
input
class MyComponent extends Component {
static propTypes = {
prop: PropTypes.node.isRequired,
}
}
output
class MyComponent extends Component {
static propTypes = {
prop: PropTypes.node.isRequired,
};
}
any idea how I might stop these from being inserted? What is slightly strange is that the linter does not complain in the editor, but on save the semi's are getting inserted.
Each rule you add to the ESLint config adds overhead. If it's not fixable then it's not useful overhead. We should improve perf by removing any rules from the config that aren't fixable. I'm not sure whether it's possible to know, but if it is, we should try. Could really speed things up I think.
It's not really clear to me, based on any of the current documentation, how to actually use this with a project. Is this a CLI tool? Does it require a configuration file? Is there a default location for such a configuration file? Is there an example available that shows how to hook this up with an existing set of eslint rules? I just can't quite figure out how to use this.
https://github.com/not-an-aardvark/eslint-plugin-prettier
It allows you to:
eslint
.eslint --fix
.Versions:
prettier-eslint
version: 6.2.2node
version: v7.10.0yarn
version: 0.24.5Have you followed the debugging tips?
Yes
Relevant code or config
// package.json
"bin": { "bin": "index.js" }
// index.js
#!/usr/bin/env node
console.log("Hello, world!");
# .eslintrc.yaml
plugins: [node]
rules: { node/shebang: error }
https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/shebang.md
When run with eslint --fix
, the shebang is correctly added if absent and not removed.
When run with prettier
, it's not touched at all.
And prettier-eslint
keeps removing it (but only if the node/shebang
rule is enabled).
It seems that the rule can't detect if the script is a bin file, i.e. can't read package.json
or something, so it treats the file as a regular file.
Branch | Build failing ๐จ |
---|---|
Dependency | prettier-eslint-cli |
Current Version | 2.0.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As prettier-eslint-cli is โonlyโ a devDependency of this project it might not break production or downstream projects, but โonlyโ your build or test tools โ preventing new deploys or publishes.
I recommend you give this issue a high priority. Iโm sure you can resolve this ๐ช
The new version differs by 1 commits .
31e9e92
fix(parser): coerce non-absolute paths to cwd (#22)
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot ๐ด
Versions:
prettier-eslint
version: 6.4.2node
version: 7.6.0npm
(or yarn
) version: 4.4.1Problem description:
How do I extend this eslint configuration? I want to be able to add an .eslitrc.json file that says something like
{
"extends": "prettier-eslint"
}
Visual Studio complains that this config can't be found and I agree, I don't see an .eslint file anywhere I can extend.
Currently prettier-eslint instantiates eslint for each linted file. The results seems to be that for every file eslint config is reading its configuration, probably hitting the performance.
It would be nice if someone did research if it's possible to make eslint read configuration just one time (unfortunately I don't have time to do so).
It seems to be the case based on output of prettier-eslint in #53
Works great!
The only issue I've come across is where it reformats chained function calls onto the same line.
Any idea why it would reformat:
describe('root', () => {
it('should have GET for health check', done => {
request.get('/')
.expect(200)
.end(done);
});
});
into this:
describe('root', () => {
it('should have GET for health check', done => {
request.get('/').expect(200).end(done);
});
});
?
For additional context, I'm using the VS Code Plugin by Robin Malfait, and he suggested I ask here (see original issue).
As suggested by Robin, I tried overriding the newline-per-chained-call
ESLint rule, but this didn't seem to have an effect on the formatting, although ESLint still picked up when I violated the rule.
For some projects there is a custom path to eslintrc files, hence support for -c, --config path::String Use configuration from this file or shareable config
in the eslint cli http://eslint.org/docs/user-guide/command-line-interface
Can you add support for --eslintrcPath
to mirror that functionality (eslintConfig takes an object instead of path)
This should also be passed through to prettier-eslint-cli
Versions:
prettier-eslint
version: 4.1.1node
version: v8.1.2npm
(or yarn
) version: npm 5.0.4Have you followed the debugging tips?
Yes
Relevant code or config
{
"extends": ["airbnb-base", "prettier"]
}
What I did:
What happened:
Reproduction repository:
[email protected]:zyy7259/prettier-foo.git
Problem description:
comma-dangle
"off" with object option is not working properly.
Run prettier-eslint index.js --log-level trace
in the root dir.
The input is
const arr = [
"asdfasdfasdfasdf",
"asdfasdfasdfasdf",
"asdfasdfasdfasdf",
"asdfasdfasdfasdf",
];
arr.sort();
The output is just the same
, with the redundant comma.
Then I search "comma-dangle"
(with quotation mark) in the terminal, and found some log.
Trace: prettier-eslint [TRACE]: adding to relevant rules: {"comma-dangle":["off",{"arrays":"always-multiline","objects":"always-multiline","imports":"always-multiline","exports":"always-multiline","functions":"always-multiline"}]}
"comma-dangle": Array [
"off",
Object {
"arrays": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline",
"imports": "always-multiline",
"objects": "always-multiline",
},
]
I guess maybe the config is wrong, there is a redundant object option.
Then I change the .eslintrc.json to (I create a branch fix
to demo this step)
{
"extends": ["airbnb-base", "prettier"],
"rules": {
"comma-dangle": ["off", {}]
}
}
and run prettier-eslint index.js --log-level trace
again, this time the output is right. Search "comma-dangle"
again, got
Trace: prettier-eslint [TRACE]: adding to relevant rules: {"comma-dangle":["off",{}]}
"comma-dangle": Array [
"off",
Object {},
]
Suggested solution:
Not sure if this is a issue with prettier-eslint
Versions:
prettier-eslint
version: the one shipped in prettier-eslint-vscode
for VS Codenode
version: 6.9.2npm
(or yarn
) version: 3.x.xHave you followed the debugging tips?
No
Relevant code or config
if (!aboolean &&
this &&
(!this.caller ||
this.caller === this ||
!this.somevalue||
this.caller === this.someobject.avalue)) {
aboolean = true;
}
What I did:
Pressed the keyboard shortcut to apply prettier-eslint fixes.
What happened:
It became like this:
if (
!aboolean&&
this &&
(!this.caller ||
this.caller === this ||
!this.somevalue||
this.caller === this.someobject.value)
) {
aboolean = true;
}
Reproduction repository:
N/A
Problem description:
Is it possible for me to configure how lines should separate in my if conditions?
Prettier format the code in specific ways, I like some but not all formatting in all cases.
With help of this tool can I change that formatting and auto-fix too with ESLint overrides?
Versions:
prettier-eslint
version: 6.2.1node
version: v7.10.0yarn
version: 0.23.4Have you followed the debugging tips?
Yes
Relevant code or config
# .eslintrc.yaml
env:
es6: true
rules:
prefer-const: error
no-var: error
const format = require("prettier-eslint")
const text = `
let x = 0
var y = 0
`
console.log(format({ text }))
What happened:
let x = 0
var y = 0
What should happen:
const x = 0
const y = 0
Problem description:
These rules are ignored by prettier-eslint
because of this variable, which removes rules that are not fixable. But these two are!
If I add them inline, everything works:
const text = `
/* eslint "prefer-const": "error" */
/* eslint "no-var": "error" */
let x = 0
var y = 0
`
Suggested solution:
For a start, remove these rules from the array.
In future, don't make too big assumptions on whether a rule will never be fixable (someone may use an older version of prettier-eslint
with a never version of eslint
and come across this problem).
Versions:
prettier-eslint
version: 3.4.2node
version: v7.10.0yarn
version: v0.23.0Relevant code or config
/* eslint no-console: "off", prettier/prettier: ["error", {
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 120
}] */
const _ = require("lodash");
What I did:
prettier-eslint --write .pygrc.js
What happened:
No single quote appear.
Problem description:
I know that with eslint we have to use --ignore-pattern '!.pygrc.js'
because by default he is ignoring dot files.
But with prettier-eslint it's not working.
Suggested solution:
We think that it's a bug from prettier-eslint to ignore by default dotfiles.
Since moving to use prettier-eslint prettier doesn't seem to respect the 80 column line width default setting and leaves long lines of code as they are. Is this because the ESLint config doesn't specify a max line length?
It's handy to have prettier deal with 95% of the code that goes beyond 80 columns but for ESLint not to warn about lines that go beyond that length in old code bases, is there any way of enabling my previous development experience without dropping prettier-eslint?
i.e. it should could provide just the defaults if filePath is provided.
It's in the same spirit as "You can also provide some of the options and have the remaining options derived via your eslint config.", but for eslint config, not prettier config.
I'm using this in context of VSCode (via prettier-eslint-code), at some point eslint config resolution stopped working (empty config was resolved internally)
The problem lies here: src/index.js#L206-L209 Whatever error occurs during config resolution it just without backing reason states that no config could be found, and resolves with empty one.
It'll be way better if eventual errors are recognized, and are either rethrown or accurate actions are taken to errors that are understood.
In my case it appeared that some other VSCode extension crashed and it was its error that prevented proper config resolution, if package would just rethrow this error, then on my end the cause would be immediately exposed.
I didn't get this part
The fix feature of eslint is pretty great and can auto-format/fix much of your code according to your ESLint config. prettier is a more powerful automatic formatter
What does it mean "prettier is a more powerful automatic formatter" ?
I run prettier-eslint --write
through husky
& lint-staged
. I wonder if there are any lint errors / or warnings that the --write
cannot --fix
(other than parser errors, maybe a question for eslint
?), or rephrased: would there be any use of running eslint
after prettier-eslint --write
? I wrote more on this here.
While playing with it, I noticed that parse errors are prettier when running just eslint
. So I also thought that maybe we could at least have an option for --no-stacktrace
, as -l silent
is neither silent nor gives enough info about where the error is at. Or maybe a -l concise
?
Here is an example of a parse error I get from eslint
- contains only the info needed to go fix the code, and a summary of total warnings / errors:
$ eslint $npm_package_config_code
/Users/om/Dev/mel/drmelgill.com/components/reveal.js
3:20 error Parsing error: Unterminated string constant
1 | import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
2 | import FirstChild from 'components/first-child'
> 3 | import styles from './reveal.js.scss;
| ^
4 |
5 | export default props => (
6 | <div className='reveal'>
โ 1 problem (1 error, 0 warnings)
error Command failed with exit code 1.
Here is the same error coming from prettier-eslint --write
:
prettier-eslint [ERROR]: prettier formatting failed due to a prettier error
prettier-eslint-cli [ERROR]: There was an error formatting "/Users/om/Dev/mel/drmelgill.com/components/reveal.js":
SyntaxError: Unterminated string constant (3:19)
1 | import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
2 | import FirstChild from 'components/first-child'
> 3 | import styles from './reveal.js.scss;
| ^
4 |
5 | export default props => (
6 | <div className='reveal'>
at Parser.pp$5.raise (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:4333:13)
at Parser.readString (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:1296:33)
at Parser.getTokenFromCode (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:1102:21)
at Parser.readToken (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:771:19)
at Parser.<anonymous> (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:6626:20)
at Parser.readToken (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:5443:22)
at Parser.nextToken (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:761:19)
at Parser.next (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:686:10)
at Parser.eat (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:693:12)
at Parser.pp.eatContextual (/Users/om/Dev/mel/drmelgill.com/node_modules/prettier/node_modules/babylon/lib/index.js:1661:44)
failure formatting 1 file with prettier-eslint
Running prettier-eslint --write -l silent
says:
failure formatting 1 file with prettier-eslint
An alternative request would be to maybe add a --no-error
option (making the cli completely silent and with exit code 0), which would allow people to run eslint
after prettier-eslint --write --no-error
.
I've adopted a strategy of using eslint to catch errors, but prettier to enforce style. Because of this strategy, I'd really rather run prettier after eslint --fix
. This would give prettier the final say on how the code should be styled.
It would be great if there was an option (--prettier-last
maybe?) that would run prettier after running eslint.
If needed, I could work on the pull request. I just want to make sure it would be accepted before I start working on it.
I posted this issue to prettier-atom and then on the recommendation tried to process these issues with prettier-eslint-cli with the same output, therefore I'm landing them here:
prettier-eslint-cli version: 3.4.4
node: v7.9.0
yarn: 0.24.4
Example:
const enhWithZip = withProps(props => ({ zip: path([ 'place', 'zip' ], props) }));
Setting is 80char wide (this is 83). Cannot make it shorter. When I make it one character longer, it works:
const enhWithZip = withProps(props => ({
zip: path([ 'place', 'zipa' ], props),
}));
My eslint is set to require spaces inside brackets { ... }
and [ ... ]
.
another issue:
Deeply nested (complexity 29, booooo, shame on me but this component should be like this) snippet:
<tr
className={ place && place.streetAndSublocality ? '' : 'invalid' }
>
length 83 (again).
I change this manually to:
<tr
className={
place && place.streetAndSublocality ? '' : 'invalid'
}
>
and similar modifications but save (reformat on save) will change it again to 83 long one line to disturb eslint. No problem with disable-line but... :)
... unfortunatelly problem with eslint...
I fixed my complexity ugliness with disable-line
const Summary = ({ priceRange, place, order, user, intl }) => { //eslint-disable-line complexity
but prettier reformats on save:
const Summary = ({ priceRange, place, order, user, intl }) => {
//eslint-disable-line complexity
const durationInHours = m...
that the //eslint...
part is on next line and therefore making eslint unhappy again.
Note: I went to all-prettier and format on save. Prettier rocks! Thanks.
I try run example
const format = require('prettier-eslint')
// notice, no semicolon in the original text
const sourceCode = 'const {foo} = bar'
const options = {
text: sourceCode,
eslintConfig: {
rules: {
semi: ['error', 'never'],
},
},
prettierOptions: {
bracketSpacing: true,
},
}
const formatted = format(options)
// notice no semicolon in the formatted text
console.log(formatted) // const { foo } = bar
and output "undefined"
Prettier then eslint --fix then max-len error.
The following code is perfectly formatted by prettier alone but when eslint --fixes it the maximum line length rule is violated.
module.exports = function(x) {
const sortPlacesByDistance = function sortPlacesByDistance(place_a, place_b) {
return place_a.distance - place_b.distance;
};
sortPlacesByDistance(x);
};
.eslintrc.js:
module.exports = {
env: { es6: true, node: true },
rules: {
'max-len': [ 'error', 80 ],
'space-before-function-paren': [ 'error', 'always' ]
}
};
--fixed:
module.exports = function (x) {
const sortPlacesByDistance = function sortPlacesByDistance (place_a, place_b) {
return place_a.distance - place_b.distance;
};
sortPlacesByDistance(x);
};
Is it even fixable? I mean, it's the fix that breaks it.
Is it the definition of irony...?
I just installed this new version and now Atom is failing to load the package on startup.
Atom Version: 1.13.0
Electron Version: 1.3.13
System: Mac OS X 10.12.2
Thrown From: prettier-eslint package, v1.1.0
Failed to load the prettier-eslint package
At Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
at Function.line.toFunction (/Users/tom/.atom/packages/prettier-eslint/node_modules/generate-function/index.js:55:21)
at compile (/Users/tom/.atom/packages/prettier-eslint/node_modules/is-my-json-valid/index.js:562:23)
at visit (/Users/tom/.atom/packages/prettier-eslint/node_modules/is-my-json-valid/index.js:337:16)
at /Users/tom/.atom/packages/prettier-eslint/node_modules/is-my-json-valid/index.js:540:9
at Array.forEach (native)
at visit (/Users/tom/.atom/packages/prettier-eslint/node_modules/is-my-json-valid/index.js:537:31)
at compile (/Users/tom/.atom/packages/prettier-eslint/node_modules/is-my-json-valid/index.js:556:3)
at module.exports (/Users/tom/.atom/packages/prettier-eslint/node_modules/is-my-json-valid/index.js:585:10)
at Object.<anonymous> (/Users/tom/.atom/packages/prettier-eslint/node_modules/eslint/lib/testers/rule-tester.js:76:24)
at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:109:30)
at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:216:21)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
at Object.<anonymous> (/Users/tom/.atom/packages/prettier-eslint/node_modules/eslint/lib/api.js:11:17)
at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:109:30)
at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:216:21)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:50:27)
at Object.<anonymous> (/Users/tom/.atom/packages/prettier-eslint/dist/index.js:12:15)
at Module._compile (/Applications/Atom.app/Contents/Resources/app.asar/src/native-compile-cache.js:109:30)
at Object.value [as .js] (/Applications/Atom.app/Contents/Resources/app.asar/src/compile-cache.js:216:21)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
-0:04.1.0 tree-view:show (atom-workspace.workspace.scrollbars-visible-when-scrolling.theme-atom-material-syntax.theme-one-dark-ui)
{
"core": {
"audioBeep": false,
"disabledPackages": [
"tag",
"react",
"smart-tab-name",
"autocomplete-emojis",
"autocomplete-paths",
"atom-ternjs",
"ide-flow",
"prettier-atom"
],
"packagesWithKeymapsDisabled": [
"merge-conflicts"
],
"telemetryConsent": "limited",
"themes": [
"one-dark-ui",
"atom-material-syntax"
],
"useCustomTitleBar": true
}
}
# User
advanced-open-file, v0.16.5 (inactive)
alignment, v1.1.5 (inactive)
an-old-hope-syntax, v0.5.0 (inactive)
atom-beautify, v0.29.16 (inactive)
atom-eco, v0.2.0 (inactive)
atom-material-syntax, v1.0.2 (inactive)
atom-material-ui, v1.3.9 (inactive)
atom-ternjs, v0.17.0 (inactive)
atom-wallaby, v1.0.14 (inactive)
auto-indent, v0.5.0 (inactive)
autoclose-html, v0.23.0 (inactive)
autocomplete-emojis, v2.5.0 (inactive)
autocomplete-glsl, v0.2.3 (inactive)
autocomplete-html-entities, v0.1.0 (inactive)
autocomplete-modules, v1.6.7 (inactive)
autocomplete-paths, v1.0.5 (inactive)
autocomplete-python, v1.8.27 (inactive)
change-case, v0.6.3 (inactive)
chester-atom-syntax, v0.1.1 (inactive)
color-picker, v2.2.4 (inactive)
compare-files, v0.8.0 (inactive)
css-comb, v2.5.0 (inactive)
css-snippets, v1.1.0 (inactive)
dash, v1.7.0 (inactive)
es6-javascript, v1.0.0 (inactive)
file-icons, v2.0.10 (inactive)
file-types, v0.5.5 (inactive)
git-control, v0.8.2 (inactive)
git-log, v0.4.1 (inactive)
git-time-machine, v1.5.4 (inactive)
highlight-selected, v0.12.0 (inactive)
ide-flow, v0.8.0 (inactive)
javascript-snippets, v1.2.1 (inactive)
jump-to-import, v1.7.5 (inactive)
jumpy, v3.1.3 (inactive)
language-babel, v2.49.4 (inactive)
language-ect, v0.4.0 (inactive)
language-elm, v1.5.0 (inactive)
language-fish-shell, v1.0.5 (inactive)
language-glsl, v2.0.1 (inactive)
language-haml, v0.24.1 (inactive)
linter, v1.11.21 (inactive)
linter-coffeescript, v1.0.0 (inactive)
linter-eslint, v8.0.0 (inactive)
linter-glsl, v2.0.5 (inactive)
linter-stylelint, v3.7.0 (inactive)
merge-conflicts, v1.4.4 (inactive)
minimap, v4.26.7 (inactive)
minimap-cursorline, v0.2.0 (inactive)
minimap-find-and-replace, v4.5.1 (inactive)
minimap-highlight-selected, v4.5.0 (inactive)
open-recent, v5.0.0 (inactive)
pigments, v0.38.0 (inactive)
prettier-atom, v0.0.10 (inactive)
prettier-eslint, v1.1.0 (inactive)
qolor, v0.4.1 (inactive)
quick-query, v0.9.0 (inactive)
react, v0.16.2 (inactive)
script, v3.14.0 (inactive)
set-syntax, v0.3.2 (inactive)
show-in-system, v0.4.0 (inactive)
slime, v2.0.0 (inactive)
smart-tab-name, v1.0.5 (inactive)
sort-lines, v0.14.0 (inactive)
split-diff, v1.1.1 (inactive)
Sublime-Style-Column-Selection, v1.7.2 (inactive)
swap-panes, v0.2.0 (inactive)
sync-settings, v0.8.1 (inactive)
tab-switcher, v1.5.4 (inactive)
tag, v0.4.0 (inactive)
zentabs, v0.8.8 (inactive)
atom-dark-syntax, v0.28.0 (inactive)
atom-dark-ui, v0.53.0 (inactive)
atom-light-syntax, v0.29.0 (inactive)
atom-light-ui, v0.46.0 (inactive)
base16-tomorrow-dark-theme, v1.4.0 (inactive)
base16-tomorrow-light-theme, v1.4.0 (inactive)
one-dark-ui, v1.8.2 (inactive)
one-light-ui, v1.8.2 (inactive)
one-dark-syntax, v1.6.0 (inactive)
one-light-syntax, v1.6.0 (inactive)
solarized-dark-syntax, v1.1.1 (inactive)
solarized-light-syntax, v1.1.1 (inactive)
about, v1.7.2 (inactive)
archive-view, v0.62.0 (inactive)
autocomplete-atom-api, v0.10.0 (inactive)
autocomplete-css, v0.14.1 (inactive)
autocomplete-html, v0.7.2 (inactive)
autocomplete-plus, v2.33.1 (inactive)
autocomplete-snippets, v1.11.0 (inactive)
autoflow, v0.29.0 (inactive)
autosave, v0.23.2 (inactive)
background-tips, v0.26.1 (inactive)
bookmarks, v0.43.2 (inactive)
bracket-matcher, v0.85.1 (inactive)
command-palette, v0.39.1 (inactive)
deprecation-cop, v0.55.1 (inactive)
dev-live-reload, v0.47.0 (inactive)
encoding-selector, v0.22.0 (inactive)
exception-reporting, v0.40.0 (inactive)
find-and-replace, v0.204.5 (inactive)
fuzzy-finder, v1.4.0 (inactive)
git-diff, v1.2.0 (inactive)
go-to-line, v0.31.2 (inactive)
grammar-selector, v0.48.2 (inactive)
image-view, v0.60.0 (inactive)
incompatible-packages, v0.26.1 (inactive)
keybinding-resolver, v0.35.0 (inactive)
line-ending-selector, v0.5.1 (inactive)
link, v0.31.2 (inactive)
markdown-preview, v0.159.1 (inactive)
metrics, v1.1.2 (inactive)
notifications, v0.65.1 (inactive)
open-on-github, v1.2.1 (inactive)
package-generator, v1.0.2 (inactive)
settings-view, v0.244.0 (inactive)
snippets, v1.0.4 (inactive)
spell-check, v0.68.5 (inactive)
status-bar, v1.6.0 (inactive)
styleguide, v0.48.0 (inactive)
symbols-view, v0.113.1 (inactive)
tabs, v0.103.1 (inactive)
timecop, v0.33.2 (inactive)
tree-view, v0.211.1 (inactive)
update-package-dependencies, v0.10.0 (inactive)
welcome, v0.35.1 (inactive)
whitespace, v0.35.0 (inactive)
wrap-guide, v0.39.0 (inactive)
language-c, v0.54.0 (inactive)
language-clojure, v0.22.1 (inactive)
language-coffee-script, v0.48.1 (inactive)
language-csharp, v0.13.0 (inactive)
language-css, v0.40.1 (inactive)
language-gfm, v0.88.0 (inactive)
language-git, v0.15.0 (inactive)
language-go, v0.43.0 (inactive)
language-html, v0.47.1 (inactive)
language-hyperlink, v0.16.1 (inactive)
language-java, v0.24.0 (inactive)
language-javascript, v0.122.0 (inactive)
language-json, v0.18.3 (inactive)
language-less, v0.29.6 (inactive)
language-make, v0.22.2 (inactive)
language-mustache, v0.13.0 (inactive)
language-objective-c, v0.15.1 (inactive)
language-perl, v0.37.0 (inactive)
language-php, v0.37.3 (inactive)
language-property-list, v0.8.0 (inactive)
language-python, v0.45.1 (inactive)
language-ruby, v0.70.2 (inactive)
language-ruby-on-rails, v0.25.1 (inactive)
language-sass, v0.57.0 (inactive)
language-shellscript, v0.23.0 (inactive)
language-source, v0.9.0 (inactive)
language-sql, v0.25.0 (inactive)
language-text, v0.7.1 (inactive)
language-todo, v0.29.1 (inactive)
language-toml, v0.18.1 (inactive)
language-xml, v0.34.12 (inactive)
language-yaml, v0.27.1 (inactive)
# Dev
No dev packages
Thanks!
Is there a CLI for this? I tried can use prettier in vim because it is a cli tool, but I'm not sure how to use prettier-eslint in vim.
Enabling ESlint integration in settings and then formatting a JS file does not cause eslint --fix to be run.
Using linter-eslint's format-on-save does cause eslint --fix to transform my code as expected.
I have lint rules in .eslintrc.yml
with eslint npm install
ed.
node_modules/eslint/bin/eslint.js --fix tab.js
does the same thing as saving the file tab.js
and letting linter-eslint format it.
Can anyone advise?
Hi!
Even if I have "semi": ["error", "never"]
rule in .eslintrc prettier adds semi in the end of state and arrow functions in React Classes like this
class Example extends React.Component {
state = { imageLoading: true };
onImageLoadStart = () => this.setState({ imageLoading: true });
onImageLoadEnd = () => this.setState({ imageLoading: false });
render() {
// some code
}
}
It seems this is a bug
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.