From e37f6b97c2c2ffedec68477bffcf748d88915269 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 25 Mar 2026 02:02:48 -0300 Subject: [PATCH] removing global options since prettier already provides them. --- knip.json | 2 +- src/options.ts | 21 ---------- test.config.js | 2 +- tests/integration/options/options.test.js | 38 +++++++++++++++++++ tests/integration/{ => test-app}/node.test.js | 2 +- tests/integration/{ => test-app}/test-app.js | 2 +- 6 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 tests/integration/options/options.test.js rename tests/integration/{ => test-app}/node.test.js (80%) rename tests/integration/{ => test-app}/test-app.js (85%) diff --git a/knip.json b/knip.json index 9f6cf375e..7dde91d8b 100644 --- a/knip.json +++ b/knip.json @@ -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": { diff --git a/src/options.ts b/src/options.ts index bb14eb765..7cc88baf3 100644 --- a/src/options.ts +++ b/src/options.ts @@ -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', diff --git a/test.config.js b/test.config.js index 99f93a10e..ea52663fd 100644 --- a/test.config.js +++ b/test.config.js @@ -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' }, diff --git a/tests/integration/options/options.test.js b/tests/integration/options/options.test.js new file mode 100644 index 000000000..17e522068 --- /dev/null +++ b/tests/integration/options/options.test.js @@ -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'); +}); diff --git a/tests/integration/node.test.js b/tests/integration/test-app/node.test.js similarity index 80% rename from tests/integration/node.test.js rename to tests/integration/test-app/node.test.js index d1785af76..358158c5f 100644 --- a/tests/integration/node.test.js +++ b/tests/integration/test-app/node.test.js @@ -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 {}'; diff --git a/tests/integration/test-app.js b/tests/integration/test-app/test-app.js similarity index 85% rename from tests/integration/test-app.js rename to tests/integration/test-app/test-app.js index 17e248e0f..35c031857 100644 --- a/tests/integration/test-app.js +++ b/tests/integration/test-app/test-app.js @@ -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, {