@ben_12/eslint-plugin-dprint 0.7.1 → 0.8.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/README.md CHANGED
@@ -2,17 +2,15 @@
2
2
 
3
3
  [![GitHub](https://img.shields.io/github/license/ben12/eslint-plugin-dprint)](https://github.com/ben12/eslint-plugin-dprint/blob/master/LICENSE)
4
4
  [![npm version](https://img.shields.io/npm/v/@ben_12/eslint-plugin-dprint.svg)](https://www.npmjs.com/package/@ben_12/eslint-plugin-dprint)
5
- [![Downloads/month](https://img.shields.io/npm/dm/@ben_12/eslint-plugin-dprint.svg)](http://www.npmtrends.com/@ben_12/eslint-plugin-dprint)
5
+ [![Downloads/month](https://img.shields.io/npm/dm/@ben_12/eslint-plugin-dprint.svg)](http://www.npmtrends.com/@ben_12/eslint-plugin-dprint)\
6
6
  [![node-current](https://img.shields.io/node/v/%40ben_12%2Feslint-plugin-dprint)](https://nodejs.org)
7
7
  [![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/peer/eslint)](https://www.npmjs.com/package/eslint)
8
- [![npm peer dependency version (scoped)](https://img.shields.io/npm/dependency-version/%40ben_12%2Feslint-plugin-dprint/@dprint/typescript)](https://www.npmjs.com/package/@dprint/typescript)
9
- ![npm bundle size](https://img.shields.io/bundlephobia/min/%40ben_12%2Feslint-plugin-dprint)
8
+ ![npm bundle size](https://img.shields.io/bundlephobia/min/%40ben_12%2Feslint-plugin-dprint)\
10
9
  [![Build Status](https://github.com/ben12/eslint-plugin-dprint/workflows/CI/badge.svg)](https://github.com/ben12/eslint-plugin-dprint/actions)
11
10
  [![codecov](https://codecov.io/gh/ben12/eslint-plugin-dprint/branch/master/graph/badge.svg)](https://codecov.io/gh/ben12/eslint-plugin-dprint)
12
11
  [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ben12_eslint-plugin-dprint&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ben12_eslint-plugin-dprint)
13
12
  [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=ben12_eslint-plugin-dprint&metric=code_smells)](https://sonarcloud.io/dashboard?id=ben12_eslint-plugin-dprint)
14
- [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=ben12_eslint-plugin-dprint&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=ben12_eslint-plugin-dprint)
15
-
13
+ [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=ben12_eslint-plugin-dprint&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=ben12_eslint-plugin-dprint)
16
14
 
17
15
  > This is an updated fork of mysticatea/eslint-plugin-dprint. Some things are still being adjusted.
18
16
 
@@ -26,15 +24,25 @@ Use [npm] or a compatible tool.
26
24
  $ npm install -D eslint @ben_12/eslint-plugin-dprint
27
25
  ```
28
26
 
27
+ Then install [dprint] plugin for the language to format.
28
+
29
+ ```
30
+ $ npm install -D @dprint/dockerfile
31
+ $ npm install -D @dprint/json
32
+ $ npm install -D @dprint/markdown
33
+ $ npm install -D @dprint/toml
34
+ $ npm install -D @dprint/typescript
35
+ ```
36
+
29
37
  ## 📖 Usage
30
38
 
31
- Write your ESLint configuration. For example:
39
+ Write your ESLint configuration. For example with typescript code:
32
40
 
33
41
  ```js
34
42
  module.exports = {
35
- extends: ["eslint:recommended", "plugin:@ben_12/dprint/recommended"],
43
+ extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:@ben_12/dprint/typescript-recommended"],
36
44
  rules: {
37
- "@ben_12/dprint/dprint": [
45
+ "@ben_12/dprint/typescript": [
38
46
  "error",
39
47
  {
40
48
  // Use dprint JSON configuration file (default: "dprint.json")
@@ -55,16 +63,24 @@ Then run ESLint with `--fix`!
55
63
 
56
64
  ### Available Rules
57
65
 
58
- | Rule | Description |
59
- | :------------------------ | :------------------------- |
60
- | [@ben_12/dprint/dprint] | Format code with [dprint]. |
66
+ | Rule | Description |
67
+ | :-------------------------- | :------------------------------------------------ |
68
+ | [@ben_12/dprint/dockerfile] | Format dockerfile code with [@dprint/dockerfile]. |
69
+ | [@ben_12/dprint/json] | Format json code with [@dprint/json]. |
70
+ | [@ben_12/dprint/markdown] | Format markdown code with [@dprint/markdown]. |
71
+ | [@ben_12/dprint/toml] | Format toml code with [@dprint/toml]. |
72
+ | [@ben_12/dprint/typescript] | Format typescript code with [@dprint/typescript]. |
61
73
 
62
74
  ### Available Configs
63
75
 
64
- | Config | Description |
65
- | :----------------------------------------------- | :-------------------------------------------------------------------------------------------- |
66
- | [plugin:@ben_12/dprint/disable-conflict-rules] | Disable rules where are conflicted with the [@ben_12/dprint/dprint] rule. |
67
- | [plugin:@ben_12/dprint/recommended] | Enable the [@ben_12/dprint/dprint] rule along with the [plugin:@ben_12/dprint/disable-conflict-rules] preset. |
76
+ | Config | Description |
77
+ | :-------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
78
+ | [plugin:@ben_12/dprint/disable-typescript-conflict-rules] | Disable rules where are conflicted with the [@ben_12/dprint/dprint] rule. |
79
+ | [plugin:@ben_12/dprint/dockerfile-recommended] | Enable the [@ben_12/dprint/dockerfile] rule. |
80
+ | [plugin:@ben_12/dprint/json-recommended] | Enable the [@ben_12/dprint/json] rule. |
81
+ | [plugin:@ben_12/dprint/markdown-recommended] | Enable the [@ben_12/dprint/markdown] rule. |
82
+ | [plugin:@ben_12/dprint/toml-recommended] | Enable the [@ben_12/dprint/toml] rule. |
83
+ | [plugin:@ben_12/dprint/typescript-recommended] | Enable the [@ben_12/dprint/typescript] rule along with the [plugin:@ben_12/dprint/disable-typescript-conflict-rules] preset. |
68
84
 
69
85
  - Put the [plugin:@ben_12/dprint/recommended] or [plugin:@ben_12/dprint/disable-conflict-rules] config into the last of your `extends` list in order to ensure disabling conflict rules where came from other base configurations.
70
86
 
@@ -85,7 +101,20 @@ Please use GitHub's Issues/PRs.
85
101
  - `npm version <patch|minor|major>` ... Bump a new version.
86
102
 
87
103
  [dprint]: https://github.com/dprint/dprint
104
+ [@dprint/dockerfile]: https://github.com/dprint/dprint-plugin-dockerfile
105
+ [@dprint/json]: https://github.com/dprint/dprint-plugin-json
106
+ [@dprint/markdown]: https://github.com/dprint/dprint-plugin-markdown
107
+ [@dprint/toml]: https://github.com/dprint/dprint-plugin-toml
108
+ [@dprint/typescript]: https://github.com/dprint/dprint-plugin-typescript
88
109
  [npm]: https://www.npmjs.com/
89
- [@ben_12/dprint/dprint]: docs/rules/dprint.md
90
- [plugin:@ben_12/dprint/disable-conflict-rules]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/disable-conflict-rules.ts
91
- [plugin:@ben_12/dprint/recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts
110
+ [@ben_12/dprint/dockerfile]: docs/rules/dprint-dockerfile.md
111
+ [@ben_12/dprint/json]: docs/rules/dprint-json.md
112
+ [@ben_12/dprint/markdown]: docs/rules/dprint-markdown.md
113
+ [@ben_12/dprint/toml]: docs/rules/dprint-toml.md
114
+ [@ben_12/dprint/typescript]: docs/rules/dprint-typescript.md
115
+ [plugin:@ben_12/dprint/disable-typescript-conflict-rules]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/disable-typescript-conflict-rules.ts
116
+ [plugin:@ben_12/dprint/dockerfile-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L3
117
+ [plugin:@ben_12/dprint/json-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L10
118
+ [plugin:@ben_12/dprint/markdown-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L17
119
+ [plugin:@ben_12/dprint/toml-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L24
120
+ [plugin:@ben_12/dprint/typescript-recommended]: https://github.com/ben12/eslint-plugin-dprint/blob/master/lib/configs/recommended.ts#L31
@@ -1,4 +1,4 @@
1
- export declare const disableConflictRules: {
1
+ export declare const disableTypescriptConflictRules: {
2
2
  plugins: string[];
3
3
  rules: {
4
4
  "array-bracket-newline": string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.disableConflictRules = void 0;
4
- exports.disableConflictRules = {
3
+ exports.disableTypescriptConflictRules = void 0;
4
+ exports.disableTypescriptConflictRules = {
5
5
  plugins: ["@ben_12/dprint"],
6
6
  rules: {
7
7
  "array-bracket-newline": "off",
@@ -1 +1 @@
1
- {"version":3,"file":"disable-conflict-rules.js","sourceRoot":"","sources":["../../../lib/configs/disable-conflict-rules.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG;IAChC,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,KAAK,EAAE;QACH,uBAAuB,EAAE,KAAK;QAC9B,uBAAuB,EAAE,KAAK;QAC9B,uBAAuB,EAAE,KAAK;QAC9B,kBAAkB,EAAE,KAAK;QACzB,cAAc,EAAE,KAAK;QACrB,eAAe,EAAE,KAAK;QACtB,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,KAAK;QACrB,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,KAAK;QACpB,2BAA2B,EAAE,KAAK;QAClC,KAAK,EAAE,KAAK;QACZ,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,KAAK;QACjB,mBAAmB,EAAE,KAAK;QAC1B,gCAAgC,EAAE,KAAK;QACvC,wBAAwB,EAAE,KAAK;QAC/B,gBAAgB,EAAE,KAAK;QACvB,wBAAwB,EAAE,KAAK;QAC/B,0BAA0B,EAAE,KAAK;QACjC,MAAM,EAAE,KAAK;QACb,eAAe,EAAE,KAAK;QACtB,YAAY,EAAE,KAAK;QACnB,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,KAAK;QACxB,iBAAiB,EAAE,KAAK;QACxB,SAAS,EAAE,KAAK;QAChB,mB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pB,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;QACnB,oBAAoB,EAAE,KAAK;QAE3B,gCAAgC,EAAE,KAAK;QACvC,kCAAkC,EAAE,KAAK;QACzC,sCAAsC,EAAE,KAAK;QAC7C,2BAA2B,EAAE,KAAK;QAClC,oCAAoC,EAAE,KAAK;QAC3C,2CAA2C,EAAE,KAAK;QAClD,oCAAoC,EAAE,KAAK;QAC3C,kCAAkC,EAAE,KAAK;QACzC,2BAA2B,EAAE,KAAK;QAClC,yBAAyB,EAAE,KAAK;QAChC,gDAAgD,EAAE,KAAK;QACvD,4CAA4C,EAAE,KAAK;QAEnD,iCAAiC,EAAE,KAAK;QACxC,oCAAoC,EAAE,KAAK;QAC3C,gCAAgC,EAAE,KAAK;QACvC,yBAAyB,EAAE,KAAK;QAChC,yBAAyB,EAAE,KAAK;QAChC,0BAA0B,EAAE,KAAK;QACjC,+BAA+B,EAAE,KAAK;QACtC,kBAAkB,EAAE,KAAK;QACzB,wBAAwB,EAAE,KAAK;QAC/B,8BAA8B,EAAE,KAAK;QACrC,mCAAmC,EAAE,KAAK;QAC1C,iCAAiC,EAAE,KAAK;QACxC,gCAAgC,EAAE,KAAK;QACvC,uBAAuB,EAAE,KAAK;QAC9B,2BAA2B,EAAE,KAAK;KACrC;CACJ,CAAA"}
1
+ {"version":3,"file":"disable-conflict-rules.js","sourceRoot":"","sources":["../../../lib/configs/disable-conflict-rules.ts"],"names":[],"mappings":";;;AAAa,QAAA,8BAA8B,GAAG;IAC1C,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,KAAK,EAAE;QACH,uBAAuB,EAAE,KAAK;QAC9B,uBAAuB,EAAE,KAAK;QAC9B,uBAAuB,EAAE,KAAK;QAC9B,kBAAkB,EAAE,KAAK;QACzB,cAAc,EAAE,KAAK;QACrB,eAAe,EAAE,KAAK;QACtB,eAAe,EAAE,KAAK;QACtB,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,KAAK;QACrB,eAA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AAuB,EAAE,KAAK;QAC9B,2BAA2B,EAAE,KAAK;KACrC;CACJ,CAAA"}
@@ -1,7 +1,31 @@
1
- export declare const recommended: {
1
+ export declare const dockerfileRecommended: {
2
2
  plugins: string[];
3
3
  rules: {
4
- "@ben_12/dprint/dprint": string;
4
+ "@ben_12/dprint/dockerfile": string;
5
+ };
6
+ };
7
+ export declare const jsonRecommended: {
8
+ plugins: string[];
9
+ rules: {
10
+ "@ben_12/dprint/json": string;
11
+ };
12
+ };
13
+ export declare const markdownRecommended: {
14
+ plugins: string[];
15
+ rules: {
16
+ "@ben_12/dprint/markdown": string;
17
+ };
18
+ };
19
+ export declare const tomlRecommended: {
20
+ plugins: string[];
21
+ rules: {
22
+ "@ben_12/dprint/toml": string;
23
+ };
24
+ };
25
+ export declare const typescriptRecommended: {
26
+ plugins: string[];
27
+ rules: {
28
+ "@ben_12/dprint/typescript": string;
5
29
  "array-bracket-newline": string;
6
30
  "array-bracket-spacing": string;
7
31
  "array-element-newline": string;
@@ -1,9 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recommended = void 0;
3
+ exports.typescriptRecommended = exports.tomlRecommended = exports.markdownRecommended = exports.jsonRecommended = exports.dockerfileRecommended = void 0;
4
4
  const disable_conflict_rules_1 = require("./disable-conflict-rules");
5
- exports.recommended = {
5
+ exports.dockerfileRecommended = {
6
6
  plugins: ["@ben_12/dprint"],
7
- rules: Object.assign(Object.assign({}, disable_conflict_rules_1.disableConflictRules.rules), { "@ben_12/dprint/dprint": "warn" }),
7
+ rules: {
8
+ "@ben_12/dprint/dockerfile": "warn",
9
+ },
10
+ };
11
+ exports.jsonRecommended = {
12
+ plugins: ["@ben_12/dprint"],
13
+ rules: {
14
+ "@ben_12/dprint/json": "warn",
15
+ },
16
+ };
17
+ exports.markdownRecommended = {
18
+ plugins: ["@ben_12/dprint"],
19
+ rules: {
20
+ "@ben_12/dprint/markdown": "warn",
21
+ },
22
+ };
23
+ exports.tomlRecommended = {
24
+ plugins: ["@ben_12/dprint"],
25
+ rules: {
26
+ "@ben_12/dprint/toml": "warn",
27
+ },
28
+ };
29
+ exports.typescriptRecommended = {
30
+ plugins: ["@ben_12/dprint"],
31
+ rules: Object.assign(Object.assign({}, disable_conflict_rules_1.disableTypescriptConflictRules.rules), { "@ben_12/dprint/typescript": "warn" }),
8
32
  };
9
33
  //# sourceMappingURL=recommended.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../../lib/configs/recommended.ts"],"names":[],"mappings":";;;AAAA,qEAA+D;AAElD,QAAA,WAAW,GAAG;IACvB,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,KAAK,kCACE,6CAAoB,CAAC,KAAK,KAC7B,uBAAuB,EAAE,MAAM,GAClC;CACJ,CAAA"}
1
+ {"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../../lib/configs/recommended.ts"],"names":[],"mappings":";;;AAAA,qEAAyE;AAE5D,QAAA,qBAAqB,GAAG;IACjC,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,KAAK,EAAE;QACH,2BAA2B,EAAE,MAAM;KACtC;CACJ,CAAA;AAEY,QAAA,eAAe,GAAG;IAC3B,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,KAAK,EAAE;QACH,qBAAqB,EAAE,MAAM;KAChC;CACJ,CAAA;AAEY,QAAA,mBAAmB,GAAG;IAC/B,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,KAAK,EAAE;QACH,yBAAyB,EAAE,MAAM;KACpC;CACJ,CAAA;AAEY,QAAA,eAAe,GAAG;IAC3B,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,KAAK,EAAE;QACH,qBAAqB,EAAE,MAAM;KAChC;CACJ,CAAA;AAEY,QAAA,qBAAqB,GAAG;IACjC,OAAO,EAAE,CAAC,gBAAgB,CAAC;IAC3B,KAAK,kCACE,uDAA8B,CAAC,KAAK,KACvC,2BAA2B,EAAE,MAAM,GACtC;CACJ,CAAA"}
@@ -0,0 +1,52 @@
1
+ {
2
+ "type": "object",
3
+ "definitions": {
4
+ "newLineKind": {
5
+ "description": "The kind of newline to use.",
6
+ "type": "string",
7
+ "oneOf": [
8
+ {
9
+ "description": "For each file, uses the newline kind found at the end of the last line.",
10
+ "type": "string",
11
+ "enum": [
12
+ "auto"
13
+ ]
14
+ },
15
+ {
16
+ "description": "Uses carriage return, line feed.",
17
+ "type": "string",
18
+ "enum": [
19
+ "crlf"
20
+ ]
21
+ },
22
+ {
23
+ "description": "Uses line feed.",
24
+ "type": "string",
25
+ "enum": [
26
+ "lf"
27
+ ]
28
+ },
29
+ {
30
+ "description": "Uses the system standard (ex. crlf on Windows).",
31
+ "type": "string",
32
+ "enum": [
33
+ "system"
34
+ ]
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ "properties": {
40
+ "locked": {
41
+ "description": "Whether the configuration is not allowed to be overriden or extended.",
42
+ "type": "boolean"
43
+ },
44
+ "lineWidth": {
45
+ "description": "The width of a line the printer will try to stay under. Note that the printer may exceed this width in certain cases.",
46
+ "type": "number"
47
+ },
48
+ "newLineKind": {
49
+ "$ref": "#/definitions/newLineKind"
50
+ }
51
+ }
52
+ }
@@ -5,4 +5,4 @@
5
5
  * @param fileText The content of the file.
6
6
  * @returns The formatted text or undefined. It's undefined if the formatter doesn't change the text.
7
7
  */
8
- export declare function format(configFile: string, config: Record<string, any>, filePath: string, fileText: string): string | undefined;
8
+ export declare function format(configFile: string, config: Record<string, unknown>, filePath: string, fileText: string): string | undefined;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-var-requires */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.format = void 0;
31
+ const formatter_1 = require("@dprint/formatter");
32
+ const fs = __importStar(require("fs"));
33
+ const JSONC = __importStar(require("jsonc-parser"));
34
+ const path_1 = __importDefault(require("path"));
35
+ const plugins = [
36
+ "@dprint/typescript",
37
+ "@dprint/json",
38
+ "@dprint/markdown",
39
+ "@dprint/toml",
40
+ "@dprint/dockerfile",
41
+ ];
42
+ const formatters = [];
43
+ for (const module of plugins) {
44
+ try {
45
+ const plugin = require(module);
46
+ let buffer = undefined;
47
+ if (plugin.getPath) {
48
+ buffer = fs.readFileSync(plugin.getPath());
49
+ }
50
+ else if (plugin.getBuffer) {
51
+ buffer = plugin.getBuffer();
52
+ }
53
+ if (buffer) {
54
+ const formatter = (0, formatter_1.createFromBuffer)(buffer);
55
+ formatters.push(formatter);
56
+ }
57
+ }
58
+ catch (e) {
59
+ // plugin unavailable
60
+ }
61
+ }
62
+ function getFormatter(filePath) {
63
+ for (const formatter of formatters) {
64
+ const pluginInfo = formatter.getPluginInfo();
65
+ const fileExtensions = pluginInfo.fileExtensions || [];
66
+ const fileNames = pluginInfo.fileNames || [];
67
+ const basename = path_1.default.basename(filePath);
68
+ if (fileExtensions.some(ext => basename.endsWith("." + ext)) || fileNames.some(file => file === basename)) {
69
+ return formatter;
70
+ }
71
+ }
72
+ return undefined;
73
+ }
74
+ /** Cache to reduce copies of config values. */
75
+ const lastConfig = {};
76
+ const lastConfigFile = {};
77
+ /**
78
+ * Format the given text with the given config.
79
+ * @param config The config object.
80
+ * @param filePath The path to the file.
81
+ * @param fileText The content of the file.
82
+ * @returns The formatted text or undefined. It's undefined if the formatter doesn't change the text.
83
+ */
84
+ function format(configFile, config, filePath, fileText) {
85
+ const formatter = getFormatter(filePath);
86
+ if (formatter) {
87
+ const configKey = formatter.getPluginInfo().configKey;
88
+ const newConfig = JSON.stringify(config);
89
+ if (newConfig !== lastConfig[configKey] || configFile !== lastConfigFile[configKey]) {
90
+ lastConfig[configKey] = newConfig;
91
+ lastConfigFile[configKey] = configFile;
92
+ setConfig(formatter, configKey, configFile, config);
93
+ }
94
+ return formatter.formatText(filePath, fileText);
95
+ }
96
+ return undefined;
97
+ }
98
+ exports.format = format;
99
+ function setConfig(formatter, configKey, configFile, config) {
100
+ // The setting values must be strings.
101
+ const globalConfig = {};
102
+ const pluginConfig = {};
103
+ if ((configFile === null || configFile === void 0 ? void 0 : configFile.length) && fs.existsSync(configFile)) {
104
+ const configFileContent = fs.readFileSync(configFile, { encoding: "utf-8" });
105
+ const configFileJson = JSONC.parse(configFileContent);
106
+ extractConfig(configFileJson, globalConfig);
107
+ const pluginConfigFileJson = configFileJson[configKey];
108
+ if (typeof pluginConfigFileJson === "object") {
109
+ extractConfig(pluginConfigFileJson, pluginConfig);
110
+ }
111
+ }
112
+ extractConfig(config, pluginConfig);
113
+ formatter.setConfig(globalConfig, pluginConfig);
114
+ }
115
+ function isConfigAllowedType(value) {
116
+ return ["string", "number", "boolean"].includes(typeof value);
117
+ }
118
+ function extractConfig(config, toConfig) {
119
+ for (const [key, value] of Object.entries(config)) {
120
+ if (isConfigAllowedType(value)) {
121
+ toConfig[key] = value;
122
+ }
123
+ }
124
+ }
125
+ //# sourceMappingURL=dprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dprint.js","sourceRoot":"","sources":["../../../lib/dprint/dprint.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvD,iDAA+D;AAC/D,uCAAwB;AACxB,oDAAqC;AACrC,gDAAuB;AASvB,MAAM,OAAO,GAAG;IACZ,oBAAoB;IACpB,cAAc;IACd,kBAAkB;IAClB,cAAc;IACd,oBAAoB;CACd,CAAA;AAEV,MAAM,UAAU,GAAgB,EAAE,CAAA;AAElC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;IAC1B,IAAI;QACA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAW,CAAA;QACxC,IAAI,MAAM,GAAuB,SAAS,CAAA;QAC1C,IAAI,MAAM,CAAC,OAAO,EAAE;YAChB,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;SAC7C;aAAM,IAAI,MAAM,CAAC,SAAS,EAAE;YACzB,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAA;SAC9B;QACD,IAAI,MAAM,EAAE;YACR,MAAM,SAAS,GAAG,IAAA,4BAAgB,EAAC,MAAM,CAAC,CAAA;YAC1C,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;SAC7B;KACJ;IAAC,OAAO,CAAC,EAAE;QACR,qBAAqB;KACxB;CACJ;AAED,SAAS,YAAY,CAAC,QAAgB;IAClC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;QAChC,MAAM,UAAU,GAAG,SAAS,CAAC,aAAa,EAAE,CAAA;QAC5C,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,IAAI,EAAE,CAAA;QACtD,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,IAAI,EAAE,CAAA;QAC5C,MAAM,QA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CAAA;IACnD,MAAM,YAAY,GAA+B,EAAE,CAAA;IAEnD,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,KAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QACjD,MAAM,iBAAiB,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;QAC5E,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACrD,aAAa,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;QAE3C,MAAM,oBAAoB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,OAAO,oBAAoB,KAAK,QAAQ,EAAE;YAC1C,aAAa,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAA;SACpD;KACJ;IAED,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAEnC,SAAS,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;AACnD,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACvC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAA;AACjE,CAAC;AAED,SAAS,aAAa,CAAC,MAAc,EAAE,QAAiC;IACpE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC/C,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE;YAC5B,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SACxB;KACJ;AACL,CAAC"}
@@ -0,0 +1,187 @@
1
+ {
2
+ "type": "object",
3
+ "definitions": {
4
+ "preferSingleLine": {
5
+ "description": "If arrays and objects should collapse to a single line if it would be below the line width.",
6
+ "type": "boolean",
7
+ "oneOf": [
8
+ {
9
+ "description": "",
10
+ "type": "boolean",
11
+ "enum": [
12
+ true
13
+ ]
14
+ },
15
+ {
16
+ "description": "",
17
+ "type": "boolean",
18
+ "enum": [
19
+ false
20
+ ]
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ "properties": {
26
+ "locked": {
27
+ "description": "Whether the configuration is not allowed to be overriden or extended.",
28
+ "type": "boolean"
29
+ },
30
+ "lineWidth": {
31
+ "description": "The width of a line the printer will try to stay under. Note that the printer may exceed this width in certain cases.",
32
+ "type": "number"
33
+ },
34
+ "indentWidth": {
35
+ "description": "The number of characters for an indent.",
36
+ "type": "number"
37
+ },
38
+ "useTabs": {
39
+ "description": "Whether to use tabs (true) or spaces (false).",
40
+ "type": "boolean",
41
+ "oneOf": [
42
+ {
43
+ "description": "",
44
+ "type": "boolean",
45
+ "enum": [
46
+ true
47
+ ]
48
+ },
49
+ {
50
+ "description": "",
51
+ "type": "boolean",
52
+ "enum": [
53
+ false
54
+ ]
55
+ }
56
+ ]
57
+ },
58
+ "newLineKind": {
59
+ "description": "The kind of newline to use.",
60
+ "type": "string",
61
+ "oneOf": [
62
+ {
63
+ "description": "For each file, uses the newline kind found at the end of the last line.",
64
+ "type": "string",
65
+ "enum": [
66
+ "auto"
67
+ ]
68
+ },
69
+ {
70
+ "description": "Uses carriage return, line feed.",
71
+ "type": "string",
72
+ "enum": [
73
+ "crlf"
74
+ ]
75
+ },
76
+ {
77
+ "description": "Uses line feed.",
78
+ "type": "string",
79
+ "enum": [
80
+ "lf"
81
+ ]
82
+ },
83
+ {
84
+ "description": "Uses the system standard (ex. crlf on Windows).",
85
+ "type": "string",
86
+ "enum": [
87
+ "system"
88
+ ]
89
+ }
90
+ ]
91
+ },
92
+ "commentLine.forceSpaceAfterSlashes": {
93
+ "description": "Forces a space after slashes. For example: `// comment` instead of `//comment`",
94
+ "type": "boolean",
95
+ "oneOf": [
96
+ {
97
+ "description": "",
98
+ "type": "boolean",
99
+ "enum": [
100
+ true
101
+ ]
102
+ },
103
+ {
104
+ "description": "",
105
+ "type": "boolean",
106
+ "enum": [
107
+ false
108
+ ]
109
+ }
110
+ ]
111
+ },
112
+ "preferSingleLine": {
113
+ "$ref": "#/definitions/preferSingleLine"
114
+ },
115
+ "array.preferSingleLine": {
116
+ "$ref": "#/definitions/preferSingleLine"
117
+ },
118
+ "object.preferSingleLine": {
119
+ "$ref": "#/definitions/preferSingleLine"
120
+ },
121
+ "trailingCommas": {
122
+ "description": "Whether to use trailing commas.",
123
+ "type": "string",
124
+ "oneOf": [
125
+ {
126
+ "description": "Always format with trailing commas. Beware: trailing commas can cause many JSON parsers to fail.",
127
+ "type": "string",
128
+ "enum": [
129
+ "always"
130
+ ]
131
+ },
132
+ {
133
+ "description": "Use trailing commas in JSONC files and do not use trailing commas in JSON files.",
134
+ "type": "string",
135
+ "enum": [
136
+ "jsonc"
137
+ ]
138
+ },
139
+ {
140
+ "description": "Keep the trailing comma if it exists.",
141
+ "type": "string",
142
+ "enum": [
143
+ "maintain"
144
+ ]
145
+ },
146
+ {
147
+ "description": "Never format with trailing commas.",
148
+ "type": "string",
149
+ "enum": [
150
+ "never"
151
+ ]
152
+ }
153
+ ]
154
+ },
155
+ "jsonTrailingCommaFiles": {
156
+ "description": "When `trailingCommas` is `jsonc`, treat these files as JSONC and use trailing commas (ex. `[\"tsconfig.json\", \".vscode/settings.json\"]`).",
157
+ "type": "array",
158
+ "items": {
159
+ "type": "string"
160
+ }
161
+ },
162
+ "deno": {
163
+ "description": "Top level configuration that sets the configuration to what is used in Deno.",
164
+ "type": "boolean",
165
+ "oneOf": [
166
+ {
167
+ "description": "",
168
+ "type": "boolean",
169
+ "enum": [
170
+ true
171
+ ]
172
+ },
173
+ {
174
+ "description": "",
175
+ "type": "boolean",
176
+ "enum": [
177
+ false
178
+ ]
179
+ }
180
+ ]
181
+ },
182
+ "ignoreNodeCommentText": {
183
+ "description": "The text to use for an ignore comment (ex. `// dprint-ignore`).",
184
+ "type": "string"
185
+ }
186
+ }
187
+ }