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
40 changes: 34 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,56 @@ permissions:
jobs:
build:
uses: Workiva/gha-dart-oss/.github/workflows/build.yaml@v0.1.14
with:
sdk: 3.13.4

dart:
strategy:
fail-fast: false
matrix:
os: [ ubuntu, windows ]
sdk: [ 2.19.6, stable ]
# 3.7.0 is the oldest Dart 3 that supports `dart format --language-version`,
# which dart_dev already passes on Dart 3.
sdk: [ 3.7.0, stable ]
name: Dart ${{ matrix.sdk }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.sdk }}
- name: Install dependencies
run: dart pub get
# Dart stable is currently 3.13.4, which resolves analyzer 14.x.
# analyzer 11+ requires Dart 3.9+, so this check is stable-only.
- name: Verify analyzer 14.x on Dart stable
if: ${{ matrix.sdk == 'stable' && matrix.os == 'ubuntu' }}
run: |
version=$(awk '
$0 == " analyzer:" { found=1 }
found && $1 == "version:" {
gsub(/"/, "", $2)
print $2
exit
}
' pubspec.lock)
echo "Dart SDK: $(dart --version 2>&1)"
echo "Resolved analyzer $version"
case "$version" in
14.*) ;;
*)
echo "Expected analyzer 14.x on Dart stable, got: ${version:-<none>}"
exit 1
;;
esac
- name: Validate dependencies
run: dart run dependency_validator
- name: Analysis
run: dart run dart_dev analyze
- name: Formatting
if: ${{ matrix.sdk == 'stable' && matrix.os == 'ubuntu' }}
run: dart run dart_dev format --check
# Format check disabled for the Dart 3 upgrade. Dart 3.7+ uses a new
# formatter style; uncomment after a dedicated format PR.
# - name: Formatting
# if: ${{ matrix.sdk == 'stable' && matrix.os == 'ubuntu' }}
# run: dart run dart_dev format --check
- name: Tests
run: dart run dart_dev test ${{ matrix.sdk != '2.19.6' && '--test-args="--exclude-tags dart2"' || '' }}
run: dart run dart_dev test
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## Unreleased

- Require Dart SDK `>=3.7.0 <4.0.0`. Always use `dart analyze` and `dart format` (the `dartanalyzer`
and `dartfmt` SDK commands no longer exist). `Formatter.dartfmt` now maps to
`dart format`. `AnalyzeTool.useDartAnalyze` is ignored.
- Allow analyzer 14 (`>=5.0.0 <15.0.0`).
- Serve accepts globally activated `webdev` `>=3.0.0 <5.0.0` (3.x and 4.x).
- Remove `TuneupCheckTool`.

## 4.2.4

- Update dependencies to allow analyzer 7
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ variance across projects becomes a configuration detail that need not be
memorized or referenced in order to run said task.

Consider formatting as an example. The default approach to formatting files is
to run `dartfmt -w .`. But, some projects may want to exclude certain files that
to run `dart format .`. But, some projects may want to exclude certain files that
would otherwise be formatted by this command. Or, some projects may want to use
`pub run dart_style:format` instead of `dart format`. Currently, there is no
`dart run dart_style:format` instead of `dart format`. Currently, there is no
project-level configuration supported by the formatter, so these sorts of things
just have to be documented in a `README.md` or `CONTRIBUTING.md`.

