aotds-docks/scripts/eslint

37 lines
521 B
Plaintext
Raw Normal View History

2020-07-19 20:21:28 +00:00
#!/usr/bin/env perl
use strict;
# check by default
my @mode;
my @files = grep {
$_ ne '--fix'or not (@mode = ('--fix'));
} @ARGV;
@files = qw/ src / unless @files;
my @ignore = (
qr/\.map$/,
qr!^docs/!,
qr/\.(css|html|md)$/,
qr/package\.(json|yaml)/,
qr#^scripts/#,
qr#^\.#,
qr#\.json$#
);
sub ignored {
my $file = shift;
for my $pattern ( @ignore ) {
return 1 if $file =~ $pattern;
}
return 0;
}
exec 'eslint', @mode, grep {
not ignored($_)
} @files;