Giter VIP home page Giter VIP logo

prettier-standard's Issues

--dry-run?

Is there a way to run this as a linter and not have it --write and/or --fix? My use case is that I want to have the linter run as an onchange event and I don't want it writing files and causing my editor to prompt me that the buffer has changed. Thanks!

prettier-standard --check

It'd be nice to be able to check if files are properly formatted so we can use prettier-standard for lint tests, as well.

Ignore node_modules

> prettier-standard ./packages/hemera-sql-store/**/*.js

prettier-eslint [ERROR]: prettier formatting failed due to a prettier error
prettier-standard [ERROR]: There was an error formatting "./packages/hemera-sql-store/node_modules/resolve/index.js":
    SyntaxError: Unexpected token, expected => (10:7)
       8 |
       9 | exports = async
    > 10 | module.exports = async
         |       ^
      11 |
        at createError$1 (E:\Repositorys\hemera\node_modules\prettier\parser-babylon.js:1:112)
        at parse (E:\Repositorys\hemera\node_modules\prettier\parser-babylon.js:1:808)
        at Object.parse (E:\Repositorys\hemera\node_modules\prettier\index.js:3819:12)
        at formatWithCursor (E:\Repositorys\hemera\node_modules\prettier\index.js:21709:22)
        at format (E:\Repositorys\hemera\node_modules\prettier\index.js:21749:10)
        at Object.format (E:\Repositorys\hemera\node_modules\prettier\index.js:21974:12)
        at prettify (E:\Repositorys\hemera\node_modules\prettier-eslint\dist\index.js:149:29)
        at format (E:\Repositorys\hemera\node_modules\prettier-eslint\dist\index.js:135:20)
        at MapSubscriber.project (E:\Repositorys\hemera\node_modules\prettier-standard\lib\format-files.js:290:55)
        at MapSubscriber._next (E:\Repositorys\hemera\node_modules\rxjs\operator\map.js:77:35)
failure formatting 1 file with prettier-standard

.eslintignore

