@ben_12/eslint-plugin-dprint 0.8.0 → 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.
@@ -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;
@@ -1 +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,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D,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"}
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "type": "object",
3
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
+ },
4
38
  "useTabs": {
5
39
  "description": "Whether to use tabs (true) or spaces (false).",
6
40
  "type": "boolean",
@@ -76,25 +110,55 @@
76
110
  ]
77
111
  },
78
112
  "preferSingleLine": {
79
- "description": "If arrays and objects should collapse to a single line if it would be below the line width.",
80
- "type": "boolean",
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",
81
124
  "oneOf": [
82
125
  {
83
- "description": "",
84
- "type": "boolean",
126
+ "description": "Always format with trailing commas. Beware: trailing commas can cause many JSON parsers to fail.",
127
+ "type": "string",
85
128
  "enum": [
86
- true
129
+ "always"
87
130
  ]
88
131
  },
89
132
  {
90
- "description": "",
91
- "type": "boolean",
133
+ "description": "Use trailing commas in JSONC files and do not use trailing commas in JSON files.",
134
+ "type": "string",
92
135
  "enum": [
93
- false
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"
94
151
  ]
95
152
  }
96
153
  ]
97
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
+ },
98
162
  "deno": {
99
163
  "description": "Top level configuration that sets the configuration to what is used in Deno.",
100
164
  "type": "boolean",
@@ -114,41 +178,6 @@
114
178
  ]
115
179
  }
116
180
  ]
117
- }
118
- },
119
- "properties": {
120
- "locked": {
121
- "description": "Whether the configuration is not allowed to be overriden or extended.",
122
- "type": "boolean"
123
- },
124
- "lineWidth": {
125
- "description": "The width of a line the printer will try to stay under. Note that the printer may exceed this width in certain cases.",
126
- "type": "number"
127
- },
128
- "indentWidth": {
129
- "description": "The number of characters for an indent.",
130
- "type": "number"
131
- },
132
- "useTabs": {
133
- "$ref": "#/definitions/useTabs"
134
- },
135
- "newLineKind": {
136
- "$ref": "#/definitions/newLineKind"
137
- },
138
- "commentLine.forceSpaceAfterSlashes": {
139
- "$ref": "#/definitions/commentLine.forceSpaceAfterSlashes"
140
- },
141
- "preferSingleLine": {
142
- "$ref": "#/definitions/preferSingleLine"
143
- },
144
- "array.preferSingleLine": {
145
- "$ref": "#/definitions/preferSingleLine"
146
- },
147
- "object.preferSingleLine": {
148
- "$ref": "#/definitions/preferSingleLine"
149
- },
150
- "deno": {
151
- "$ref": "#/definitions/deno"
152
181
  },
153
182
  "ignoreNodeCommentText": {
154
183
  "description": "The text to use for an ignore comment (ex. `// dprint-ignore`).",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ben_12/eslint-plugin-dprint",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "An ESLint plugin that fixes code with dprint",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -12,10 +12,10 @@
12
12
  ],
13
13
  "peerDependencies": {
14
14
  "@dprint/dockerfile": "^0.3.0",
15
- "@dprint/json": "^0.17.4",
15
+ "@dprint/json": "^0.19.0",
16
16
  "@dprint/markdown": "^0.16.2",
17
17
  "@dprint/toml": "^0.5.4",
18
- "@dprint/typescript": "^0.88.1",
18
+ "@dprint/typescript": "^0.88.3",
19
19
  "eslint": ">=7.0.0"
20
20
  },
21
21
  "peerDependenciesMeta": {
@@ -42,7 +42,7 @@
42
42
  "jsonc-parser": "^3.2.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@ben_12/eslint-plugin-dprint": "^0.7.1",
45
+ "@ben_12/eslint-plugin-dprint": "file:./test/internal-rules",
46
46
  "@ben_12/eslint-simple-parser": "^0.1.0",
47
47
  "@types/debug": "^4.1.5",
48
48
  "@types/diff": "^5.0.0",
@@ -60,7 +60,7 @@
60
60
  "scripts": {
61
61
  "build": "rimraf dist && tsc -p tsconfig.build.json",
62
62
  "codecov": "nyc report --reporter text-lcov | codecov --pipe --disable=gcov",
63
- "lint": "eslint \"**/*.ts\"",
63
+ "lint": "eslint \"**/*.ts\" \"**/*.js\" \"**/*.md\"",
64
64
  "test": "npm run -s lint && npm run -s test:ci",
65
65
  "test:ci": "tsc && nyc mocha \"test/rules/**/*.ts\"",
66
66
  "watch": "mocha --require ts-node/register --watch --watch-files \"lib/**/*.ts,test/**/*.ts\" \"test/rules/**/*.ts\"",