Giter Club home page Giter Club logo

grunt-prettier's People

Contributors

greenkeeper[bot] avatar h223chen avatar krogh avatar laurent-malvert avatar markjaquith avatar poalrom avatar simonmayerhofer avatar tkambler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

grunt-prettier's Issues

glob matching with *.(js|json) not working

This is not working (matches nothing):

{
    options: {
      singleQuote: true
    },
    files: {
      src: [
        '*.(js|json)',
        'tasks/**/*.(js|json)',
        'src/js/components/**/*.(js|json)'
      ]
    }
  }

according to the glob documentation this should be working (as far as I undertand it).

Changes to the following works:

{
    options: {
      singleQuote: true
    },
    files: {
      src: ['*.js', 'tasks/**/*.js', 'src/js/components/**/*.js']
    }
  }

Background is that next to using grunt, I also use onchange as described at https://prettier.io/docs/en/watching-files.html and there the above globs work perfectly and I do not seem to be able to reuse them in grunt-prettier. Here's my package.json:

  "scripts": {
    "startPrettierWatcher":
      "onchange \"*.(js|json)\" \"tasks/**/*.(js|json)\" \"src/components/**/*.(js|json)\" -- prettier --write {{changed}}",
  },

Hot formatting not working as intended

I tried using hot formatting as mentioned in the repository and had a setup similar to this in my Gruntfile:

src: [
  "my-awesome-project/**.js",
  "!my-awesome-project/**.config.js"
]

What happened: The formatted JS was written concatenated into one file called src.

Expected behaviour: Write formatted contents back to each file.

Versions:

[email protected]
grunt v0.4.5

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper 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 click the 'fix repo' button on account.greenkeeper.io.

Ignored unknown option "overrides"

Hi,
I use the .prettierrc file for my configuration.

{
	'singleQuote': true,
	'useTabs': true,
	'trailingComma': 'all',
	'overrides': [
		{
			'files': '.prettierrc',
			'options': { 'parser': 'json' },
		},
		{
			'files': '.eslintrc',
			'options': { 'parser': 'json' },
		}
	]
}

I get the message
Ignored unknown option '{ "overrides": [{"files":".prettierrc","options":{"parser":"json"}},{"files":".eslintrc","options":{"parser":"json"}}] }'.

Thanks for your help and this nice grunt plugin :)

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper 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 click the 'fix repo' button on account.greenkeeper.io.

bug(html): PC hangs and big CPU usage

1. Summary

If I use grunt-prettier for real HTML files:

    task not ended + big CPU usage.

2. Reproducibility

grunt-prettier works (for types of the files):

  1. Normally and quickly:

    1. CSS and JavaScript
    2. HTML boilerplates
  2. Slow:

    1. Small HTML
  3. Very slow:

    1. Real HTML

3. Environment

  1. Operating system:

    1. Windows 10.0.18362 Enterprise 64-bit EN (local)
    2. Ubuntu 16.04.6 LTS (Travis CI)
  2. Node.js 12.12.0

  3. grunt-cli 1.2.0, grunt 1.0.4

  4. Prettier 1.18.2

  5. grunt-prettier 1.3.0

4. MCVE

You can see data on KiraPrettierHTML branch of my demo GitHub repository.

  • Gruntfile.coffee:
module.exports = (grunt) ->

    grunt.loadNpmTasks 'grunt-prettier'
    grunt.initConfig
        prettier:
            files:
                src: ["KiraArchitecture.html"]

    return
  • KiraArchitecture.html:

My real HTML web-page

  • .travis.yml:
git:
  depth: 1

language: node_js

node_js:
- node

install:
- npm install -g grunt-cli prettier

before_script:
- npm install

script:
- prettier --write --loglevel debug KiraArchitecture.html
- grunt prettier --verbose

5. Steps to reproduce

  1. CLI Prettier:

    prettier --write --loglevel debug KiraArchitecture.html
    
  2. grunt-prettier:

    grunt prettier --verbose
    

