Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://unpkg.com/knip@5/schema.json",
"ignoreFiles": [
"tests/format/RespectDefaultOptions/respect-default-options.js",
"tests/integration/node.test.js"
"tests/integration/**/*.test.js"
],
"ignoreDependencies": ["eslint-config-prettier"],
"ignoreExportsUsedInFile": {
Expand Down
21 changes: 0 additions & 21 deletions src/options.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
import type { SupportOptions } from 'prettier';

const CATEGORY_GLOBAL = 'Global';
const CATEGORY_COMMON = 'Common';
const CATEGORY_JAVASCRIPT = 'JavaScript';
const CATEGORY_SOLIDITY = 'Solidity';

const options: SupportOptions = {
printWidth: {
category: CATEGORY_GLOBAL,
type: 'int',
default: 80,
description: 'The line length where Prettier will try to wrap.',
range: { start: 0, end: Number.POSITIVE_INFINITY, step: 1 }
},
tabWidth: {
type: 'int',
category: CATEGORY_GLOBAL,
default: 2,
description: 'Number of spaces per indentation level.',
range: { start: 0, end: Number.POSITIVE_INFINITY, step: 1 }
},
useTabs: {
category: CATEGORY_GLOBAL,
type: 'boolean',
default: false,
description: 'Indent with tabs instead of spaces.'
},
bracketSpacing: {
category: CATEGORY_COMMON,
type: 'boolean',
Expand Down
2 changes: 1 addition & 1 deletion test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { __dirname } = createEsmUtils(import.meta);

export default {
entry: {
test: './tests/integration/test-app.js',
test: './tests/integration/test-app/test-app.js',
'create-parser': './src/slang-utils/create-parser.js',
'variant-coverage': './variant-coverage/index.js'
},
Expand Down
38 changes: 38 additions & 0 deletions tests/integration/options/options.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import getPrettier from '../../config/get-prettier.js';
import getPlugins from '../../config/get-plugins.js';

const prettier = await getPrettier();
const plugins = await getPlugins();

test('Prettier should report the supported options when multiple plugins are given', async () => {
const supportedOptionsNames = (
await prettier.getSupportInfo({ plugins })
).options.map((option) => option.name);

expect(supportedOptionsNames).toContain('printWidth');
expect(supportedOptionsNames).toContain('tabWidth');
expect(supportedOptionsNames).toContain('useTabs');
expect(supportedOptionsNames).toContain('bracketSpacing');
expect(supportedOptionsNames).toContain('singleQuote');
expect(supportedOptionsNames).toContain('experimentalTernaries');
expect(supportedOptionsNames).toContain('experimentalOperatorPosition');
expect(supportedOptionsNames).toContain('compiler');
});

test('Prettier should report the supported options when a single plugin is given', async () => {
const solidityPlugin = plugins[plugins.length - 1];
const supportedOptionsNames = (
await prettier.getSupportInfo({
plugins: [solidityPlugin]
})
).options.map((option) => option.name);

expect(supportedOptionsNames).toContain('printWidth');
expect(supportedOptionsNames).toContain('tabWidth');
expect(supportedOptionsNames).toContain('useTabs');
expect(supportedOptionsNames).toContain('bracketSpacing');
expect(supportedOptionsNames).toContain('singleQuote');
expect(supportedOptionsNames).toContain('experimentalTernaries');
expect(supportedOptionsNames).toContain('experimentalOperatorPosition');
expect(supportedOptionsNames).toContain('compiler');
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import format from '../../dist/test.js';
import format from '../../../dist/test.js';

test('Should run a test app in a node environment', async () => {
const data = 'contract CheckPackage {}';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import prettier from 'prettier/standalone';
import '../../dist/standalone.js';
import '../../../dist/standalone.js';

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