Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'ignore-suffixes' option to input #96

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ For more information on these inputs, see the [Workflow syntax for GitHub Action
- `fail-on-warnings`: The action fails if any warning was found. This will always fail on errors. Optional. Default: `false`
- `working-directory`: The working directory. Optional. Default: `./`
- `line-length`: The maximum line length. Optional. The formatter will use its default: `80`
- `ignore-suffixes`: Ignore the specified suffix, split multi suffixes with `|`

### Outputs
None.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
default: ./
line-length:
description: 'The maximum line length. Optional. The formatter will use its default: `80`'
ignore-suffixes:
description: 'Ignore the specified suffix, split multi suffixes with `|`'
default: '.g.dart|.freezed.dart'

runs:
using: 'node20'
main: 'dist/index.js'
Expand Down
5 changes: 4 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ async function format(workingDirectory) {
args.push('.');

await exec.exec('dart', args, options);

let warningCount = 0;
const lines = output.trim().split(/\r?\n/);

const ignoreSuffixes = core.getInput("ignore-suffixes").split("|");

for (const line of lines) {
if (!line.endsWith('.dart')) continue;
if (ignoreSuffixes.some(e => line.endsWith(e))) continue;
const file = line.substring(8); // Remove the "Changed " prefix

console.log(`::warning file=${file}::Invalid format. For more details, see https://dart.dev/guides/language/effective-dart/style#formatting`);
Expand Down