!/*.js
/tests/**/*.js
!/tests/**/jsfmt.spec.js
!/**/.eslintrc.js
/test.js
/dist/
**/node_modules/**
/website/static/lib/
/tests_integration/cli/
.nyc_output
coverage
test

.prettierignore

node_modules

Does this make ESLint more bearable?

What i mean is currently we have a webpack config with:

        {
          enforce: 'pre',
          test: /\.js$/,
          loader: 'eslint-loader',
          options: {
            formatter: require('eslint-friendly-formatter')
          },
          include: jsSrc,
          exclude: /(node_modules|bower_components|vendor)/
        },

And for example if we miss a space before some parenthesis on a function definition it will throw up this

Now since prettier-standard will handle these situations does this tone down the ESLint Standard formatting errors or do they still occur?

Update prettier version to 1.5.3

Is it used the prettier version that comes with the prettier-standard package, or does it uses whatever we install? If first, can you guys keep it updated or use what we install please?

Trying to run Prettier-standard as the cli for sublimeprettierjs doens't work

./node_modules/.bin/prettier-standard --stdin --no-config --print-width 80 --single-quote false --trailing-comma none --bracket-spacing true --jsx-bracket-same-line false --parser babylon --semi true --require-pragma false --prose-wrap preserve --arrow-parens avoid --tab-width 2 --use-tabs false --stdin-filepath /path/to/file

This is what command is run by JsPrettier sublime plugin when I configure my cli path to be prettier-standard, this command doesn't work when run alone, it seems because --stdin-filepath is not a valid flag, this causes JsPrettier to fall back to prettier, which causes linting issues. The --stdin-filepath option should still be supported to keep the apis the same and allow for the most interoperability.

Prettier Standard doesn't add spaces before params

First of all, thank you for all for your hard work on prettier-standard! It's awesome. Now, I'm not sure how to point this out, so that's why I'm opening this issue.

I was trying to add the lib to a project here, and everything went fine until I noticed that it wasn't adding spaces before the param list:

function foo(a) { console.log(a) }
// instead of
function foo (a) { console.log(a) }

At first, I thought it was something related to Flow (the file in question is annotated), but I was wrong. Digging deeper I was finally able to fix the issue. So, in my project I had [email protected]. After updating it to its latest version, we problem was gone. Actually, updating to 6.0.0 fixed the problem as well.

I wanted to open a PR here to update the dependency version, but then I realized prettier-standard doesn't depend on eslint-config-standard. I was taking a look at the diff between 5.3.5 and 6.0.0, and I believe it is something related to this line, but I'm not sure.

Maybe there was some crazy problem in my project itself, and updating eslint-config-standard made it go away. Still, I just wanted to share this here; case others face the same issue. Later today I will try to reproduce this on a brand new project to confirm if the problem happens.

Thanks!

JSX double quotes in output

JavaScript Standard Style prefers single quotes.

When testing with text below JSX gets converted to double quotes, the rest of the code gets single quotes.

const GoogleLoginButton = React.createClass({
  componentDidMount: () => {
    window.addEventListener('google-loaded', renderGoogleLoginButton)
    renderGoogleLoginButton()
  },
  render: () => <div id="gmailLogin" />
})

Standard 12

Now that standard@12 is out, it'd be awesome if this package could be updated to use that.

I've been locking down my version of standard to 10 because using version 11 broke stuff. I'm guessing version 12 isn't going to be any better.

Is there a formal to-do list for upgrading? I assume it involves upgrading eslint-config-standard as well as eslint itself?

Thanks!

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Conflicts when using standard babel-eslint parser.

I'm using decorators in my project so to get standard working I have this in my package.json:

"standard": {
  "parser": "babel-eslint"
}

When prettier-standard is also installed, I get errors like 'observer' is defined but never used.

Prettier-standard is somehow breaking the lint detection that my imports are in fact being used as decorators. Could there be a conflict in one of the dependencies? Any suggestions on a fix?

How to check for non-style problems?

Running standard will tell you if there are things like unused variables.
Running prettier-standard won't.

Ideally I think we want a tool that can automatically format code and also:

  • Check that code matches the output format.
  • Check that the code follows eslint rules like no unused variables.
  • These should be easy for a user to add to CI.

Prettier-standard output not equal to standard --fix output

Running prettier-standard does not replace double quotes in JSX.

C:\>prettier-standard --version
4.0.0
C:\>prettier-standard test.js
success formatting 1 file with prettier-standard

C:\>type test.js
const GoogleLoginButton = React.createClass({
  componentDidMount: () => {
    window.addEventListener('google-loaded', renderGoogleLoginButton)
    renderGoogleLoginButton()
  },
  render: () => <div id="gmailLogin" />
})

Using standard with --fix replaces the quotes:

C:\>standard --version
9.0.1
C:\>standard --fix test.js
standard: Use JavaScript Standard Style (http://standardjs.com)
  C:\test.js:1:7: 'GoogleLoginButton' is assigned a value but never used.
  C:\test.js:1:27: 'React' is not defined.
  C:\test.js:3:46: 'renderGoogleLoginButton' is not defined.
  C:\test.js:4:5: 'renderGoogleLoginButton' is not defined.

C:\>type test.js
const GoogleLoginButton = React.createClass({
  componentDidMount: () => {
    window.addEventListener('google-loaded', renderGoogleLoginButton)
    renderGoogleLoginButton()
  },
  render: () => <div id='gmailLogin' />
})

How to get this functionality with prettier-standard?

TypeError: eslint.linter.getRules is not a function

Runinig prettier-standard 'src/**/*.js' generates the following error:

