HTMLHint

Integrates the HTMLHint static analysis tool into Visual Studio Code.

hero

Configuration

The HTMLHint extension will attempt to use the locally installed HTMLHint module (the project-specific module if present, or a globally installed HTMLHint module). If a locally installed HTMLHint isn't available, the extension will use the embedded version (current version 0.9.13).

To install a version to the local project folder, run npm install --save-dev htmlhint. To install a global version on the current machine, run npm install --global htmlhint.

Usage

The HTMLHint extension will run HTMLHint on your open HTML files and report the number of errors on the Status Bar with details in the Problems panel (View > Problems).

status bar

Errors in HTML files are highlighted with squiggles and you can hover over the squiggles to see the error message.

hover

Note: HTMLHint will only analyze open HTML files and does not search for HTML files in your project folder.

Rules

The HTMLHint extension uses the default rules provided by HTMLHint.

{
    "tagname-lowercase": true,
    "attr-lowercase": true,
    "attr-value-double-quotes": true,
    "doctype-first": true,
    "tag-pair": true,
    "spec-char-escape": true,
    "id-unique": true,
    "src-not-empty": true,
    "attr-no-duplication": true,
    "title-require": true
}

.htmlhintrc

If you'd like to modify the rules, you can provide a .htmlhintrc file in the root of your project folder with a reduced ruleset or modified values.

You can learn more about rule configuration at the HTMLHint Usage page.

Additional file types

By default, HTMLHint will run on any files associated with the "html" language service (i.e., ".html" and ".htm" files). If you'd like to use the HTMLHint extension with additional file types, you have two options:

Option 1: Treating your file like any other html file

If you would like the file type to be treated as any other html file (including syntax highlighting, as well as HTMLHint linting), you'll need to associate the extension with the html language service. Add the following to your VS Code settings, replacing "*.ext" with your file extension.

{
  "files.associations": {
    "*.ext": "html",
  }
}

Option 2: Associating HTMLHint extension with your file type

If your file type already has an associated language service other than "html", and you'd like HTMLHint to process those file types, you will need to associate the HTMLHint extension with that language service. Add the following to your VS Code settings, replacing "mylang" with your language service. For example, if you want HTMLHint to process .twig files, you would use "twig". Note that with this configuration, you need to open an html file first to activate the HTMLHint extension. Otherwise, you won't see any linter errors, (the extension is hard-coded to activate when the html language service activates).

{
  "htmlhint.documentSelector": [
    "html",
    "mylang"
  ]
}

Settings

The HTMLHint extension provides three settings:

  • htmlhint.enable - disable the HTMLHint extension globally or per workspace.
  • htmlhint.documentSelector - specify additional language services to be linted
  • htmlhint.options - provide a rule set to override on disk .htmlhintrc or HTMLHint defaults.

You can change settings globally (File > Preferences > User Settings) or per workspace (File > Preferences > Workspace Settings). The Preferences menu is under Code on macOS.

Here's an example using the htmlhint.documentSelector and htmlhint.options settings:

"htmlhint.documentSelector: [
    "html",
    "htm",
    "twig"
],
"htmlhint.options": {
    "tagname-lowercase": false,
    "attr-lowercase": true,
    "attr-value-double-quotes":  true,
    "doctype-first": true
}

 

IntelliSense for CSS class names in HTML

IntelliSense for CSS class names in HTML

A Visual Studio Code extension that provides CSS class name completion for the HTML class attribute based on the definitions found in your workspace or external files referenced through the link element.

Features

  • Gives you autocompletion for CSS class definitions that can be found in your workspace (defined in CSS files or the in the file types listed in the Supported Language Modes section)
  • Supports external stylesheets referenced through link elements in HTML files
  • Command to manually re-cache the class definitions used in the autocompletion
  • User Settings to override which folders and files should be considered or excluded from the caching process

Supported Language Modes

  • HTML
  • Razor
  • PHP
  • Laravel (Blade)
  • JavaScript
  • JavaScript React (.jsx)
  • TypeScript React (.tsx)
  • Vue (.vue) [requires octref.vetur]
  • Twig
  • Markdown (.md)
  • Embedded Ruby (.html.erb) [requires rebornix.Ruby]
  • Handlebars
  • EJS (.ejs)

