poalrom / grunt-prettier Goto Github PK
View Code? Open in Web Editor NEWPrettier plugin for Grunt
License: MIT License
Prettier plugin for Grunt
License: MIT License
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}}",
},
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
Is there any way to provide configuration file ( https://github.com/prettier/prettier#configuration-file )
using grunt-prettier
The prettier version is significantly old. Can you help me move to the 2.x branch?
🚨 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.
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 :)
🚨 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.
If I use grunt-prettier for real HTML files:
task not ended + big CPU usage.
grunt-prettier works (for types of the files):
Normally and quickly:
Slow:
Very slow:
Operating system:
Node.js 12.12.0
grunt-cli 1.2.0, grunt 1.0.4
Prettier 1.18.2
grunt-prettier 1.3.0
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
:.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
CLI Prettier:
prettier --write --loglevel debug KiraArchitecture.html
grunt-prettier:
grunt prettier --verbose
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.
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:
Thanks.
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,
}
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.
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.
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!
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
I want to configure a precommit task that doesn't do the actual reformat but only tells me if a file is unformatted. I can't find a way to do this with grunt-prettier, is it supported?
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.