0.3.0 ā¢ Published 3 years ago
@mapbox/docs-file-lint v0.3.0
@mapbox/docs-file-lint
Tests to assert files in docs repositories.
Install
$ npm install @mapbox/docs-file-lint --global
Checks
docs-file-lint checks the following files:
- All
mp4
files are less than 2 MB. (See #configuration for how to change this limit.) - All
gif
files are less than 1 MB. (See #configuration for how to change this limit.) - No
png
,jpg
, orjpeg
files are in the Batfish pages directory. - No
mp4
orgif
files in the AppropriateImages directory. - Find unused assets.
Ignoring files
.docs-file-lintignore
To prevent files from being found, add a file named .docs-file-lintignore
in the root of the repository. The format of this file is similar to .eslintignore
(which in turn is similar to .gitignore
files)
src/pages/necessary-video.mp4
Configuration
You can control docs-file-lint through .docs-file-lintrc
configuration files:
{
"allow": ["large-gif"]
}
Options
- The
allow
field should be an array of rules orundefined
(the default isundefined
). When provided, the rules specified are skipped and not reported. - The
videoLimit
field is a number to override the current video limit size (in MB). - The
gifLimit
field is a number to override the current gif limit size (in MB). - The
pagesDir
field is the path to the Batfish page's directory. Default issrc/pages/
. - The
imgSrcDir
field is the path to the directory where all raw AppropriateImages files are stored. Default issrc/img/src/
.
CLI
From the root of this repository, running
$ docs-file-lint test
Yields:
test/pages/cool.png: no issues found
test/src/img/src/fail.gif
1:1 error This file cannot be parsed by AppropriateImage, move it to `src/pages/`. misplaced-gif gif
test/src/img/src/fail.mp4
1:1 error This file cannot be parsed by AppropriateImage, move it to `src/pages/`. misplaced-video gif
test/src/img/src/ok.png: no issues found
test/src/pages/fail.gif
1:1 error This file is 4.6 MB it must be less than 1 MB. Reshoot it as a video or compress it using a tool like compressor.io. large-gif gif
test/src/pages/fail.png
1:1 error This file must use AppropriateImages to improve performance. Move it to `src/img/src/`. use-appropriate-images pages-check
test/src/pages/ok.gif: no issues found
test/src/pages/ok.mp4: no issues found
test/src/videos/fail.mp4
1:1 error This file is 2.1 MB it must be less than 2 MB. Follow the video compression guidelines: https://github.com/mapbox/documentation/blob/hey-pages/docs/video-compression.md. large-video videos
ā 5 errors
See $ docs-file-lint --help
for more information.