Expand Down Expand Up @@ -234,7 +234,7 @@ final config = {
dart_dev can be used to facilitate formatting on save inside of JetBrains IDEs. For setup instructions, see below.

### A Note on VS Code
A VS code extension exists to run either `dartfmt` or `over_react_format` on save. For information on it, see [its project](vs-code-formatter). However, that VS Code extension does not run `dart_dev`, but rather has its own logic to run a formatting command.
A VS code extension exists to run either `dart format` or `over_react_format` on save. For information on it, see [its project](vs-code-formatter). However, that VS Code extension does not run `dart_dev`, but rather has its own logic to run a formatting command.

### JetBrains IDEs (WebStorm, IntelliJ, etc.)
Webstorm exposes a File Watcher utility that can be used to run commands when a file saves. For this approach, all you need to do is set up the file watcher. Shoutout to @patkujawa-wf for creating the original inspiration of this solution!
Expand Down
10 changes: 3 additions & 7 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ analyzer:
language:
strict-inference: true
strict-raw-types: true
strong-mode:
implicit-casts: true
implicit-dynamic: true

linter:
rules:
- avoid_types_on_closure_parameters
- prefer_void_to_null
- void_checks
- overridden_fields: false
avoid_types_on_closure_parameters: true
prefer_void_to_null: true
void_checks: true
2 changes: 0 additions & 2 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ The `dart_dev` package includes:
- [`AnalyzeTool`][analyze-tool]
- [`FormatTool`][format-tool]
- [`TestTool`][test-tool]
- [`TuneupCheckTool`][tuneup-check-tool]
- [`WebdevServeTool`][webdev-serve-tool]
- [Creating, Extending, and Composing Tools][tool-composition]
- [v3 upgrade guide][v3-upgrade-guide]

<!-- Table of Contents Links -->
[analyze-tool]: /doc/tools/analyze-tool.md
[tuneup-check-tool]: /doc/tools/tuneup-check-tool.md
[dart-function-tool]: /doc/tools/dart-function-tool.md
[format-tool]: /doc/tools/format-tool.md
[process-tool]: /doc/tools/process-tool.md
Expand Down
2 changes: 0 additions & 2 deletions doc/tool-composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,12 @@ final config = {
- [`AnalyzeTool`][analyze-tool]
- [`FormatTool`][format-tool]
- [`TestTool`][test-tool]
- [`TuneupCheckTool`][tuneup-check-tool]
- [`WebdevServeTool`][webdev-serve-tool]
- [Creating, Extending, and Composing Tools][tool-composition]
- [v3 upgrade guide][v3-upgrade-guide]

<!-- Table of Contents Links -->
[analyze-tool]: /doc/tools/analyze-tool.md
[tuneup-check-tool]: /doc/tools/tuneup-check-tool.md
[dart-function-tool]: /doc/tools/dart-function-tool.md
[format-tool]: /doc/tools/format-tool.md
[process-tool]: /doc/tools/process-tool.md
Expand Down
18 changes: 4 additions & 14 deletions doc/tools/analyze-tool.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `AnalyzeTool`

Statically analyzes the current project by running the `dartanalyzer`.
Statically analyzes the current project by running `dart analyze`.

## Usage

Expand All @@ -18,13 +18,13 @@ final config = {

## Default behavior

By default this tool will run `dartanalyzer .` which will analyze all dart files
By default this tool will run `dart analyze .` which will analyze all dart files
in the current project.

## Configuration

`AnalyzeTool` supports one configuration option which is the list of args to
pass to the `dartanalyzer` process:
pass to the `dart analyze` process:

```dart
// tool/dart_dev/config.dart
Expand All @@ -43,22 +43,14 @@ final config = {
## Excluding files from analysis

The `analysis_options.yaml` configuration file
[supports excluding files][analysis-exclude]. However, there is an
[open issue with the `dartanalyzer` CLI][analyzer-exclude-issue] because it does
not respect this list.

If your project has files that need to be excluded from analysis (e.g. generated
files), use the [`TuneupCheckTool`][tuneup-check-tool]. It uses the
`tuneup` package to run analysis instead of `dartanalyzer` and it properly
respects the exclude rules defined in `analysis_options.yaml`.
[supports excluding files][analysis-exclude]. `dart analyze` respects this list.

## Command-line options

```bash
$ ddev help analyze
```

[analyzer-exclude-issue]: https://github.com/dart-lang/sdk/issues/25551
[analysis-exclude]: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis
[core-config]: /lib/src/core_config.dart

Expand All @@ -71,14 +63,12 @@ $ ddev help analyze
- [`AnalyzeTool`][analyze-tool]
- [`FormatTool`][format-tool]
- [`TestTool`][test-tool]
- [`TuneupCheckTool`][tuneup-check-tool]
- [`WebdevServeTool`][webdev-serve-tool]
- [Creating, Extending, and Composing Tools][tool-composition]
- [v3 upgrade guide][v3-upgrade-guide]

<!-- Table of Contents Links -->
[analyze-tool]: /doc/tools/analyze-tool.md
[tuneup-check-tool]: /doc/tools/tuneup-check-tool.md
[dart-function-tool]: /doc/tools/dart-function-tool.md
[format-tool]: /doc/tools/format-tool.md
[process-tool]: /doc/tools/process-tool.md
Expand Down
14 changes: 6 additions & 8 deletions doc/tools/format-tool.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `FormatTool`

Formats dart files in the current project by running `dartfmt`.
Formats dart files in the current project by running `dart format`.

## Usage

Expand All @@ -18,7 +18,7 @@ final config = {

## Default behavior

By default this tool will run `dartfmt -w .` which will format all dart files in
By default this tool will run `dart format .` which will format all dart files in
the current project.

## Configuration
Expand All @@ -44,11 +44,11 @@ final config = {
};
```

### Using the `dart_style` package instead of `dartfmt`
### Using the `dart_style` package instead of `dart format`

Some projects like to depend on a specific version of the `dart_style` package
and use its `format` executable rather than the `dartfmt` provided by the Dart
SDK.
and use its `format` executable rather than the `dart format` command provided
by the Dart SDK.

```dart
// tool/dart_dev/config.dart
Expand All @@ -75,7 +75,7 @@ final config = {
```bash
$ ddev format
[INFO] Running subprocess...
dartfmt -w --fix .
dart format --fix .
----------------------------
```

Expand Down Expand Up @@ -142,14 +142,12 @@ $ ddev help format
- [`AnalyzeTool`][analyze-tool]
- [`FormatTool`][format-tool]
- [`TestTool`][test-tool]
- [`TuneupCheckTool`][tuneup-check-tool]
- [`WebdevServeTool`][webdev-serve-tool]
- [Creating, Extending, and Composing Tools][tool-composition]
- [v3 upgrade guide][v3-upgrade-guide]

<!-- Table of Contents Links -->
[analyze-tool]: /doc/tools/analyze-tool.md
[tuneup-check-tool]: /doc/tools/tuneup-check-tool.md
[dart-function-tool]: /doc/tools/dart-function-tool.md
[format-tool]: /doc/tools/format-tool.md
[process-tool]: /doc/tools/process-tool.md
Expand Down
2 changes: 0 additions & 2 deletions doc/tools/test-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,12 @@ $ ddev help test
- [`AnalyzeTool`][analyze-tool]
- [`FormatTool`][format-tool]
- [`TestTool`][test-tool]
- [`TuneupCheckTool`][tuneup-check-tool]
- [`WebdevServeTool`][webdev-serve-tool]
- [Creating, Extending, and Composing Tools][tool-composition]
- [v3 upgrade guide][v3-upgrade-guide]

<!-- Table of Contents Links -->
[analyze-tool]: /doc/tools/analyze-tool.md
[tuneup-check-tool]: /doc/tools/tuneup-check-tool.md
[dart-function-tool]: /doc/tools/dart-function-tool.md
[format-tool]: /doc/tools/format-tool.md
[process-tool]: /doc/tools/process-tool.md
Expand Down
89 changes: 0 additions & 89 deletions doc/tools/tuneup-check-tool.md

This file was deleted.

2 changes: 0 additions & 2 deletions doc/tools/webdev-serve-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ $ ddev help serve
- [`AnalyzeTool`][analyze-tool]
- [`FormatTool`][format-tool]
- [`TestTool`][test-tool]
- [`TuneupCheckTool`][tuneup-check-tool]
- [`WebdevServeTool`][webdev-serve-tool]
- [Creating, Extending, and Composing Tools][tool-composition]
- [v3 upgrade guide][v3-upgrade-guide]

<!-- Table of Contents Links -->
[analyze-tool]: /doc/tools/analyze-tool.md
[tuneup-check-tool]: /doc/tools/tuneup-check-tool.md
[dart-function-tool]: /doc/tools/dart-function-tool.md
[format-tool]: /doc/tools/format-tool.md
[process-tool]: /doc/tools/process-tool.md
Expand Down
Loading
Loading