Skip to content

Commit ed0219c

Browse files
authored
feat(dart_frog_lint): add pkg:dart_frog_lint (#1821)
1 parent 1338886 commit ed0219c

File tree

14 files changed

+298
-0
lines changed

14 files changed

+298
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Dart Package Workflow
2+
description: Build and test Dart packages.
3+
4+
inputs:
5+
collect_coverage:
6+
required: false
7+
default: "true"
8+
description: Whether to collect code coverage
9+
collect_score:
10+
required: false
11+
default: "true"
12+
description: Whether to collect the pana score
13+
concurrency:
14+
required: false
15+
default: "4"
16+
description: The value of the concurrency flag (-j) used when running tests
17+
coverage_excludes:
18+
required: false
19+
default: ""
20+
description: Globs to exclude from coverage
21+
dart_sdk:
22+
required: false
23+
default: "stable"
24+
description: "The dart sdk version to use"
25+
working_directory:
26+
required: false
27+
default: "."
28+
description: The working directory for this workflow
29+
min_coverage:
30+
required: false
31+
default: "100"
32+
description: The minimum coverage percentage value
33+
min_score:
34+
required: false
35+
default: "120"
36+
description: The minimum pana score value
37+
analyze_directories:
38+
required: false
39+
default: "lib test"
40+
description: Directories to analyze
41+
report_on:
42+
required: false
43+
default: "lib"
44+
description: Directories to report on when collecting coverage
45+
run_tests:
46+
required: false
47+
default: "true"
48+
description: Whether to run tests for the package.
49+
50+
runs:
51+
using: "composite"
52+
steps:
53+
- name: 🎯 Setup Dart
54+
uses: dart-lang/setup-dart@v1
55+
with:
56+
sdk: ${{inputs.dart_sdk}}
57+
58+
- name: 📦 Install Dependencies
59+
working-directory: ${{ inputs.working_directory }}
60+
shell: ${{ inputs.shell }}
61+
run: dart pub get
62+
63+
- name: ✨ Format
64+
working-directory: ${{ inputs.working_directory }}
65+
shell: ${{ inputs.shell }}
66+
run: dart format --set-exit-if-changed .
67+
68+
- name: 🔍 Analyze
69+
working-directory: ${{ inputs.working_directory }}
70+
shell: ${{ inputs.shell }}
71+
run: dart analyze --fatal-warnings ${{inputs.analyze_directories}}
72+
73+
- name: 🧪 Test
74+
if: inputs.run_tests == 'true'
75+
working-directory: ${{ inputs.working_directory }}
76+
shell: ${{ inputs.shell }}
77+
run: |
78+
dart pub global activate coverage
79+
dart test -j ${{inputs.concurrency}} --coverage=coverage && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=${{inputs.report_on}} --check-ignore
80+
81+
- name: 📊 Verify Coverage
82+
if: inputs.run_tests == 'true' && inputs.collect_coverage == 'true'
83+
uses: VeryGoodOpenSource/very_good_coverage@v3
84+
with:
85+
path: ${{inputs.working_directory}}/coverage/lcov.info
86+
exclude: ${{inputs.coverage_excludes}}
87+
min_coverage: ${{inputs.min_coverage}}
88+
89+
- name: 💯 Verify Pub Score
90+
if: inputs.collect_score == 'true'
91+
working-directory: ${{ inputs.working_directory }}
92+
shell: ${{ inputs.shell }}
93+
run: |
94+
dart pub global activate pana 0.22.21
95+
sudo apt-get install webp
96+
PANA=$(pana . --no-warning); PANA_SCORE=$(echo $PANA | sed -n "s/.*Points: \([0-9]*\)\/\([0-9]*\)./\1\/\2/p")
97+
echo "score: $PANA_SCORE"
98+
IFS='/'; read -a SCORE_ARR <<< "$PANA_SCORE"; SCORE=SCORE_ARR[0]; TOTAL=SCORE_ARR[1]
99+
if [ -z "$1" ]; then MINIMUM_SCORE=TOTAL; else MINIMUM_SCORE=$1; fi
100+
if (( $SCORE < $MINIMUM_SCORE )); then echo "minimum score $MINIMUM_SCORE was not met!"; exit 1; fi

.github/workflows/dart_frog_lint.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: dart_frog_lint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/dart_frog_lint.yaml"
7+
- "packages/dart_frog_lint/lib/**"
8+
- "packages/dart_frog_lint/pubspec.yaml"
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- ".github/workflows/dart_frog_lint.yaml"
14+
- "packages/dart_frog_lint/lib/**"
15+
- "packages/dart_frog_lint/pubspec.yaml"
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: 📚 Git Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: 🎯 Build
26+
uses: ./.github/actions/dart_package
27+
with:
28+
analyze_directories: lib
29+
run_tests: false # there aren't any tests since this is just a single yaml file.
30+
working_directory: packages/dart_frog_lint
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: publish/dart_frog_lint
2+
3+
on:
4+
push:
5+
tags:
6+
- "dart_frog_lint-v[0-9]+.[0-9]+.[0-9]+*"
7+
8+
jobs:
9+
publish:
10+
environment: pub.dev
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write # Required for authentication using OIDC
14+
15+
steps:
16+
- name: 📚 Git Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: 📦 Publish
20+
uses: ./.github/actions/pub_publish
21+
with:
22+
working_directory: packages/dart_frog_lint

packages/dart_frog_lint/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# See https://www.dartlang.org/guides/libraries/private-files
2+
3+
# Files and directories created by pub
4+
.dart_tool/
5+
.packages
6+
build/
7+
pubspec.lock
8+
9+
# Test related files
10+
coverage/

packages/dart_frog_lint/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 0.1.0
2+
3+
- feat: initial release 🎉

packages/dart_frog_lint/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Dart Frog Dev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/dart_frog_lint/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[<img src="https://raw.githubusercontent.com/dart-frog-dev/dart_frog/main/assets/dart_frog.png" align="left" height="63.5px" />](https://dart-frog.dev/)
2+
3+
### Dart Frog Lint
4+
5+
<br clear="left"/>
6+
7+
[![discord][discord_badge]][discord_link]
8+
[![dart][dart_badge]][dart_link]
9+
10+
[![ci][ci_badge]][ci_link]
11+
[![coverage][coverage_badge]][ci_link]
12+
[![pub package][pub_badge]][pub_link]
13+
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
14+
[![License: MIT][license_badge]][license_link]
15+
16+
A collection of lint rules built specifically for [Dart Frog][docs_link].
17+
18+
## Documentation 📝
19+
20+
For official documentation, please visit [dart-frog.dev][docs_link].
21+
22+
## Quick Start 🚀
23+
24+
1. Install `dart_frog_lint`
25+
26+
`dart pub add --dev dart_frog_lint`
27+
28+
1. Add an `analysis_options.yaml` to the root of your project with the recommended rules
29+
30+
```yaml
31+
include: package:dart_frog_lint/recommended.yaml
32+
```
33+
34+
[ci_badge]: https://github.com/dart-frog-dev/dart_frog/actions/workflows/dart_frog_lint.yaml/badge.svg?branch=main
35+
[ci_link]: https://github.com/dart-frog-dev/dart_frog/actions/workflows/dart_frog_lint.yaml
36+
[coverage_badge]: https://raw.githubusercontent.com/dart-frog-dev/dart_frog/main/packages/dart_frog_lint/coverage_badge.svg
37+
[dart_badge]: https://img.shields.io/badge/Dart-%230175C2.svg?style=for-the-badge&logo=dart&logoColor=5BB4F0&color=1E2833
38+
[dart_link]: https://dart.dev
39+
[discord_badge]: https://img.shields.io/discord/1394707782271238184?style=for-the-badge&logo=discord&color=1C2A2E&logoColor=1DF9D2
40+
[discord_link]: https://discord.gg/dart-frog
41+
[docs_link]: https://dart-frog.dev
42+
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
43+
[license_link]: https://opensource.org/licenses/MIT
44+
[logo_black]: https://raw.githubusercontent.com/dart-frog-dev/dart_frog/main/assets/dart_frog_logo_black.png#gh-light-mode-only
45+
[logo_white]: https://raw.githubusercontent.com/dart-frog-dev/dart_frog/main/assets/dart_frog_logo_white.png#gh-dark-mode-only
46+
[pub_badge]: https://img.shields.io/pub/v/dart_frog.svg
47+
[pub_link]: https://pub.dartlang.org/packages/dart_frog
48+
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
49+
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ./lib/recommended.yaml
23.4 KB
Loading
Lines changed: 20 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)