prettier configuration error, prettier not working - prettier

I got an error in prettier. how to solve this issue?

It looks like, for whatever reason, there is no configuration file for prettier in the place it is looking for it, namely your root folder.
I would check if a ~\.prettierrc.js file exists, by typing cd ~\ && dir /ah and see if .pretterrc.js shows up. If not, create that file and copy this:
module.exports = {
trailingComma: "es5",
tabWidth: 4,
semi: false,
singleQuote: true,
};
which is just the default configuration found here: https://prettier.io/docs/en/configuration.html

Related

Is there a better way to set C++ format options in VS Code instead of packing them into one long string?

I am using Clang C++ on macOS in VS Code and I have overridden some C++ formatting options in 'settings.json' file. I am able to set some things from the Settings UI, but for more detailed settings I have added the following entry in 'settings.json':
"C_Cpp.clang_format_fallbackStyle": "{ EmptyLineBeforeAccessModifier: Never, AllowShortCaseLabelsOnASingleLine: true, ConstructorInitializerIndentWidth: 2, ColumnLimit: 120, PointerAlignment: Left, AllowShortIfStatementsOnASingleLine: true, SpaceAfterTemplateKeyword: false, AlignOperands: false, ContinuationIndentWidth: 2 }"
I found descriptions of these settings at Clang Format Style Options
It seems to work properly and my C++ files get nicely reformatted when I hit Alt-F, but I was wondering if there was a nicer way to specify the settings instead of using one long string in settings.json.
For example, it would be nice if I could specify each format setting on a different line or split up the string somehow into multiple lines. I don't think splitting a string into multiple lines can be done in regular JSON files, but perhaps VS code has a way?
I'm not sure if it's relevant, but I have set 'C_Cpp: Clang_format_fallback Style' to 'Google' in the Setting UI.
Any suggestions would be greatly appreciated.
Based on a comment from Frank I tried using .clang-format file and after some messing around I got it to work. I first tried putting .clang-format inside the .vscode directory in my project, but that didn't work. After reading move about clang format I moved the file to my home directory (note the file format for .clang-format is YAML instead of JSON) since it needs to be in the same directory or a parent directory of the file being formatted.
I don't think it was required, but I also ended up running brew install clang-format since I couldn't find it in my path. Once that was installed I ran clang-format -style google -dump-config>~/.clang-format and then made the overrides I wanted.
I was able to remove the long fallback string from settings.json and VS Code is still formatting nicely using my style overrides in my new .clang-format file.

Dockerfile: ADD and COPY fails without error

When building the Dockerfile, no errors occur. This is true for COPY and ADD
Step 6/6 : COPY linter /etc/
---> 4cc83d919016
Successfully built 4cc83d919016
The image gets tagged and pushed as if everything worked correctly. When I attach to the container after pull and run, the directory /etc/linters is not present.
How to debug/resolve this?
Asking questions here is somehow catalytic...
The problem was, that my command just copied the content of linter to /etc/
What I wanted to achieve was, to add the complete dir to /etc. The correct add command would be:
ADD linter /etc/linter/

WebStorm: configure Prettier to use tabs?

The Prettier docs say to use --use-tabs to override the default behavior. WebStorm automatically populated the Prettier package:
That's a folder. I tried changing it to npm\prettier.cmd and adding the switch, but that doesn't work (It just turns red).
How can I set WebStorm to use tabs with Prettier?
If your project has a .editorconfig file, you can override the indent_style setting in there.
# top-most EditorConfig file
root = true
[*]
indent_size = 4
indent_style = tab
I found these resources helpful too:
https://prettier.io/docs/en/options.html#tabs
https://editorconfig.org/
Due to https://github.com/prettier/prettier/pull/2434 fix, Prettier (even global!) uses configuration file nearest to current file (up the directory tree) when formatting.
So, you can install it globally and configure it in your project, by adding the corresponding .prettierrc file or "prettier" section in project package.json.

Change filename of Bower dependencies

I've got an Ember app and want to use external libraries (like in my case gamps api). So I've put a dependency in my bower.json file which looks like that:
"dependencies": {
...
"gmaps-with-token": "https://maps.googleapis.com/maps/api/js?key=XXXXX",
...
}
Unfortunately, bower install will load a file called 'index' without any suffix. However importing that file in my ember-cli-app with app.import(app.bowerDirectory + 'gmpas-width-token/index');
won't work and I don't know why.
When I try to start the ember server, ember prompts
"You must pass a file to 'app.import'. ..."
Can anybody explain to me why this is a problem? Maybe it matters because of the missing file-suffix at the "index" file.
Can anybody explain me why this is a problem? Maybe its matters because of the missing file-suffix at the "index" file.
That's exactly what it is. Broccoli is expecting a file with a file-extension. I don't know why, but it assumes that a path with no extension is a directory. You need to ensure that the file has an extension. You can do one of two things for that:
Download the file manually and put it in your vendor folder. This will ensure it has an extension.
Create a bower shim by creating a repository that hosts the file (with an extension) then point bower at that repo instead of the Google Maps URL.
The first option will allow you to get up and running more quickly, so that might be the preferred option. You can always switch to the second option later if you need.

grunt-karma not running the spec file when using shared config

I created a basic project to try and get Gruntjs, Karma and Jasmine to play together. When I setup the karma.conf.js file with all of the neccesary files, everything works and the tests pass.
When I try to split them up in Grunt though, I get problems.
Gruntfile.js
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
karma: {
options: {
configFile: 'karma.conf.js'
},
basicController: {
files: ['/basicController/scBasicControllerCtrl.js', '/basicController/test/ControllersSpec.js']
},
overworkedController: {
src: ['overworkedController/scOverworkedControllerCtrl.js', 'overworkedController/test/ControllersSpec.js']
}
}
});
The documentation at grunt-karma show to use "files:" when splitting up the modules. I did that under the basicController module and when I try to run $ grunt karma:basicController --verbose, I get an error saying
Warning: Cannot use 'in' operator to search for 'src' in /basicController/scBasicControllerCtrl.js Use --force to continue
Aborted due to warnings.
When I run $ grunt karma:overworkedControllers --verbose (using "src" instead of "files", it looks like everything is going to work and the Chrome browser launches but then is says it executed 0 of 0 ERROR.
There should be 3 tests.
Let me know if there's any more info I could post.
My understanding of grunt-karma was incorrect.
I thought I could have the base and source files in the karma.conf.js file. Then in each module, I'd just add the specific files needed for that module and test.
The way it actually works is that the files declared in each module completely overwrite the files property in the karma.conf.js file. Not append to them.
I ended up creating an array in Gruntfile.js that contains all of the source .js files and just concat the necessary files to it in each module.