TypeError: eslint.linter.getRules is not a function
    at formatFilesFromArgv (/usr/local/lib/node_modules/prettier-standard/lib/format-files.js:182:19)
    at _callee$ (/usr/local/lib/node_modules/prettier-standard/lib/index.js:22:72)
    at tryCatch (/usr/local/lib/node_modules/prettier-standard/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/prettier-standard/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/prettier-standard/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/usr/local/lib/node_modules/prettier-standard/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /usr/local/lib/node_modules/prettier-standard/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (<anonymous>)
    at new F (/usr/local/lib/node_modules/prettier-standard/node_modules/core-js/library/modules/_export.js:35:28)
    at /usr/local/lib/node_modules/prettier-standard/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12

I'm using node v8.9.3. Any ideas what might be the problem?

[suggestion] Configure GreenKeeper or similar to keep dependencies updated

First of all, thanks for this project! ❤️

So currently prettier-standard is using an exact version of prettier instead of a range, 1.7.0 specifically. Version 1.7.4 is out already and prettier-standard does not benefit from those patches.

Cannot tell if there's a reason behind using the exact version instead of the caret (^) range. I would use the range instead.

Additionally, I would set up a service like greenkeeper.io to help with maintenance.

Love,

Cannot run `npm run cli`

After cloning the repository and running npm install, I'm unable to run npm run cli.

At first, I tried just running npm run cli and I saw this error message:

> [email protected] cli /Users/maecapozzi/Desktop/Codes/prettier-standard
> babel-node src/index.js

/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
        throw e;
        ^

Error: Using `babel-preset-react-app` requires that you specify `NODE_ENV` or `BABEL_ENV` environment variables. Valid values are "development", "test", and "production". Instead, received: undefined. (While processing preset: "/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-preset-node-module/index.js")
    at buildPreset (/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-preset-node-module/index.js:48:11)
    at /Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-core/lib/transformation/file/options/option-manager.js:317:46
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at compile (/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-register/lib/node.js:103:45)
    at loader (/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/babel-register/lib/node.js:154:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] cli: `babel-node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] cli script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/maecapozzi/.npm/_logs/2018-02-10T20_07_49_143Z-debug.log

I then tried running NODE_ENV=development npm run cli --verbose and saw this error.

> [email protected] cli /Users/maecapozzi/Desktop/Codes/prettier-standard
> babel-node src/index.js


  Prettier and standard brought together!

  Usage
    $ prettier-standard [<glob>...]

  Options
    --log-level  Log level to use (default: warn)

  Examples
    $ prettier-standard 'src/**/*.js'
    $ echo "const {foo} = "bar";" | prettier-standard


npm verb lifecycle [email protected]~cli: unsafe-perm in lifecycle true
npm verb lifecycle [email protected]~cli: PATH: /Users/maecapozzi/.nvm/versions/node/v8.0.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/maecapozzi/Desktop/Codes/prettier-standard/node_modules/.bin:/Users/maecapozzi/.nvm/versions/node/v8.0.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
npm verb lifecycle [email protected]~cli: CWD: /Users/maecapozzi/Desktop/Codes/prettier-standard
npm info lifecycle [email protected]~cli: Failed to exec cli script
npm verb stack Error: [email protected] cli: `babel-node src/index.js`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (/Users/maecapozzi/.nvm/versions/node/v8.0.0/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
npm verb stack     at emitTwo (events.js:125:13)
npm verb stack     at EventEmitter.emit (events.js:213:7)
npm verb stack     at ChildProcess.<anonymous> (/Users/maecapozzi/.nvm/versions/node/v8.0.0/lib/node_modules/npm/lib/utils/spawn.js:40:14)
npm verb stack     at emitTwo (events.js:125:13)
npm verb stack     at ChildProcess.emit (events.js:213:7)
npm verb stack     at maybeClose (internal/child_process.js:887:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
npm verb pkgid [email protected]
npm verb cwd /Users/maecapozzi/Desktop/Codes/prettier-standard
npm verb Darwin 15.6.0
npm verb argv "/Users/maecapozzi/.nvm/versions/node/v8.0.0/bin/node" "/Users/maecapozzi/.nvm/versions/node/v8.0.0/bin/npm" "run" "cli" "--verbose"
npm verb node v8.0.0
npm verb npm  v5.0.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] cli: `babel-node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] cli script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/maecapozzi/.npm/_logs/2018-02-10T20_10_47_521Z-debug.log

