Skip to content

Commit 79c06ce

Browse files
authored
removing global options since prettier already provides them. (#1478)
1 parent 95e44d2 commit 79c06ce

6 files changed

Lines changed: 42 additions & 25 deletions

File tree

knip.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://unpkg.com/knip@5/schema.json",
33
"ignoreFiles": [
44
"tests/format/RespectDefaultOptions/respect-default-options.js",
5-
"tests/integration/node.test.js"
5+
"tests/integration/**/*.test.js"
66
],
77
"ignoreDependencies": ["eslint-config-prettier"],
88
"ignoreExportsUsedInFile": {

src/options.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
11
import type { SupportOptions } from 'prettier';
22

3-
const CATEGORY_GLOBAL = 'Global';
43
const CATEGORY_COMMON = 'Common';
54
const CATEGORY_JAVASCRIPT = 'JavaScript';
65
const CATEGORY_SOLIDITY = 'Solidity';
76

87
const options: SupportOptions = {
9-
printWidth: {
10-
category: CATEGORY_GLOBAL,
11-
type: 'int',
12-
default: 80,
13-
description: 'The line length where Prettier will try to wrap.',
14-
range: { start: 0, end: Number.POSITIVE_INFINITY, step: 1 }
15-
},
16-
tabWidth: {
17-
type: 'int',
18-
category: CATEGORY_GLOBAL,
19-
default: 2,
20-
description: 'Number of spaces per indentation level.',
21-
range: { start: 0, end: Number.POSITIVE_INFINITY, step: 1 }
22-
},
23-
useTabs: {
24-
category: CATEGORY_GLOBAL,
25-
type: 'boolean',
26-
default: false,
27-
description: 'Indent with tabs instead of spaces.'
28-
},
298
bracketSpacing: {
309
category: CATEGORY_COMMON,
3110
type: 'boolean',

test.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { __dirname } = createEsmUtils(import.meta);
55

66
export default {
77
entry: {
8-
test: './tests/integration/test-app.js',
8+
test: './tests/integration/test-app/test-app.js',
99
'create-parser': './src/slang-utils/create-parser.js',
1010
'variant-coverage': './variant-coverage/index.js'
1111
},
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import getPrettier from '../../config/get-prettier.js';
2+
import getPlugins from '../../config/get-plugins.js';
3+
4+
const prettier = await getPrettier();
5+
const plugins = await getPlugins();
6+
7+
test('Prettier should report the supported options when multiple plugins are given', async () => {
8+
const supportedOptionsNames = (
9+
await prettier.getSupportInfo({ plugins })
10+
).options.map((option) => option.name);
11+
12+
expect(supportedOptionsNames).toContain('printWidth');
13+
expect(supportedOptionsNames).toContain('tabWidth');
14+
expect(supportedOptionsNames).toContain('useTabs');
15+
expect(supportedOptionsNames).toContain('bracketSpacing');
16+
expect(supportedOptionsNames).toContain('singleQuote');
17+
expect(supportedOptionsNames).toContain('experimentalTernaries');
18+
expect(supportedOptionsNames).toContain('experimentalOperatorPosition');
19+
expect(supportedOptionsNames).toContain('compiler');
20+
});
21+
22+
test('Prettier should report the supported options when a single plugin is given', async () => {
23+
const solidityPlugin = plugins[plugins.length - 1];
24+
const supportedOptionsNames = (
25+
await prettier.getSupportInfo({
26+
plugins: [solidityPlugin]
27+
})
28+
).options.map((option) => option.name);
29+
30+
expect(supportedOptionsNames).toContain('printWidth');
31+
expect(supportedOptionsNames).toContain('tabWidth');
32+
expect(supportedOptionsNames).toContain('useTabs');
33+
expect(supportedOptionsNames).toContain('bracketSpacing');
34+
expect(supportedOptionsNames).toContain('singleQuote');
35+
expect(supportedOptionsNames).toContain('experimentalTernaries');
36+
expect(supportedOptionsNames).toContain('experimentalOperatorPosition');
37+
expect(supportedOptionsNames).toContain('compiler');
38+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import format from '../../dist/test.js';
1+
import format from '../../../dist/test.js';
22

33
test('Should run a test app in a node environment', async () => {
44
const data = 'contract CheckPackage {}';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import prettier from 'prettier/standalone';
2-
import '../../dist/standalone.js';
2+
import '../../../dist/standalone.js';
33

44
export default async function format(code) {
55
const formattedCode = await prettier.format(code, {

0 commit comments

Comments
 (0)