Registry / devops / dart-style

dart-style

JSON →
library1.3.2-devjsnpmunverified

Opinionated, automatic Dart source code formatter that provides both an API and CLI tool. Version 1.3.2-dev is a development release. It enforces consistent Dart coding style as defined by the Dart team. Unlike alternatives, it is the official formatter from the Dart project, tightly integrated with the Dart ecosystem. Use for formatting Dart code in build pipelines or editor integration.

npm install dart-style
INSTALL
IMPORT
SIG · DART-STYLE
D
dart-style
devopsjavascriptv1.3.2-dev
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DartFormatter
import { DartFormatter } from 'dart-style';
const DartFormatter = require('dart-style').DartFormatter;
Package is ESM-only; CommonJS require will not work.
formatCode
import { formatCode } from 'dart-style';
import { format } from 'dart-style';
Function name is formatCode, not format.
DartFormatterOptions
import type { DartFormatterOptions } from 'dart-style';
Use import type for TypeScript type imports.

Demonstrates basic usage of DartFormatter to format a simple Dart snippet using the ESM import.

import { DartFormatter } from 'dart-style'; const code = `void main() { print('hello'); }`; const formatter = new DartFormatter(); try { const result = formatter.formatCode(code); console.log(result); } catch (e) { console.error('Formatting error:', e); }
Debug
Known issues
gotchaThe package has no type definitions for some options.
fix
Use inline type assertions or check the source for available options.
affects: >=1.0.0
breakingAPI changed from synchronous to asynchronous in some versions.
fix
Check your import; the default export may be a promise. Use await formatter.formatCode().
affects: >=1.2.0
deprecatedThe `format` function is deprecated in favor of `formatCode`.
fix
Replace format with formatCode.
affects: >=1.3.0
Errors
Common errors & fixes
Cannot find module 'dart-style'
Package is not installed or not in node_modules.
fix
Run 'npm install dart-style' or 'yarn add dart-style'.
TypeError: dart_formatter.formatCode is not a function
Incorrect import or use of CommonJS require.
fix
Use ESM import: import { DartFormatter } from 'dart-style';
SyntaxError: The requested module 'dart-style' does not provide an export named 'format'
Trying to import 'format' which does not exist (deprecated in newer versions).
fix
Use 'formatCode' instead of 'format'.
Upgrade
Version history
1.3.2-devlatest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
dart-style — npm install dart-style · libregistry