This is my first time trying to run a command line application, so please forgive me if I'm making a mistake. Should I be able to run this script?

Decorator warnings after the update to 7.0.1 (from 6.0.0)

I ran into some minor issues after updating from 6.0.0 to 7.0.1.

Peer dependencies are not satisfied for these two packages anymore because of [email protected].

npm WARN [email protected] requires a peer of [email protected] - 3.x but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint@^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.

All decorators get reported as defined but never used, and functions using decorators are reported as is not defined.

/home/user/e/src/components/Transaction.js:2:10: 'translate' is defined but never used.
/home/user/e/src/components/Transaction.js:3:10: 'inject' is defined but never used.
/home/user/e/src/components/Transaction.js:3:18: 'observer' is defined but never used.
/home/user/e/src/components/AddressGet.js:4:18: 'computed' is defined but never used.

The ones above reference these imports.

import React from 'react'
import { translate } from 'react-i18next'
import { computed } from 'mobx'
import { inject, observer } from 'mobx-react'

export default @observer class Test extends React.Component {
  render () {
    return (
      <div>hello</div>
    )
  }
}

Update Prettier?

Hello,
Thanks for the great package!

I just noticed that prettier has been updated to 1.7.0 is this something that can easily be supported by prettier-standard?

Thanks!

Explain why both are needed

It would be great, for someone newer to all the tools available, what the benefits of using both standard and prettier are.

From what I understand, its that standard is used to enforce code quality rules, like no unused vars, whereas prettier is just about formatting style. If that's correct, it would be useful to put that somewhere in the readme.

Computed property even spacing standard

Expected "[" and "]" to be on the same line (standard/computed-property-even-spacing)

Ex:
attendancesByStudentId[studentId] = attendancesByStudentId[studentId] || [];

Prettier standard will turn it into:
attendancesByStudentId[studentId] = attendancesByStudentId[
studentId
] || [];

In this case maybe it should be on the same line.

prettier-standard on vscode

I love what the package does on cli. Is there a way of formatting with it in vscode?

I have the dbaeumer.vscode-eslint-1.4.5 extension installed and I would like to keep using my .eslintrc

Edit: my .estlintc

{
  "extends": ["standard"],
  "rules": {
    "camelcase": 0
  },
  "env": {
    "browser": true,
    "es6": true
  },
  "globals": {
    "app": true,
    "moment": true
  }
}

prettier-standard indentation

I had to disable prettier-standard because it is indenting files in a way standard doesn't like, I'm getting errors like: "Standard: expected indentation of 18 spaces but found 20. (indent)"

Issue with rule standard/computed-property-even-spacing

When linting with standard, prettier-standard formatting conflicts with the rule standard/computed-property-even-spacing.

Similar to prettier/eslint-config-prettier#29

Prettier standard wants this:

const { whatever } = loooooooooooooooooooooooong[
      something
].some.thiiiiiiiiiiiiing[0]

While standard wants:

const { whatever } = loooooooooooooooooooooooong[something].some.thiiiiiiiiiiiiing[0]

[Error] There was trouble creating the ESLint CLIEngine

Hello !

First of all, thanks for this amazing project, I love it :)

Context : I'm using prettier-standard with husky and lint-staged. Relevant parts of package.json :

{
  "name": "client",
  "version": "1.0.0",
  "private": true,
  "devDependencies": {
    "husky": "^0.13.2",
    "lint-staged": "^3.4.0",
    "prettier-standard": "^1.0.4",
    "react-scripts": "^0.8.4"
  },
  "dependencies": {
    ...
  },
  "scripts": {
   ...
    "precommit": "lint-staged"
  },
  "lint-staged": {
    "gitDir": "../",
    "linters": {
      "client/src/**/*.js": [
        "prettier-standard",
        "git add"
      ]
    }
  },
  "proxy": "http://localhost:8080"
}

I don't know if it's relevant, but my git repository contains two folders : client and server. Server is a Java spring boot application, and client contains the package.json above (hence the 'gitDir' option and the linter pattern)