Specific Support

  • "@apply" directive in CSS, SASS and SCSS Files for Tailwind CSS
  • "className" and "class" in TypeScript React, JavaScript and JavaScript React language modes
  • Emmet abbreviations support triggered by typing a "." (comes disabled by default, check the User Settings topic for more information)

Contributions

You can request new features and contribute to the extension development on its repository on GitHub. Look for an issue you're interested in working on, comment on it to let me know you're working on it and submit your pull request! :D

What's new in version 1.17.1 (Fev 18, 2018)

  • Added support for "class" in TypeScript React, JavaScript and JavaScript React language modes. Previously only "className" was supported.
  • Added support for Emmet.

Check out the changelog for the current and previous updates.

Usage

If there are HTML or JS files on your workspace, the extension automatically starts and looks for CSS class definitions. In case new CSS classes are defined, or new CSS files are added to the workspace, and you also want auto-completion for them, just hit the lightning icon on the status bar. Also, you can execute the command by pressing Ctrl+Shift+P(Cmd+Shift+P for Mac) and then typing "Cache CSS class definitions."

User Settings

The extension supports a few user settings, changes to these settings will be automatically recognized and the caching process will be re-executed.

Folders and Files

You can change the folders and files the extension will consider or exclude during the caching process by setting the following user settings:

  • "html-css-class-completion.includeGlobPattern" (default: "**/*.{css,html}")
  • "html-css-class-completion.excludeGlobPattern" (default: "")
Emmet

Emmet support comes disabled by default, the reason behind this choice is because it the current implementation simply triggers completion when you type a "." (period) and this behavior might be considered a little annoying, but it might change in the future.

Currently it supports the following languages (those are language identifier): "html", "razor", "php", "blade", "vue", "twig", "markdown", "erb", "handlebars", "ejs", "typescriptreact", "javascript", "javascriptreact".

  • "html-css-class-completion.enableEmmetSupport" (default: false)

 

JavaScript (ES6) code snippets

This extension contains code snippets for JavaScript in ES6 syntax for Vs Code editor (supports both JavaScript and TypeScript).

Installation

In order to install an extension you need to launch the Command Pallete (Ctrl + Shift + P or Cmd + Shift + P) and type Extensions. There you have either the option to show the already installed snippets or install new ones. Search for JavaScript (ES6) code snippets and install it.

Supported languages (file extensions)

  • JavaScript (.js)
  • TypeScript (.ts)
  • JavaScript React (.jsx)
  • TypeScript React (.tsx)
  • Html (.html)
  • Vue (.vue)

Snippets

Below is a list of all available snippets and the triggers of each one. The means the TAB key.

Import and export

TriggerContent
imp→imports entire module import fs from 'fs';
imn→imports entire module without module name import 'animate.css'
imd→imports only a portion of the module using destructing import {rename} from 'fs';
ime→imports everything as alias from the module import * as localAlias from 'fs';
ima→imports only a portion of the module as alias import { rename as localRename } from 'fs';
enf→exports name function export const log = (parameter) => { console.log(parameter);};
edf→exports default function export default (parameter) => { console.log(parameter);};
ecl→exports default class export default class Calculator { };
ece→exports default class by extending a base one export default class Calculator extends BaseClass { };

Class helpers

TriggerContent
con→adds default constructor in the class constructor() {}
met→creates a method inside a class add() {}
pge→creates a getter property get propertyName() {return value;}
pse→creates a setter property set propertyName(value) {}

Various methods

