@taiga-ui/prettier-config 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +31 -0
- package/index.js +87 -0
- package/options/svg.js +7 -0
- package/package.json +25 -0
- package/plugins/prettier-plugin-sort-package.js +40 -0
- package/project.json +15 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See
|
|
4
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 0.1.1 (2023-08-14)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add linters ([b35e525](https://github.com/taiga-family/taiga-ui/commit/b35e5252a2bac063696f0fd1b5accc1ac0d34a66))
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @taiga-ui/prettier-config
|
|
2
|
+
|
|
3
|
+
Common Prettier configuration for taiga-ui projects. Compatible with taiga-ui eslint configs.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
1. Install from npm
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i --save-dev @taiga-ui/prettier-config
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
1. Create `.prettierrc.js` at project root
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
module.exports = require('@taiga-ui/prettier-config');
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
More information about available at
|
|
20
|
+
[prettier documentation](https://prettier.io/docs/en/configuration.html#sharing-configurations)
|
|
21
|
+
|
|
22
|
+
### Available presets
|
|
23
|
+
|
|
24
|
+
- **angular**
|
|
25
|
+
|
|
26
|
+
```json5
|
|
27
|
+
{
|
|
28
|
+
// ...
|
|
29
|
+
prettier: '@taiga-ui/prettier-config/angular',
|
|
30
|
+
}
|
|
31
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
$schema: 'https://json.schemastore.org/prettierrc',
|
|
3
|
+
htmlWhitespaceSensitivity: 'ignore',
|
|
4
|
+
printWidth: 120,
|
|
5
|
+
tabWidth: 4,
|
|
6
|
+
proseWrap: 'always',
|
|
7
|
+
useTabs: false,
|
|
8
|
+
semi: true,
|
|
9
|
+
singleQuote: true,
|
|
10
|
+
trailingComma: 'all',
|
|
11
|
+
endOfLine: 'lf',
|
|
12
|
+
bracketSpacing: false,
|
|
13
|
+
arrowParens: 'avoid',
|
|
14
|
+
singleAttributePerLine: true,
|
|
15
|
+
plugins: [require.resolve('prettier-plugin-organize-attributes')],
|
|
16
|
+
attributeGroups: [
|
|
17
|
+
'$ANGULAR_STRUCTURAL_DIRECTIVE',
|
|
18
|
+
'$ANGULAR_ELEMENT_REF',
|
|
19
|
+
'$ID',
|
|
20
|
+
'$DEFAULT',
|
|
21
|
+
'$CLASS',
|
|
22
|
+
'$ANGULAR_ANIMATION',
|
|
23
|
+
'$ANGULAR_ANIMATION_INPUT',
|
|
24
|
+
'$ANGULAR_INPUT',
|
|
25
|
+
'$ANGULAR_TWO_WAY_BINDING',
|
|
26
|
+
'$ANGULAR_OUTPUT',
|
|
27
|
+
],
|
|
28
|
+
overrides: [
|
|
29
|
+
{
|
|
30
|
+
files: ['*.json', '.prettierrc', '.stylelintrc'],
|
|
31
|
+
options: {parser: 'json'},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
files: ['package.json', 'ng-package.json'],
|
|
35
|
+
options: {
|
|
36
|
+
parser: 'json-stringify',
|
|
37
|
+
plugins: [
|
|
38
|
+
require.resolve(
|
|
39
|
+
require('path').resolve(
|
|
40
|
+
__dirname,
|
|
41
|
+
'plugins',
|
|
42
|
+
'prettier-plugin-sort-package.js',
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
files: ['*.less'],
|
|
50
|
+
options: {parser: 'less'},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
files: ['*.scss'],
|
|
54
|
+
options: {parser: 'scss'},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
files: ['*.xml'],
|
|
58
|
+
options: {
|
|
59
|
+
parser: 'xml',
|
|
60
|
+
plugins: [require.resolve('@prettier/plugin-xml')],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
files: ['*.yml', '*.yaml'],
|
|
65
|
+
options: {parser: 'yaml', tabWidth: 2},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
files: ['*.md'],
|
|
69
|
+
options: {parser: 'markdown', tabWidth: 2},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
files: ['*.js', '*.ts'],
|
|
73
|
+
options: {printWidth: 90, parser: 'typescript'},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
files: ['*.html'],
|
|
77
|
+
options: {
|
|
78
|
+
parser: 'angular',
|
|
79
|
+
printWidth: 120,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
files: '*.svg',
|
|
84
|
+
options: require(require('path').resolve(__dirname, 'options', 'svg.js')),
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
package/options/svg.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taiga-ui/prettier-config",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Taiga-ui prettier config",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"prettier",
|
|
7
|
+
"prettier-config"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/taiga-family/taiga-ui.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"main": "index.js",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@prettier/plugin-xml": "2.2.0",
|
|
17
|
+
"@types/prettier": "2.7.3",
|
|
18
|
+
"prettier-package-json": "2.8.0",
|
|
19
|
+
"prettier-plugin-organize-attributes": "0.0.5",
|
|
20
|
+
"sort-package-json": "1.57.0"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const sortPackageJson = require('sort-package-json');
|
|
2
|
+
const {parsers} = require('prettier/parser-babel');
|
|
3
|
+
|
|
4
|
+
const parser = parsers['json-stringify'];
|
|
5
|
+
|
|
6
|
+
exports.parsers = {
|
|
7
|
+
'json-stringify': {
|
|
8
|
+
...parser,
|
|
9
|
+
preprocess(text, options) {
|
|
10
|
+
const processed = parser.preprocess ? parser.preprocess(text, options) : text;
|
|
11
|
+
|
|
12
|
+
const isPackageJson =
|
|
13
|
+
options.filepath &&
|
|
14
|
+
/package\.json$|ng-package\.json$/.test(options.filepath);
|
|
15
|
+
|
|
16
|
+
if (isPackageJson) {
|
|
17
|
+
const json = JSON.parse(processed);
|
|
18
|
+
const unsortedScripts = deepClone((json && json.scripts) || {});
|
|
19
|
+
const sorted = sortPackageJson(json);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @note: add the scripts field if it's provided
|
|
23
|
+
* the scripts must be unsorted
|
|
24
|
+
*/
|
|
25
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
26
|
+
if (json && json.hasOwnProperty('scripts')) {
|
|
27
|
+
sorted.scripts = unsortedScripts;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return JSON.stringify(sorted);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return processed;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function deepClone(value) {
|
|
39
|
+
return JSON.parse(JSON.stringify(value));
|
|
40
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "prettier-config",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "projects/prettier-config",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"prefix": "tui",
|
|
7
|
+
"targets": {
|
|
8
|
+
"publish": {
|
|
9
|
+
"executor": "nx:run-commands",
|
|
10
|
+
"options": {
|
|
11
|
+
"command": "npm publish ./projects/prettier-config --access=public --ignore-scripts || echo \"already published\""
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|