Format *.md files with prettier
The `npm run format` command now matches the husky `lint-staged`-commands. Also upgraded to prettier v3.
This commit is contained in:
committed by
Jay Linski
parent
f202c501a3
commit
9413ea99ce
@@ -1,2 +1,4 @@
|
|||||||
# Upgrade to Prettier 2.7
|
# Upgrade to Prettier 2.7
|
||||||
3d228334530860a6e3f99dc10777c84bf22292c1
|
3d228334530860a6e3f99dc10777c84bf22292c1
|
||||||
|
# Format markdown files with Prettier
|
||||||
|
dfe2eaaf20f0b679d94e5a799757c4394d80f1cc
|
||||||
@@ -7,5 +7,3 @@ Before filing issues, please check the following points first:
|
|||||||
|
|
||||||
This will probably help you to get a solution faster.
|
This will probably help you to get a solution faster.
|
||||||
For bugs, it would be great to have a PR with a failing test-case.
|
For bugs, it would be great to have a PR with a failing test-case.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ We recommend always using the latest versions of Handlebars and its official com
|
|||||||
## Supported Versions
|
## Supported Versions
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
|---------| ------------------ |
|
| ------- | ------------------ |
|
||||||
| 5.0.x | :white_check_mark: |
|
| 5.0.x | :white_check_mark: |
|
||||||
| 4.7.x | :white_check_mark: |
|
| 4.7.x | :white_check_mark: |
|
||||||
| < 4.7 | :x: |
|
| < 4.7 | :x: |
|
||||||
|
|||||||
@@ -3,7 +3,5 @@
|
|||||||
"repo": "components/handlebars.js",
|
"repo": "components/handlebars.js",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "handlebars.js",
|
"main": "handlebars.js",
|
||||||
"scripts": [
|
"scripts": ["handlebars.js"]
|
||||||
"handlebars.js"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-20
@@ -34,8 +34,8 @@ let ast = Handlebars.parseWithoutProcessing(myTemplate);
|
|||||||
|
|
||||||
`Handlebars.parse` will parse the template with `parseWithoutProcessing` (see above) then it will update the AST to strip extraneous whitespace. The whitespace stripping functionality handles two distinct situations:
|
`Handlebars.parse` will parse the template with `parseWithoutProcessing` (see above) then it will update the AST to strip extraneous whitespace. The whitespace stripping functionality handles two distinct situations:
|
||||||
|
|
||||||
* Removes whitespace around dynamic statements that are on a line by themselves (aka "stand alone")
|
- Removes whitespace around dynamic statements that are on a line by themselves (aka "stand alone")
|
||||||
* Applies "whitespace control" characters (i.e. `~`) by truncating the `ContentStatement` `value` property appropriately (e.g. `\n\n{{~foo}}` would have a `ContentStatement` with a `value` of `''`)
|
- Applies "whitespace control" characters (i.e. `~`) by truncating the `ContentStatement` `value` property appropriately (e.g. `\n\n{{~foo}}` would have a `ContentStatement` with a `value` of `''`)
|
||||||
|
|
||||||
`Handlebars.parse` is used internally by `Handlebars.precompile` and `Handlebars.compile`.
|
`Handlebars.parse` is used internally by `Handlebars.precompile` and `Handlebars.compile`.
|
||||||
|
|
||||||
@@ -132,7 +132,6 @@ interface PartialBlockStatement <: Statement {
|
|||||||
|
|
||||||
`name` will be a `SubExpression` when tied to a dynamic partial, i.e. `{{> (foo) }}`, otherwise this is a path or literal whose `original` value is used to lookup the desired partial.
|
`name` will be a `SubExpression` when tied to a dynamic partial, i.e. `{{> (foo) }}`, otherwise this is a path or literal whose `original` value is used to lookup the desired partial.
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
interface ContentStatement <: Statement {
|
interface ContentStatement <: Statement {
|
||||||
type: "ContentStatement";
|
type: "ContentStatement";
|
||||||
@@ -148,7 +147,6 @@ interface CommentStatement <: Statement {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
interface Decorator <: Statement {
|
interface Decorator <: Statement {
|
||||||
type: "Decorator";
|
type: "Decorator";
|
||||||
@@ -209,7 +207,6 @@ interface PathExpression <: Expression {
|
|||||||
- `parts` is an array of the names in the path. `foo.bar` would be `['foo', 'bar']`. Scope references, `.`, `..`, and `this` should be omitted from this array.
|
- `parts` is an array of the names in the path. `foo.bar` would be `['foo', 'bar']`. Scope references, `.`, `..`, and `this` should be omitted from this array.
|
||||||
- `original` is the path as entered by the user. Separator and scope references are left untouched.
|
- `original` is the path as entered by the user. Separator and scope references are left untouched.
|
||||||
|
|
||||||
|
|
||||||
##### Literals
|
##### Literals
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@@ -242,7 +239,6 @@ interface NullLiteral <: Literal {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@@ -330,7 +326,6 @@ This example changes all lookups of properties are performed by a helper (`looku
|
|||||||
|
|
||||||
There is also [a jsfiddle with this code](https://jsfiddle.net/9D88g/162/) if you want to play around with it.
|
There is also [a jsfiddle with this code](https://jsfiddle.net/9D88g/162/) if you want to play around with it.
|
||||||
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function MyCompiler() {
|
function MyCompiler() {
|
||||||
Handlebars.JavaScriptCompiler.apply(this, arguments);
|
Handlebars.JavaScriptCompiler.apply(this, arguments);
|
||||||
@@ -338,29 +333,35 @@ function MyCompiler() {
|
|||||||
MyCompiler.prototype = new Handlebars.JavaScriptCompiler();
|
MyCompiler.prototype = new Handlebars.JavaScriptCompiler();
|
||||||
|
|
||||||
// Use this compile to compile BlockStatment-Blocks
|
// Use this compile to compile BlockStatment-Blocks
|
||||||
MyCompiler.prototype.compiler = MyCompiler
|
MyCompiler.prototype.compiler = MyCompiler;
|
||||||
|
|
||||||
MyCompiler.prototype.nameLookup = function (parent, name, type) {
|
MyCompiler.prototype.nameLookup = function (parent, name, type) {
|
||||||
if (type === 'context') {
|
if (type === 'context') {
|
||||||
return this.source.functionCall('helpers.lookupLowerCase', '', [parent, JSON.stringify(name)])
|
return this.source.functionCall('helpers.lookupLowerCase', '', [
|
||||||
|
parent,
|
||||||
|
JSON.stringify(name),
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
return Handlebars.JavaScriptCompiler.prototype.nameLookup.call(this, parent, name, type);
|
return Handlebars.JavaScriptCompiler.prototype.nameLookup.call(
|
||||||
}
|
this,
|
||||||
|
parent,
|
||||||
|
name,
|
||||||
|
type
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var env = Handlebars.create();
|
var env = Handlebars.create();
|
||||||
env.registerHelper('lookupLowerCase', function (parent, name) {
|
env.registerHelper('lookupLowerCase', function (parent, name) {
|
||||||
return parent[name.toLowerCase()]
|
return parent[name.toLowerCase()];
|
||||||
})
|
});
|
||||||
|
|
||||||
env.JavaScriptCompiler = MyCompiler;
|
env.JavaScriptCompiler = MyCompiler;
|
||||||
|
|
||||||
var template = env.compile('{{#each Test}} ({{Value}}) {{/each}}');
|
var template = env.compile('{{#each Test}} ({{Value}}) {{/each}}');
|
||||||
console.log(template({
|
console.log(
|
||||||
test: [
|
template({
|
||||||
{value: 'a'},
|
test: [{ value: 'a' }, { value: 'b' }, { value: 'c' }],
|
||||||
{value: 'b'},
|
})
|
||||||
{value: 'c'}
|
);
|
||||||
]
|
|
||||||
}));
|
|
||||||
```
|
```
|
||||||
|
|||||||
Generated
+16
-16
@@ -30,7 +30,7 @@
|
|||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"dustjs-linkedin": "^2.0.2",
|
"dustjs-linkedin": "^2.0.2",
|
||||||
"eslint": "^8.25.0",
|
"eslint": "^8.25.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.9.0",
|
||||||
"eslint-plugin-compat": "4.0",
|
"eslint-plugin-compat": "4.0",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"grunt": "^1.0.4",
|
"grunt": "^1.0.4",
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"mock-stdin": "^0.3.0",
|
"mock-stdin": "^0.3.0",
|
||||||
"mustache": "^2.1.3",
|
"mustache": "^2.1.3",
|
||||||
"nyc": "^14.1.1",
|
"nyc": "^14.1.1",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^3.0.0",
|
||||||
"semver": "^5.0.1",
|
"semver": "^5.0.1",
|
||||||
"sinon": "^7.5.0",
|
"sinon": "^7.5.0",
|
||||||
"typescript": "^3.4.3",
|
"typescript": "^3.4.3",
|
||||||
@@ -4094,9 +4094,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-config-prettier": {
|
"node_modules/eslint-config-prettier": {
|
||||||
"version": "8.5.0",
|
"version": "8.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.9.0.tgz",
|
||||||
"integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
|
"integrity": "sha512-+sbni7NfVXnOpnRadUA8S28AUlsZt9GjgFvABIRL9Hkn8KqNzOp+7Lw4QWtrwn20KzU3wqu1QoOj2m+7rKRqkA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"eslint-config-prettier": "bin/cli.js"
|
"eslint-config-prettier": "bin/cli.js"
|
||||||
@@ -11285,15 +11285,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "2.7.1",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.0.tgz",
|
||||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
"integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"prettier": "bin-prettier.js"
|
"prettier": "bin/prettier.cjs"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.13.0"
|
"node": ">=14"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
@@ -18140,9 +18140,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eslint-config-prettier": {
|
"eslint-config-prettier": {
|
||||||
"version": "8.5.0",
|
"version": "8.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.9.0.tgz",
|
||||||
"integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
|
"integrity": "sha512-+sbni7NfVXnOpnRadUA8S28AUlsZt9GjgFvABIRL9Hkn8KqNzOp+7Lw4QWtrwn20KzU3wqu1QoOj2m+7rKRqkA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {}
|
"requires": {}
|
||||||
},
|
},
|
||||||
@@ -23659,9 +23659,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"version": "2.7.1",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.0.tgz",
|
||||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
"integrity": "sha512-zBf5eHpwHOGPC47h0zrPyNn+eAEIdEzfywMoYn2XPi0P44Zp0tSq64rq0xAREh4auw2cJZHo9QUob+NqCQky4g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"pretty-bytes": {
|
"pretty-bytes": {
|
||||||
|
|||||||
+4
-4
@@ -41,7 +41,7 @@
|
|||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"dustjs-linkedin": "^2.0.2",
|
"dustjs-linkedin": "^2.0.2",
|
||||||
"eslint": "^8.25.0",
|
"eslint": "^8.25.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.9.0",
|
||||||
"eslint-plugin-compat": "4.0",
|
"eslint-plugin-compat": "4.0",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
"grunt": "^1.0.4",
|
"grunt": "^1.0.4",
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
"mock-stdin": "^0.3.0",
|
"mock-stdin": "^0.3.0",
|
||||||
"mustache": "^2.1.3",
|
"mustache": "^2.1.3",
|
||||||
"nyc": "^14.1.1",
|
"nyc": "^14.1.1",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^3.0.0",
|
||||||
"semver": "^5.0.1",
|
"semver": "^5.0.1",
|
||||||
"sinon": "^7.5.0",
|
"sinon": "^7.5.0",
|
||||||
"typescript": "^3.4.3",
|
"typescript": "^3.4.3",
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
"build": "grunt build",
|
"build": "grunt build",
|
||||||
"release": "grunt release",
|
"release": "grunt release",
|
||||||
"publish:aws": "npm run test:tasks && grunt && grunt publish-to-aws",
|
"publish:aws": "npm run test:tasks && grunt && grunt publish-to-aws",
|
||||||
"format": "prettier --write '**/*.js' && eslint --fix .",
|
"format": "prettier --write '**/*.{js,css,json,md}' && eslint --fix .",
|
||||||
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:types",
|
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:types",
|
||||||
"lint:eslint": "eslint --max-warnings 0 .",
|
"lint:eslint": "eslint --max-warnings 0 .",
|
||||||
"lint:prettier": "prettier --check '**/*.js'",
|
"lint:prettier": "prettier --check '**/*.js'",
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,css,json}": [
|
"*.{js,css,json,md}": [
|
||||||
"prettier --write",
|
"prettier --write",
|
||||||
"git add"
|
"git add"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ module.exports = {
|
|||||||
tabWidth: 2,
|
tabWidth: 2,
|
||||||
semi: true,
|
semi: true,
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
|
trailingComma: 'es5',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user