TriggerContent
fre→forEach loop in ES6 syntax array.forEach(currentItem => {})
fof→for ... of loop for(const item of object) {}
fin→for ... in loop for(const item in object) {}
anfn→creates an anonymous function (params) => {}
nfn→creates a named function const add = (params) => {}
dob→destructing object syntax const {rename} = fs
dar→destructing array syntax const [first, second] = [1,2]
sti→set interval helper method setInterval(() => {});
sto→set timeout helper method setTimeout(() => {});
prom→creates a new Promise return new Promise((resolve, reject) => {});
thenCatch→adds then and catch declaration to a promise .then((res) => {).catch((err) => {});

Console methods

TriggerContent
cas→console alert method console.assert(expression, object)
ccl→console clear console.clear()
cco→console count console.count(label)
cdi→console dir console.dir
cer→console error console.error(object)
cgr→console group console.group(label)
cge→console groupEnd console.groupEnd()
clg→console log console.log(object)
clo→console log object with name console.log('object :', object);
ctr→console trace console.trace(object)
cwa→console warn console.warn
cin→console info console.info
clt→console table console.table

 

jshint

Integrates JSHint into VS Code.

Setup

The extension looks for a jshint module in the current directory and in the global package location. You can install jshint locally with npm install jshint or globally with npm install -g jshint. If your jshint module is in a different location, use the jshint.nodePath setting to specify the correct path. The jshint.packageManager setting can be used to specify which package manager you are using, npm or yarn.

To check where jshint is loaded from, use the JSHint: Show output command after the extension has started to view the extension logs in the output panel.

Configuration Options

The jshint extension uses the standard jshint configuration options described on the jshint web site.

The options can be specified in a number of locations mostly mimicing jshint's default behavior. The extension looks for its configuration options the following way and stops at the first positive match:

  1. An options file specified in the user or workspace settings like this: "jshint.config" : "<file path>". The file path is interpreted relative to the workspace's root folder.
  2. The value of the jshintConfig attribute in a package.json file located in the current directory or any parent of the current directory.
  3. A .jshintrc file located in the current directory or any parent of the current directory.
  4. A .jshintrc file located in the user's home directory.
  5. The values specified within jshint.options in the user or workspace settings. By default jshint.options is empty.

.jshintrc files can be chained using the extends attribute as described here.

Exclude Options

In order to ignore specific files or folders from being linted exclude options can be specified in a number of locations mostly mimicing jshint's default behavior. The extenion looks for its exclude options the following way and stops at the first positive match:

  1. A file specified in the user or workspace settings like this: "jshint.excludePath" : "<file path>". The file path is interpreted relative to the workspace's root folder. The file contains glob patterns specifying files that should be excluded. The glob patterns are interpreted relative to the workspace's root folder.
  2. A .jshintignore file located in the current directory or any parent of the current directory. The glob patterns in this file are interpreted relative to the location of the .jshintignore file.
  3. The value of the jshint.exclude attribute in the user or workspace settings. The attribute has the following form: "jshint.exclude" : { "<glob pattern>" : true, "<glob pattern>" : true }. The glob patterns are interpreted relative to the workspace's root folder.

The glob patterns are interpreted using the npm minimatch module. Be aware that there are slight differences between minimatch and how .gitignore patterns are interpreted. Most noteably, **/name and name are not the same in minimatch whereas they are consider equal in .gitignore. Always use **/name if you want to match a name within a subtree.

No files are excluded by default.

What is JSHint?

JSHint is a community-driven tool that detects errors and potential problems in JavaScript code. Since JSHint is so flexible, you can easily adjust it in the environment you expect your code to execute. JSHint is open source and will always stay this way.

Our goal

The project aims to help JavaScript developers write complex programs without worrying about typos and language gotchas.

Any code base eventually becomes huge at some point, so simple mistakes — that would not show themselves when written — can become show stoppers and add extra hours of debugging. So, static code analysis tools come into play and help developers spot such problems. JSHint scans a program written in JavaScript and reports about commonly made mistakes and potential bugs. The potential problem could be a syntax error, a bug due to an implicit type conversion, a leaking variable, or something else entirely.

Only 15% of all programs linted on jshint.com pass the JSHint checks. In all other cases, JSHint finds some red flags that could've been bugs or potential problems.

Please note, that while static code analysis tools can spot many different kind of mistakes, it can't detect if your program is correct, fast or has memory leaks. You should always combine tools like JSHint with unit and functional tests as well as with code reviews.

 

jQuery Code Snippets

Over 130 jQuery Code Snippets for JavaScript code.

Just type the letters 'jq' to get a list of all available jQuery Code Snippets.

Image of Snippets

Snippets

TriggerDescription
funcAn anonymous function.
jqAfterInsert content, specified by the parameter, after each element in the set of matched elements.
jqAjaxPerform an asynchronous HTTP (Ajax) request.
jqAjaxAspNetWebServicePerform an asynchronous HTTP (Ajax) request to a ASP.NET web service.
jqAppendInsert content, specified by the parameter, to the end of each element in the set of matched elements.
jqAppendToInsert every element in the set of matched elements to the end of the target.
jqAttrGetGet the value of an attribute for the first element in the set of matched elements.
jqAttrRemoveRemove an attribute from each element in the set of matched elements.
jqAttrSetSet one or more attributes for the set of matched elements.
jqAttrSetFnSet one or more attributes for the set of matched elements.
jqAttrSetObjSet one or more attributes for the set of matched elements.
jqBeforeInsert content, specified by the parameter, before each element in the set of matched elements.
jqBindAttach a handler to an event for the elements.
jqBindWithDataAttach a handler to an event for the elements.
jqBlurBind an event handler to the "blur" JavaScript event, or trigger that event on an element.
jqChangeBind an event handler to the "change" JavaScript event, or trigger that event on an element.
jqClassAddAdds the specified class(es) to each of the set of matched elements.
jqClassRemoveRemove a single class, multiple classes, or all classes from each element in the set of matched elements.
jqClassToggleAdd or remove one or more classes from each element in the set of matched elements, depending on either the class's presence.
jqClassToggleSwitchAdd or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
jqClickBind an event handler to the "click" JavaScript event, or trigger that event on an element.
jqCloneCreate a deep copy of the set of matched elements.
jqCloneWithEventsCreate a deep copy of the set of matched elements.
jqCssGetGet the computed style properties for the first element in the set of matched elements.
jqCssSetSet one or more CSS properties for the set of matched elements.
jqCssSetObjSet one or more CSS properties for the set of matched elements.
jqDataGetReturn the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
jqDataRemoveRemove a previously-stored piece of data.
jqDataSetStore arbitrary data associated with the matched elements.
jqDataSetObjStore arbitrary data associated with the matched elements.
jqDieRemove event handlers previously attached using .live() from the elements.
jqDieAllRemove event handlers previously attached using .live() from the elements.
jqDieFnRemove event handlers previously attached using .live() from the elements.
jqDocReadyFunction to execute when the DOM is fully loaded.
jqDocReadyShortFunction to execute when the DOM is fully loaded.
jqEachA generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.
jqEachElementIterate over a jQuery object, executing a function for each matched element.
jqEmptyRemove all child nodes of the set of matched elements from the DOM.
jqFadeInDisplay the matched elements by fading them to opaque.
jqFadeInFullDisplay the matched elements by fading them to opaque.
jqFadeOutHide the matched elements by fading them to transparent.
jqFadeOutFullHide the matched elements by fading them to transparent.
jqFadeToAdjust the opacity of the matched elements.
jqFadeToFullAdjust the opacity of the matched elements.
jqFindGet the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.
jqFocusBind an event handler to the "focus" JavaScript event, or trigger that event on an element.
jqGetLoad data from the server using a HTTP GET request.
jqGetJsonLoad JSON-encoded data from the server using a GET HTTP request.
jqGetScriptLoad a JavaScript file from the server using a GET HTTP request, then execute it.
jqHasClassDetermine whether any of the matched elements are assigned the given class.
jqHeightGetGet the current computed height for the first element in the set of matched elements.
jqHeightSetSet the CSS height of every matched element.
jqHideHide the matched elements.
jqHideFullHide the matched elements.
jqHoverBind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.
jqHtmlGetGet the HTML contents of the first element in the set of matched elements.
jqHtmlSetSet the HTML contents of each element in the set of matched elements.
jqInnerHeightGet the current computed height for the first element in the set of matched elements, including padding but not border.
jqInnerWidthGet the current computed inner width for the first element in the set of matched elements, including padding but not border.
jqInsertAfterInsert every element in the set of matched elements after the target.
jqInsertBeforeInsert every element in the set of matched elements before the target.
jqKeyDownBind an event handler to the "keydown" JavaScript event, or trigger that event on an element.
jqKeyPressBind an event handler to the "keypress" JavaScript event, or trigger that event on an element.
jqKeyUpBind an event handler to the "keyup" JavaScript event, or trigger that event on an element.
jqLoadGetLoad data from the server and place the returned HTML into the matched element.
jqLoadPostLoad data from the server and place the returned HTML into the matched element.
jqMapTranslate all items in an array or object to new array of items.
jqMouseDownBind an event handler to the "mousedown" JavaScript event, or trigger that event on an element.
jqMouseEnterBind an event handler to be fired when the mouse enters an element, or trigger that handler on an element.
jqMouseLeaveBind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element.
jqMouseMoveBind an event handler to the "mousemove" JavaScript event, or trigger that event on an element.
jqMouseOutBind an event handler to the "mouseout" JavaScript event, or trigger that event on an element.
jqMouseOverBind an event handler to the "mouseover" JavaScript event, or trigger that event on an element.
jqMouseUpBind an event handler to the "mouseup" JavaScript event, or trigger that event on an element.
jqNamespaceA namespace template. ref: http://enterprisejquery.com/2010/10/how-good-c-habits-can-encourage-bad-javascript-habits-part-1/
jqOffsetGetGet the current coordinates of the first element, or set the coordinates of every element, in the set of matched elements, relative to the document.
jqOffsetParentGet the closest ancestor element that is positioned.
jqOnAttach an event handler function for one or more events to the selected elements.
jqOneAttach a handler to an event for the elements. The handler is executed at most once per element per event type.
jqOneWithDataAttach a handler to an event for the elements. The handler is executed at most once per element per event type.
jqOuterHeightGet the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns a number (without "px") representation of the value or null if called on an empty set of elements.
jqOuterWidthGet the current computed width for the first element in the set of matched elements, including padding and border.
jqPluginPlugin template.
jqPositionGet the current coordinates of the first element in the set of matched elements, relative to the offset parent.
jqPostLoad data from the server using a HTTP POST request.
jqPrependInsert content, specified by the parameter, to the beginning of each element in the set of matched elements.
jqPrependToInsert every element in the set of matched elements to the beginning of the target.
jqRemoveRemove the set of matched elements from the DOM.
jqRemoveExpRemove the set of matched elements from the DOM.
jqReplaceAllReplace each target element with the set of matched elements.
jqReplaceWithReplace each element in the set of matched elements with the provided new content and return the set of elements that was removed.
jqResizeBind an event handler to the "resize" JavaScript event, or trigger that event on an element.
jqScrollBind an event handler to the "scroll" JavaScript event, or trigger that event on an element.
jqScrollLeftGetGet the current horizontal position of the scroll bar for the first element in the set of matched elements.
jqScrollLeftSetSet the current horizontal position of the scroll bar for each of the set of matched elements.
jqScrollTopGetGet the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.
jqScrollTopSetSet the current vertical position of the scroll bar for each of the set of matched elements.
jqSelectBind an event handler to the "select" JavaScript event, or trigger that event on an element.
jqSelectTriggerBind an event handler to the "select" JavaScript event, or trigger that event on an element.
jqShowDisplay the matched elements.
jqShowFullDisplay the matched elements.
jqSlideDownDisplay the matched elements with a sliding motion.
jqSlideDownFullDisplay the matched elements with a sliding motion.
jqSlideToggleDisplay or hide the matched elements with a sliding motion.
jqSlideToggleFullDisplay or hide the matched elements with a sliding motion.
jqSlideUpDisplay the matched elements with a sliding motion.
jqSlideUpFullDisplay the matched elements with a sliding motion.
jqSubmitBind an event handler to the "submit" JavaScript event, or trigger that event on an element.
jqSubmitTriggerBind an event handler to the "submit" JavaScript event, or trigger that event on an element.
jqTextGetGet the combined text contents of each element in the set of matched elements, including their descendants.
jqTextSetSet the content of each element in the set of matched elements to the specified text.
jqToggleDisplay or hide the matched elements.
jqToggleFullDisplay or hide the matched elements.
jqToggleSwitchDisplay or hide the matched elements.
jqTriggerExecute all handlers and behaviors attached to the matched elements for the given event type.
jqTriggerHandlerExecute all handlers attached to an element for an event.
jqTriggerHandlerWithDataExecute all handlers attached to an element for an event.
jqTriggerWithDataExecute all handlers and behaviors attached to the matched elements for the given event type.
jqUnbindRemove a previously-attached event handler from the elements.
jqUnbindAllRemove a previously-attached event handler from the elements.
jqUnloadBind an event handler to the "unload" JavaScript event.
jqValGetGet the current value of the first element in the set of matched elements.
jqValSetSet the value of each element in the set of matched elements.
jqWidthGetGet the current computed width for the first element in the set of matched elements.
jqWidthSetSet the CSS width of each element in the set of matched elements.
jqWrapWrap an HTML structure around each element in the set of matched elements.
jqWrapAllWrap an HTML structure around all elements in the set of matched elements.
jqWrapInnerWrap an HTML structure around the content of each element in the set of matched elements.

Source

Github

All snippets have been taken from the Visual Studio 2015 jQuery Code Snippets Extension. Credit given where due.

Categories

Snippets

Tags

javascript

Resources

More Info

Version

0.0.1

Last updated

‎2015‎年‎12‎月‎7‎日‎ ‎9‎:‎02‎:‎31

Publisher

Don Jayamanne

Unique Identifier

donjayamanne.jquerysnippets

Report

Report Abuse

 

Vetur

Vue tooling for VS Code, powered by vue-language-server.

Doc: https://vuejs.github.io/vetur

Try it out with Veturpack!

? VueConf 2017 Slide & Video ?

Features

  • Syntax-highlighting
  • Snippet
  • Emmet
  • Linting / Error Checking
  • Formatting
  • Auto Completion
  • Debugging

Quick Start

  • Install Vetur.
  • Try it with Veturpack, a pre-configured Vue boilerplate based on Vuepack.
  • Refer to setup page for setting up.
  • Refer to each feature's own page for setting up specific features.

 

npm Intellisense

Visual Studio Code plugin that autocompletes npm modules in import statements.

auto complete

Installation

In the command palette (cmd-shift-p) select Install Extension and choose npm Intellisense.

install

Contributing

Something missing? Found a bug? - Create a pull request or an issue. Github

Features

Import command

import command

{
	"npm-intellisense.importES6": true,
	"npm-intellisense.importQuotes": "'",
	"npm-intellisense.importLinebreak": ";\r\n",
	"npm-intellisense.importDeclarationType": "const",
}

Import command (ES5)

import command

{
	"npm-intellisense.importES6": false,
	"npm-intellisense.importQuotes": "'",
	"npm-intellisense.importLinebreak": ";\r\n",
	"npm-intellisense.importDeclarationType": "const",
}

Scan devDependencies

Npm intellisense scans only dependencies by default. Set scanDevDependencies to true to enable it for devDependencies too.

{
	"npm-intellisense.scanDevDependencies": true,
}

Show build in (local) libs

Shows build in node modules like 'path' of 'fs'

{
	"npm-intellisense.showBuildInLibs": true,
}

Lookup package.json recursive

Look for package.json inside nearest directory instead of workspace root. It's enabled by default.

{
	"npm-intellisense.recursivePackageJsonLookup": true,
}

Experimental: Package Subfolder Intellisense

Open subfolders of a module. This feature is work in progress and experimental.

{
	"npm-intellisense.packageSubfoldersIntellisense": false,
}

 

转载于:https://my.oschina.net/ZhenyuanLiu/blog/1817492

Logo

前往低代码交流专区

更多推荐