When I run yarn run precommit, I get the following error :

yarn run v0.20.3
$ lint-staged 
 ❯ Running tasks for client/src/**/*.js
   → failure formatting 1 file with prettier-standard
   ✖ prettier-standard
     → failure formatting 1 file with prettier-standard
     git add
🚫 prettier-standard found some errors. Please fix them and try committing again.
prettier-eslint [ERROR]: There was trouble creating the ESLint CLIEngine. Is "eslintPath: /home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-standard/node_modules/eslint" a correct path to the ESLint module?
prettier-standard [ERROR]: There was an error formatting "/home/benoit/Documents/YR/ihm-address-control/client/src/index.js": 
    Error: Cannot find module '/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-standard/node_modules/eslint'
        at Function.Module._resolveFilename (module.js:472:15)
        at Function.Module._load (module.js:420:25)
        at Module.require (module.js:500:17)
        at require (internal/module.js:20:19)
        at getESLintCLIEngine (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-eslint/dist/index.js:219:20)
        at getConfig (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-eslint/dist/index.js:187:22)
        at format (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-eslint/dist/index.js:78:54)
        at MapSubscriber.rxReadFile.map.text [as project] (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/prettier-standard/lib/format-files.js:242:55)
        at MapSubscriber._next (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/rxjs/operator/map.js:77:35)
        at MapSubscriber.Subscriber.next (/home/benoit/Documents/YR/ihm-address-control/client/node_modules/rxjs/Subscriber.js:89:18)
failure formatting 1 file with prettier-standard

I'm guessing the problem commes from prettier-standard because the path it's complaining about is in prettier-standard, but I could be wrong.

The problem is that eslint is included both by prettier-standard and prettier-eslint, so yarn doesn't put it in the prettier-standard node_modules folder. I found a workaround by adding an old version of prettier-eslint in my package.json, so that the current version end up in the folder that causes the error.

Do you know what might be causng this ? I looked in the code a bit, and it seems this line should find the correct path, but it doesn't for some reason.

Is there an option that I can give to prettier-standard to avoid this, or is there a bug ?

Thanks in advance

Deprecation warning appears when formatting through stdin

Using the example in the Readme this is the output I get:

$ echo "const {foo} = "bar";" | prettier-standard
The react/jsx-space-before-closing rule is deprecated. Please use the react/jsx-tag-spacing rule with the "beforeSelfClosing" option instead.
const { foo } = bar

Ignoring files

Hello,

Could be possible that prettier-standard ignore files based on standard ignore property?

"standard": {
    "globals": [
      "fetch"
    ],
    "parser": "babel-eslint",
    "ignore": [ ←yep
      "/lib/"
    ]
  }

Wrong 'brace-style' (non-standard)

I have a problem with the following:

if (!id) { return }

get's fixed to:

if (!id) {
  return
}

However, I don't think this rule is written anywhere in the standard ruleset. And I'd like prettier-standard to not touch these lines...

Any idea how to fix this?

babel-preset-react-app requires that you specify NODE _ENV or BABEL_ENV

> node v8.9.4

after i globally installed pretter-stantard, run prettier-standard 'src/**/*.js', it gives below error

Error: Using babel-preset-react-app requires that you specify NODE _ENV or BABEL_ENV environment variables. Valid values are "develop
ment", "test", and "production". Instead, received: undefined

Rx defaults are not exported

Using node 8 LTS:

$ g ac "Remove logo from state"
husky > npm run -s precommit (node v9.2.0)

 ❯ Running tasks for *.js
   ✖ prettier-standard
     → at Module._compile (module.js:641:30)
     git add
✖ prettier-standard found some errors. Please fix them and try committing again.

          /Users/josefranciscoverdugambin/Projects/microlink/react-microlink/node_modules/prettier-standard/lib/format-files.js:132
var rxGlob = _Rx2.default.Observable.bindNodeCallback(_glob2.default);
                      ^

