{"id":11979,"library":"sass-formatter","title":"Sass Formatter","description":"Sass Formatter is a TypeScript-based utility for automatically formatting Sass, SCSS, CSS, and Less syntax files. It provides consistent code styling by correcting indentation, spacing, and other common formatting issues. The current stable version is 0.8.0, indicating it is still in active development with potential for minor breaking changes before a 1.0 release. It features both a programmatic API for integration into tools and a powerful command-line interface (CLI) for direct file processing and CI/CD pipelines. A key differentiator is its ability to convert CSS or SCSS to Sass syntax, alongside customizable formatting rules through a `.sassformatterrc.json` configuration file. It is notably used in the VS Code Sass extension. While a specific release cadence isn't published, the project is actively maintained with frequent updates.","status":"active","version":"0.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/TheRealSyler/sass-formatter","tags":["javascript","sass","formatter","typescript"],"install":[{"cmd":"npm install sass-formatter","lang":"bash","label":"npm"},{"cmd":"yarn add sass-formatter","lang":"bash","label":"yarn"},{"cmd":"pnpm add sass-formatter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primary class for programmatic formatting. The package is ESM-first, commonJS requires are not supported.","wrong":"const SassFormatter = require('sass-formatter');","symbol":"SassFormatter","correct":"import { SassFormatter } from 'sass-formatter';"},{"note":"TypeScript interface for configuring the formatter's behavior. Can be imported for type checking custom configurations.","wrong":"import type { SassFormatterConfig } from 'sass-formatter'; // While valid, explicit 'type' import might be used for clarity in some TS configs.","symbol":"SassFormatterConfig","correct":"import { SassFormatterConfig } from 'sass-formatter';"},{"note":"Provides the default configuration object, useful for merging with custom settings. The package is ESM-first.","wrong":"const defaultSassFormatterConfig = require('sass-formatter').defaultSassFormatterConfig;","symbol":"defaultSassFormatterConfig","correct":"import { defaultSassFormatterConfig } from 'sass-formatter';"}],"quickstart":{"code":"import { SassFormatter } from 'sass-formatter';\n\nconst unformattedSass = `\n// This is an unformatted Sass snippet\nspan\n  color: none\n  @for $i from 0 through 2\n    &:nth-child(#{$i})\n        color: none\n    @each $author in $list\n      .photo-#{$author}\n                background: image-url(\"avatars/#{$author}.png\") no-repeat\n\n@while $types > 0\n      .while-#{$types}\n width: $type-width + $types\n`;\n\nconsole.log('--- Original Sass ---');\nconsole.log(unformattedSass);\n\nconst formattedSass = SassFormatter.Format(unformattedSass);\n\nconsole.log('\\n--- Formatted Sass ---');\nconsole.log(formattedSass);\n","lang":"typescript","description":"Demonstrates how to import and use the `SassFormatter` class to format a Sass string programmatically and print the result."},"warnings":[{"fix":"Remove the `deleteWhitespace` key from your `.sassformatterrc.json` or custom configuration file. It may be removed in future versions.","message":"The `deleteWhitespace` configuration option is deprecated in `SassFormatterConfig`.","severity":"deprecated","affected_versions":">=0.8.0"},{"fix":"Consult the project's changelog or GitHub releases for detailed breaking change information before upgrading to a new version.","message":"As a pre-1.0 package, `sass-formatter` may introduce breaking changes in minor versions. Always review release notes carefully when upgrading.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Ensure all keys in your `.sassformatterrc.json` or custom config file adhere to the `SassFormatterConfig` interface, and that values match the expected types.","message":"When using a custom configuration file, providing unknown keys or invalid values will trigger warnings or an exit code 1, respectively, during CLI execution.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed via `npm install sass-formatter` or `yarn add sass-formatter`, and that your project supports ESM imports (e.g., set `\"type\": \"module\"` in package.json or use `.mjs` files).","cause":"The 'sass-formatter' package is not installed or the import path is incorrect. It's an ESM-only package.","error":"Error: Cannot find module 'sass-formatter'"},{"fix":"Install the CLI tool globally using `npm install -g sass-formatter` or ensure `node_modules/.bin` is included in your system's PATH environment variable for local installations.","cause":"The `sass-formatter` CLI tool is not globally installed or its executable path is not in your system's PATH.","error":"sass-formatter: command not found"},{"fix":"Review the specified configuration file for JSON syntax errors. Refer to the `SassFormatterConfig` interface in the documentation for valid keys and their expected value types.","cause":"The custom configuration file specified (e.g., `.sassformatterrc.json`) contains syntax errors, is not valid JSON, or contains unrecognized keys/values.","error":"Invalid config file: [path-to-config-file].json"}],"ecosystem":"npm"}