diff --git a/.prettierignore b/.prettierignore index c3972d46..24cc5695 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,6 +13,7 @@ LICENSE /locale/ /node_modules/ /tests/fixtures/ +/coverage/ # white-list files we want to process !*.js diff --git a/.prettierrc b/.prettierrc index f923252f..d6b27744 100644 --- a/.prettierrc +++ b/.prettierrc @@ -15,6 +15,12 @@ "options": { "parser": "babel" } + }, + { + "files": "*.md", + "options": { + "proseWrap": "preserve" + } } ] } diff --git a/.travis.yml b/.travis.yml index 73b43918..5475d34b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ script: - npm run lint # run integration tests using an addons-linter binary in a production-like environment - npm run test-integration:production + - npm run prettier-ci notifications: slack: if: branch = master diff --git a/README.md b/README.md index c03eb397..2177f6fe 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ Dependencies are automatically kept up-to-date using [renovatebot](https://renov | npm run test-coverage-once | Runs the tests once with coverage | | npm run test-integration-linter | Runs our integration test-suite | | npm run prettier | Automatically format the whole code-base with Prettier | +| npm run prettier-ci | Run [Prettier][] and fail if some code has been changed without being formatted | | npm run prettier-dev | Automatically compare and format modified source files against the master branch | ### Building @@ -221,3 +222,4 @@ After merging the PR, [create a new release][new release] with the same tag name [new release]: https://github.com/mozilla/addons-linter/releases/new [semver]: http://semver.org/ +[prettier]: https://prettier.io/ diff --git a/docs/rules.md b/docs/rules.md index c4cb7ca5..ffdd5ec5 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -6,26 +6,26 @@ Rules are sorted by severity. ## JavaScript -| Message code | Severity | Description | -| -------------------------- | -------- | -------------------------------------------------------------------------------------- | -| `KNOWN_LIBRARY` | notice | This is version of a JS library is known and generally accepted. | -| `OPENDIALOG_NONLIT_URI` | notice | openDialog called with non-literal parameter. | -| `EVENT_LISTENER_FOURTH` | notice | `addEventListener` called with truthy fourth argument. | -| `UNEXPECTED_GLOGAL_ARG` | warning | Unexpected global passed as an argument. | -| `NO_IMPLIED_EVAL` | warning | disallow the use of `eval()`-like methods. | -| `OPENDIALOG_REMOTE_URI` | warning | openDialog called with non-local URI. | -| `NO_DOCUMENT_WRITE` | warning | Use of `document.write` strongly discouraged. | -| `JS_SYNTAX_ERROR` | warning | JavaScript compile-time error. | -| `UNADVISED_LIBRARY` | warning | This version of a JS library is not recommended. | -| `DEPRECATED_API` | warning | API is deprecated. | -| `STORAGE_SYNC` | warning | Temporary IDs can cause issues with `storage.sync`. | -| `STORAGE_MANAGED` | warning | Temporary IDs can cause issues with `storage.managed`. | -| `IDENTITY_GETREDIRECTURL` | warning | Temporary IDs can cause issues with `identity.getRedirectURL`. | -| `RUNTIME_ONMESSAGEEXTERNAL`| warning | Temporary IDs can cause issues with `runtime.onMessageExternal`. | -| `RUNTIME_ONCONNECTEXTERNAL`| warning | Temporary IDs can cause issues with `runtime.onConnectExternal`. | -| `BANNED_LIBRARY` | error | This version of a JS library is banned for security reasons. | -| `INCOMPATIBLE_API` | warning | API not compatible with `applications.gecko.strict_min_version` | -| `ANDROID_INCOMPATIBLE_API` | warning | API not compatible with Firefox for Android at `applications.gecko.strict_min_version` | +| Message code | Severity | Description | +| --------------------------- | -------- | -------------------------------------------------------------------------------------- | +| `KNOWN_LIBRARY` | notice | This is version of a JS library is known and generally accepted. | +| `OPENDIALOG_NONLIT_URI` | notice | openDialog called with non-literal parameter. | +| `EVENT_LISTENER_FOURTH` | notice | `addEventListener` called with truthy fourth argument. | +| `UNEXPECTED_GLOGAL_ARG` | warning | Unexpected global passed as an argument. | +| `NO_IMPLIED_EVAL` | warning | disallow the use of `eval()`-like methods. | +| `OPENDIALOG_REMOTE_URI` | warning | openDialog called with non-local URI. | +| `NO_DOCUMENT_WRITE` | warning | Use of `document.write` strongly discouraged. | +| `JS_SYNTAX_ERROR` | warning | JavaScript compile-time error. | +| `UNADVISED_LIBRARY` | warning | This version of a JS library is not recommended. | +| `DEPRECATED_API` | warning | API is deprecated. | +| `STORAGE_SYNC` | warning | Temporary IDs can cause issues with `storage.sync`. | +| `STORAGE_MANAGED` | warning | Temporary IDs can cause issues with `storage.managed`. | +| `IDENTITY_GETREDIRECTURL` | warning | Temporary IDs can cause issues with `identity.getRedirectURL`. | +| `RUNTIME_ONMESSAGEEXTERNAL` | warning | Temporary IDs can cause issues with `runtime.onMessageExternal`. | +| `RUNTIME_ONCONNECTEXTERNAL` | warning | Temporary IDs can cause issues with `runtime.onConnectExternal`. | +| `BANNED_LIBRARY` | error | This version of a JS library is banned for security reasons. | +| `INCOMPATIBLE_API` | warning | API not compatible with `applications.gecko.strict_min_version` | +| `ANDROID_INCOMPATIBLE_API` | warning | API not compatible with Firefox for Android at `applications.gecko.strict_min_version` | ## Markup diff --git a/package.json b/package.json index b9ec0849..5ea3cc8b 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "test-integration:production": "node tests/integration/run-as-production-env.js test-integration tests/integration/addons-linter", "lint": "npm run eslint", "prettier": "prettier --write '**'", + "prettier-ci": "prettier --list-different '**' || (echo '\n\nThis failure means you did not run `npm run prettier-dev` before committing\n\n' && exit 1)", "prettier-dev": "pretty-quick --branch master", "publish-rules": "scripts/build-rules && cp node_modules/gfm.css/gfm.css docs/html/gfm.css && scripts/publish-rules", "gen-contributing-toc": "doctoc CONTRIBUTING.md"