How to config autocomplete-plus to suggest javascript without semicolon?
For example, I input log in atom, autocomplete-plus suggest console.log();.
I don't need the ;, how to config autocomplete-plus to remove ; when suggest.
You can add custom snippet to replace the default one. In order to do that open command palette Ctrl+Shift+P, search for Application: Open your Snippets and write a snippet for .source.js scope:
'.source.js':
'Log without ;':
'prefix': 'log'
'body': 'console.log()'
To override the default snippet you have to set prefix to log. If you want to learn more about snippets you can visit Flight Manual.
You can add a custom snippet:
Open the command palette with Ctrl+Shift+P.
Search for Application: Open your Snippets.
Add the folowing code:
'.source.js':
'Console log without ;':
'prefix': 'log'
'body': 'console.log($1)$2'
Related
I want to use <docs> blocks in my *.vue files to add documentation to components.
These blocks are correctly interpreted by vue-docgen-cli, but file compilation fails because vite is reading inside the block. For example, compilation of this SFC file fails with error: Uncaught SyntaxError: Unexpected identifier 'is':
<docs>
This is my component.
</docs>
<script setup lang="ts">
. . .
</script>
Is there a way to make vite ignore <docs> blocks? There is vite-plugin-vuedoc that seems useful, but the package does not install.
Thanks for your help!
mario
Environment
vue 3.2.45
vite 4.0.0
Windows 11
node 18.12.1
You will probably need to use a plugin for that.
Vite plugins are compatible with rollup plugin structure, so you may be able to use the rollup-plugin-re plugin to remove the desired content using a regexp. You could also write your own plugin that does exactly what you need.
Found a way. In vite.config.ts add the following code (from https://github.com/vitejs/vite/discussions/9301#discussioncomment-3224059):
const vueDocsPlugin = {
name: 'vue-docs',
transform(_code: unknown, id: string) {
if(!/vue&type=docs/.test(id)) return
return `export default ''`
}
}
Then in the plugins array add vueDocsPlugin.
I am working with WooCommerce for the first time and I am currently implementing WC filters on the shop page. The filters show up but are not functional, and the console is throwing the following errors:
ERROR 1: woocommerce_shared_settings filter in Blocks is deprecated. See https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/docs/contributors/block-assets.md
ERROR 2: deprecated.min.js?ver=932d8bb37da8bbb396a7a3f754345e08:2 select control in #wordpress/data-controls is deprecated since version 5.7. Please use built-in resolveSelect control in #wordpress/data instead.
The errors disappear when I remove the filters.
I have located the file where the deprecated code exists. I also read the WC docs about how to fix the issue and it presented this code:
use Automattic\WooCommerce\Blocks\Package;
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;
Package::container()->get( AssetDataRegistry::class )->add( $key, $value )
It doesn't say where to put this code, though. Where should I put it to solve this issue?
I have the same problem.
Which is the file you located?
Here also says you have to add, on the "client side", this code:
wc.wcSettings.getSetting( 'key' );
I have been trying to figure out how to add add timestamp to Atom Snippets.
'.text.plain':
'Timestamp':
'prefix': 'isoT'
'body': 'new Date().toISOString()'
This just prints the text and without ' it throws an error.
Is it possible to add javascript to an Atom snippet?
This is not possible. Snippets are stored in a CSON file, which is CoffeeScripts equivalent of JSON.
In all likelyhood, there already exists a package that inserts a timestamp. Otherwise, with knowledge of JavaScript, it's fairly easy to write your own. Take note that all commands provided by a package can be bound to a keystroke.
I am using urigo:angular2-meteor. When I add an empty main.ts in server folder, it always shows:
Cannot compile namespaces when the '--isolatedModules' flag is
provided.
Even I added the code below on the top of main.ts, it still shows same thing.
/// <reference path="../typings/angular2-meteor.d.ts" />
I faced similar issue in react + ts. I had commented out all my code.
Turns out
A global file cannot be compiled using '--isolatedModules'. Ensure your file contains imports, exports, or an 'export {}' statement.
So, added something like:
export const foo = 'foo';
or
export {}
It's a temporary solution, else you can delete the file with commented code or update tsconfig.json
I had the same problem and I added tsconfig.json into the root directory of my project.
{
"compilerOptions": {
"isolatedModules": false
}
}
I didn't have the time to dive into it, but it solved the problem.
I was getting this error when file was not imported in any other file.
Importing it in any other file (import {} from "/the-filename-having-compilation-error"), removed this error.
I had the same problem. I was made a component and never use that. When I imported that component In one of my page and use that and RERUN the project again , error was disappear.
This error occurs mostly when working with React + TypeScript
Simplest Solution for the same is to add 'export' keyword before the class creation or export the class in the end using
export default className;
If you have eslint installed check the rules section in .eslintrc.json file for any contradicting action.If the action you perforned is against the rule defined then error appears.
I am working on my own boilerplate using grunt's CLI possibilities like so grunt init:webdesign-project - for this I created a folder named webdesign-project within node_modules/grunt/init and a corresponding webdesign-project.js file. So far everything works great.
Now I wanted to insert my own "questions" with the grunt.helper function like this
grunt.helper('prompt_for', 'img_path', 'img')
however this gives me
TypeError: Cannot set property 'name' of undefined
at Object.module.exports.grunt.registerHelper.grunt.utils.spawn.cmd (/usr/lib/node_modules/grunt/tasks/init.js:573:17)
at Task.helper (/usr/lib/node_modules/grunt/lib/util/task.js:117:19)
at Object.exports.template (/usr/lib/node_modules/grunt/tasks/init/webdesign-project.js:30:11)
at Object.module.exports.grunt.registerHelper.done (/usr/lib/node_modules/grunt/tasks/init.js:240:27)
at Object.task.registerTask.thisTask.fn (/usr/lib/node_modules/grunt/lib/grunt/task.js:58:16)
at Task.<anonymous> (/usr/lib/node_modules/grunt/lib/util/task.js:341:36)
at Task.start (/usr/lib/node_modules/grunt/lib/util/task.js:357:5)
at Object.grunt.tasks (/usr/lib/node_modules/grunt/lib/grunt.js:143:8)
at Object.module.exports [as cli] (/usr/lib/node_modules/grunt/lib/grunt/cli.js:36:9)
at Object.<anonymous> (/usr/lib/node_modules/grunt/bin/grunt:19:14)
Isn't it possible to define your own variables using this function?
EDIT: Does anybody know if a documentation for this function exists? (Couldn't find one yet)
You shouldn't modify or add files within the node_modules/ folder as they will be overwritten upon updating with npm. Take a look at the init docs for creating custom init templates: https://github.com/gruntjs/grunt/blob/master/docs/task_init.md#creating-custom-templates
I recommend copying one of the existing init templates to: ~/.grunt/tasks/init/webdesign-project.js and modify from there.
I figured out how to achieve the "custom prompt" - in case anybody is interested:
Grunt's grunt.helper('prompt_for', '...') function apparently only takes a predefined set of values in lieu of '...'. Actually this should not be surprising, as there are some pretty unique features for some of those values (e.g. when you've entered testproject as your project's name, "(git://github.com/peter/testproject.git)" will automatically be proposed.
Solution: Take a look at the .js file of the gruntfile template (node_modules/grunt/tasks/init/gruntfile.js) - creating a custom prompt goes like this:
{
name: 'img_path',
message: 'Name the folder where all image files are located',
default: 'img',
// warning: '' couldn't find any use for this optional property
}
instead of
grunt.helper('prompt_for', 'img_path', 'img')