TypeError: Cannot read property 'Observable' of undefined
at Object.<anonymous> (/Users/josefranciscoverdugambin/Projects/microlink/react-microlink/node_modules/prettier-standard/lib/format-files.js:132:27)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Module.require (module.js:585:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/josefranciscoverdugambin/Projects/microlink/react-microlink/node_modules/prettier-standard/lib/index.js:41:20)
at Module._compile (module.js:641:30)

husky > pre-commit hook failed (add --no-verify to bypass)

I think code is not relevant; Rx polyfill is not exporting defaults 😢

throw in case of ESlint errors

Hi,

I'm using this setting

    "lint": "eslint src/**/*.js",
    "format": "prettier-standard 'src/**/*.js'",

What I think is unexpected is that when running link I get ESLint errors (valid/expected errors), and the prettier-standard works fine to fix most of the code, but it does not throw any error. I'd like it to throw errors, how can I do that?

21:36 $ yarn lint
yarn lint v0.24.4
$ eslint src/**/*.js

/Users/sebastienlorber/Desktop/projects/shoootin/mobile/photographers/src/styleguide/ShoootinButton.js
  6:27  error  'text' is missing in props validation     react/prop-types
  6:33  error  'onPress' is missing in props validation  react/prop-types

✖ 2 problems (2 errors, 0 warnings)

error Command failed with exit code 1.
21:36 $ yarn format
yarn format v0.24.4
$ prettier-standard 'src/**/*.js'
11 files were unchanged
✨  Done in 2.37s.

I'd like yarn format to fail, because there are eslint errors

Generator function not being fixed

Reproduction: https://github.com/mcchrish/prettier-standard-bug.

  1. npm run lint
  2. npm run format
  3. npm run lint

Results to:

$ standard index.js
standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
  /Users/mcchris/steve/prettier-standard-bug/index.js:1:9: Missing space before *.
error Command failed with exit code 1.

prettier-standard will format the following from:

function * test () {
  console.log('test')
}

test()

to:

function* test () {
  console.log('test')
}

test()

Workaround is running standard --fix after running format. I assumed this library will just pipe the result of prettier into standard --fix. There seems to be a bug?

space-before-function-paren not working

based on steps provided, I have configured prettier-standard but when I do git add space-before-function-paren eslint rule seems not working:

Source:
function a () { if (true) { } }

After Git Add:
function a() { if (true) { } }

It is removing the space before function parentheses. I have also tried to put the same in .eslintrc but then also it is not working.

{ "rules": { "object-curly-spacing": ["error", "always"], "space-before-function-paren": ["error", { "anonymous": "always", "named": "always", "asyncArrow": "always" }] } }

Can you please guide me how to enable this feature. Please find below software stack:

"prettier": "1.2.2",
"prettier-standard": "4.1.0"

Default glob pattern like standard

Would love to have prettier-standard use the same default glob pattern as standard itself:

by default standard will look for all files matching the patterns: **/.js, **/.jsx.

Certain paths (node_modules/, coverage/, vendor/, *.min.js, bundle.js, and files/folders that begin with . like .git/) are automatically ignored.
Paths in a project's root .gitignore file are also automatically ignored.

This would make running prettier-standard operate similar to standard (no options necessary, just normal conventional configuration by default)

Vim integration mangles code

From what I can tell, the vim integration does some bizarre things to the buffer code.

I've added autocmd BufWritePre *.js :normal gggqG to my .vimrc and when I save my files, all the contents get turned into one long line of code. Here is a video of it happening:

This might be a .vimrc conflict but I'm not sure how to determine what is at fault. If I run :!prettier-standard % in the buffer the file gets modified by prettier-standard correctly.

Thanks for any suggestions

discrepency between standard and prettier-standard

Using:

  • latest standard (10.0.3)
  • latest prettier-standard (7.0.3)

My goal here, which I think is a common use case is to use prettier-standard in a pre-commit hook to format the code that gets committed. I also want to have the code that gets committed be compliant with StandardJS. Ultimately, the CI server will run the standard CLI command on the relevant directories to confirm that the code passes the StandardJS linting rules.

