Merged in fix/3697-prettier-configs (pull request #3396)

fix(SW-3691): Setup one prettier config for whole repo

* Setup prettierrc in root and remove other configs


Approved-by: Joakim Jäderberg
Approved-by: Linus Flood
This commit is contained in:
Rasmus Langvad
2026-01-07 12:45:50 +00:00
parent 932413412b
commit d0546926a9
500 changed files with 18367 additions and 18419 deletions

View File

@@ -1,38 +1,38 @@
/// <reference types="vitest" />
import { dirname, extname, relative, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import fs from 'node:fs'
import { dirname, extname, relative, resolve } from "node:path"
import { fileURLToPath } from "node:url"
import fs from "node:fs"
import react from '@vitejs/plugin-react'
import { glob } from 'glob'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import { libInjectCss } from 'vite-plugin-lib-inject-css'
import react from "@vitejs/plugin-react"
import { glob } from "glob"
import { defineConfig } from "vite"
import dts from "vite-plugin-dts"
import { libInjectCss } from "vite-plugin-lib-inject-css"
// import ensureDirectives from './plugins/rollup-plugin-ensure-directives'
import preserveDirectives from 'rollup-preserve-directives'
import preserveDirectives from "rollup-preserve-directives"
// https://vitejs.dev/config/
export default defineConfig({
optimizeDeps: {
include: ['react/jsx-dev-runtime'],
include: ["react/jsx-dev-runtime"],
},
plugins: [
react(),
libInjectCss(),
dts({
include: ['lib'],
include: ["lib"],
exclude: [
'node_modules',
'**/*.css',
'**/*.test.ts',
'**/*.stories.tsx',
'.storybook/content/*.mdx',
'.storybook/content/tokens/**/*.mdx',
'.storybook/content/tokens/**/*.css',
'.storybook/content/tokens/**/*.tsx',
"node_modules",
"**/*.css",
"**/*.test.ts",
"**/*.stories.tsx",
".storybook/content/*.mdx",
".storybook/content/tokens/**/*.mdx",
".storybook/content/tokens/**/*.css",
".storybook/content/tokens/**/*.tsx",
],
// rollupTypes: true,
bundledPackages: ['class-variance-authority', 'clsx'],
bundledPackages: ["class-variance-authority", "clsx"],
}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
preserveDirectives() as any,
@@ -41,24 +41,24 @@ export default defineConfig({
cssCodeSplit: true,
copyPublicDir: false,
lib: {
entry: [resolve(__dirname, 'lib/index.ts')],
formats: ['es'],
entry: [resolve(__dirname, "lib/index.ts")],
formats: ["es"],
},
rollupOptions: {
plugins: [],
external: [
'react',
'react-dom',
'react/jsx-runtime',
'react-aria-components',
'react-hook-form',
'react-intl',
'next',
"react",
"react-dom",
"react/jsx-runtime",
"react-aria-components",
"react-hook-form",
"react-intl",
"next",
],
onwarn(warning, defaultHandler) {
if (
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
warning.message.includes('use client')
warning.code === "MODULE_LEVEL_DIRECTIVE" &&
warning.message.includes("use client")
) {
return
}
@@ -68,16 +68,16 @@ export default defineConfig({
// We ignore sourcemap_error on the first character for component files
// to be caused by the 'use client' directive
if (
warning.code === 'SOURCEMAP_ERROR' &&
warning.code === "SOURCEMAP_ERROR" &&
warning.loc?.file &&
warning.loc.line === 1 &&
warning.loc.column === 0
) {
if (fs.statSync(warning.loc.file)) {
const file = fs.readFileSync(warning.loc.file, {
encoding: 'utf-8',
encoding: "utf-8",
})
const lines = file.split('\n')
const lines = file.split("\n")
if (lines[0] === "'use client'") {
return
@@ -89,15 +89,15 @@ export default defineConfig({
},
input: Object.fromEntries(
glob
.sync(['lib/**/*.{ts,tsx,css}'], {
ignore: ['**/types.ts', '**/*.stories.{ts,tsx}', 'lib/tokens/*'],
.sync(["lib/**/*.{ts,tsx,css}"], {
ignore: ["**/types.ts", "**/*.stories.{ts,tsx}", "lib/tokens/*"],
})
.map((file) => {
return [
// The name of the entry point
// lib/nested/foo.ts becomes nested/foo
relative(
'lib',
"lib",
file.slice(0, file.length - extname(file).length)
),
// The absolute path to the entry file
@@ -110,13 +110,13 @@ export default defineConfig({
assetFileNames: (assetInfo) => {
if (assetInfo.originalFileNames.length > 0) {
const originalFileName = assetInfo.originalFileNames[0]
if (originalFileName.indexOf('/components/') >= 0) {
return `${dirname(originalFileName).replace('lib/', '')}/[name]-[hash][extname]`
if (originalFileName.indexOf("/components/") >= 0) {
return `${dirname(originalFileName).replace("lib/", "")}/[name]-[hash][extname]`
}
}
return `[name][extname]`
},
entryFileNames: '[name].js',
entryFileNames: "[name].js",
},
},
},