6. Expected behavior

If Prettier CLI:

$ prettier --write --loglevel debug KiraArchitecture.html

[debug] normalized argv: {"_":["KiraArchitecture.html"],"color":true,"editorconfig":true,"write":true,"loglevel":"debug","plugin-search-dir":[],"plugin":[],"ignore-path":".prettierignore","debug-repeat":0,"config-precedence":"cli-override"}

[debug] resolve config from 'KiraArchitecture.html'

[debug] loaded options `{"useTabs":true,"tabWidth":4,"endOfLine":"lf"}`

[debug] applied config-precedence (cli-override): {"endOfLine":"lf","tabWidth":4,"useTabs":true}

KiraArchitecture.html 1658ms

The command "prettier --write --loglevel debug KiraArchitecture.html" exited with 0.

7. Unexpected behavior

Else grunt-prettier:

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.

Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received

The build has been terminated

Big CPU usage, PC hangs:

Prettier Real HTML

Thanks.

Cannot read property 'replace' of undefined

Hello
I know in documentation to npm module required grunt version is ~0.4.5

But is there any change library can be adapted for grunt 1.0.3 or higher?

Once triggered in precommit hook output is:

Warning: Cannot read property 'replace' of undefined Use --force to continue. 
Aborted due to warnings.

Grunt 1.0.3

grunt init config:

prettier: {
      files: {
        src: [
          "./some_file"
        ]
      }
    },

grunt task:

  grunt.registerTask('prettier', 'Codestyle', [
    grunt.loadNpmTasks('grunt-prettier')
  ]);

.prettierrc.json content:

{
  "tabWidth": 2,
}

Ignored unknown option configFile

If I run grunt prettier with the following task configuration

prettier: {
        build: {
          src: ["*.js", "bin/**/*.js"]
        },
        app: {
          src: ["src/js/**/*.js"]
        }
      }

I get the warning

Ignored unknown option `{ "configFile": ".prettierrc" }`.

on the console.

Parser override not working

Seems like overriding parsers in .prettierrc doesn't work.

.prettierrc

{
	"singleQuote": true,
	"useTabs": true,
	"trailingComma": "all",
	"overrides": [
		{
			"files": [".prettierrc", ".firebaserc"],
			"options": { "parser": "json" }
		}
	]
}

When I run e.g. prettier --write .firebaserc it will be formatted. When running grunt prettier I get a error:

...
Reading tasks/options/watch.js...OK
Writing tasks/options/watch.js...OK
Prettify file "tasks/options/watch.js".
Reading firebase.json...OK
Writing firebase.json...OK
Prettify file "firebase.json".
Reading package.json...OK
Writing package.json...OK
Prettify file "package.json".
Reading .firebaserc...OK
Warning: Unexpected token, expected ";" (2:12)
  1 | {
> 2 | 	"projects": {
    | 	          ^
  3 | 		"default": "fb-website-checker"
  4 | 	}
  5 | } Use --force to continue.

Aborted due to warnings.

Does not work with scss files

grunt-prettier works great with JS files. Thanks for writing this plugin!

I really would like to use it with SCSS files as well, but it just gives an error when attempting to do that:
Running "prettier:dev" (prettier) task
Warning: Unexpected token

I have my files set up for SCSS only for testing:
prettier: {
options: {
singleQuote: true,
useTabs: true
},
dev: {
src: ["src//.scss"]
}

I am not completely sure, but somehow it seems that prettier.format() API call for some reason seems to expect a JS file, but I am not sure why.

Would it be possible to add SCSS(and CSS) file support in?

Thanks!

How do I call 'check' api from my Gruntfile?

I am sorry, I am new to Grunt, so it may be a silly questions to ask, but I am not able to figure out how to pass the 'api' type I wish to use to your plugin.

The plugin by default uses 'format' api, but I only want to use 'check'. How should I add the config to my Gruntfil, so that your plugin onlyc checks the files.

Please help

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.