I have a couple examples below where the code passes the standard command before running prettier-standard but does not pass the standard command after prettier-standard does the formatting.

I have supplied a small gist here with the starting code for both Example 1 and Example 2: https://gist.github.com/dylanjha/1d07f355636e15293df46c9db6781c5d

Thank you to anyone who can chime in 👍 . Perhaps I'm going about this the wrong way or missing something obvious here.

Example 1

I have a file that looks like this:

const obj = {}

function doSomething () {
  return new Promise((resolve, reject) => {
    obj.create({
      name: 'Dylan',
      username: 'dylan',
      photo: 'avatarurl.com',
      email: '[email protected]'
    },
    { url: window.location.href })
    .then(() => {})
  })
}

doSomething()

Right now, this file is compliant with StandardJS, running the standard cli passes.

Now I run prettier-standard, here's what I get, which looks nice 💅

const obj = {}

function doSomething () {
  return new Promise((resolve, reject) => {
    obj
      .create(
        {
          name: 'Dylan',
          username: 'dylan',
          photo: 'avatarurl.com',
          email: '[email protected]'
        },
        { url: window.location.href }
      )
      .then(() => {})
  })
}

doSomething()

Problem is, this file is no longer StandardJS complaint, running the standard CLI fails:

testing/gist.js:7:9: Expected indentation of 6 spaces but found 8.
testing/gist.js:8:11: Expected indentation of 8 spaces but found 10.
testing/gist.js:9:11: Expected indentation of 8 spaces but found 10.
testing/gist.js:10:11: Expected indentation of 8 spaces but found 10.
testing/gist.js:11:11: Expected indentation of 8 spaces but found 10.
testing/gist.js:12:9: Expected indentation of 6 spaces but found 8.

Example 2

Starting with this code

function doSomething () {
  return new Promise((resolve, reject) => {
    return reject( // eslint-disable-line prefer-promise-reject-errors
      'reject this thing'
    )
  })
}
doSomething()

StandardJS has a rule to pass in error objects to reject (not strings). This rules is being explicitly disabled with the in-line comment, so this code passes the StandardJS standard CLI command.

When prettier runs, it reformats the code to look like this:

function doSomething () {
  return new Promise((resolve, reject) => {
    return reject(
      // eslint-disable-line prefer-promise-reject-errors
      'reject this thing'
    )
  })
}

doSomething()

Now, because the eslint-disable comment was moved to it's own line, the code is no-longer compliant with StandardJS and no longer passes the standard command.

semi-colons not being removed

Running prettier-standard 'src/*.js' formats my code with prettier, but also adds back in semi-colons so it no longer adheres to Standard.

I can work around it by adding an .eslintrc of the following, but I expected this to be default behaviour:

{
  "rules": {
    "semi": ["error", "never"]
  }
}

Is there a way to pass options to the underlying prettier instance? Could then pass --no-semi, but ideally this package would handle this anyway.

Doesn't show all `standard` errors

First off, thanks for building this! It's a very easy way to have the linting of standard with the formatting of prettier :)

However, prettier-standard doesn't show the same errors that standard does. For example, in the prettier-standard repo at commit 54948a5 (with prettier-standard linked globally):

$ prettier-standard src/format-files.js
1 file was unchanged
$ standard src/format-files.js
standard: Use JavaScript Standard Style (https://standardjs.com)
  /Users/josephfrazier/workspace/prettier-standard/src/format-files.js:39:10: 'coercePath' is defined but never used.
$

Difference from standard

https://gist.github.com/johnmuhl/4592c57c0b1c85e5b4c8f035c3ecf6eb

The configuration-original.js file is generated by the rails/webpacker gem; configuration.js is the result of running prettifier-standard. standard-out.sh shows the offending code; i.e.

// Expected "[" and "]" to be on the same line
const paths = safeLoad(readFileSync(join(configPath, 'paths.yml'), 'utf8'))[
  env.NODE_ENV
]

Standard 10.x and 9.x show the same error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.