diff --git a/styles/Canonical/019-no-external-images.yml b/styles/Canonical/019-no-external-images.yml new file mode 100644 index 0000000..90ee35a --- /dev/null +++ b/styles/Canonical/019-no-external-images.yml @@ -0,0 +1,15 @@ +# 19 - No external images + +extends: existence +message: "Don't use images from Google Drive or the asset manager. Store images in the repository." +scope: raw +nonword: true +level: error +tokens: + - '!\[[^\n]*\]\([\w\.:\/\-=\? \"]+(drive.google|drive.usercontent.google|assets.ubuntu)[\w\.:\/\-=\? \"]+\)' + - '<[\w\.:\/-=? "]+(drive.google|drive.usercontent.google|assets.ubuntu)[\w\.:\/\-=? "]+>' + - '{image}[\w\.:\/\-=? "]+(drive.google|drive.usercontent.google|assets.ubuntu)[\w\.:\/\-=? "]+' + - '{figure}[\w\.:\/\-=? "]+(drive.google|drive.usercontent.google|assets.ubuntu)[\w\.:\/\-=? "]+' + - '\.\. image::[\w\.:\/\-=? "]+(drive.google|drive.usercontent.google|assets.ubuntu)[\w\.:\/\-=? "]+' + - '\.\. figure::[\w\.:\/\-=? "]+(drive.google|drive.usercontent.google|assets.ubuntu)[\w\.:\/\-=? "]+' + \ No newline at end of file diff --git a/styles/Canonical/019-no-google-drive-images.yml b/styles/Canonical/019-no-google-drive-images.yml deleted file mode 100644 index 2a5d905..0000000 --- a/styles/Canonical/019-no-google-drive-images.yml +++ /dev/null @@ -1,15 +0,0 @@ -# 19 - No Google Drive links - -extends: existence -message: "Don't use images from Google Drive. Use the asset manager." -scope: raw -nonword: true -level: error -tokens: - - '!\[[^\n]*\]\([\w\.:\/\-=\? \"]+(drive.google|drive.usercontent.google)[\w\.:\/\-=\? \"]+\)' - - '<[\w\.:\/-=? "]+(drive.google|drive.usercontent.google)[\w\.:\/\-=? "]+>' - - '{image}[\w\.:\/\-=? "]+(drive.google|drive.usercontent.google)[\w\.:\/\-=? "]+' - - '{figure}[\w\.:\/\-=? "]+(drive.google|drive.usercontent.google)[\w\.:\/\-=? "]+' - - '\.\. image::[\w\.:\/\-=? "]+(drive.google|drive.usercontent.google)[\w\.:\/\-=? "]+' - - '\.\. figure::[\w\.:\/\-=? "]+(drive.google|drive.usercontent.google)[\w\.:\/\-=? "]+' - diff --git a/tests/data/manifest.yml b/tests/data/manifest.yml index 5c7932b..f341393 100644 --- a/tests/data/manifest.yml +++ b/tests/data/manifest.yml @@ -416,14 +416,94 @@ rules: let value = 10; // Initialize value severity: suggestion # For 017, see the end of this file, as the content is long. - # 019-no-google-drive-images: - # cases: - # - id: valid - # filetypes: [md, rst] - # content: - # expect: - # triggers: - # severity: + 019-no-external-images: + cases: + - id: google-drive-md + filetypes: [md] + content: "![alt](https://drive.google.com/file/d/abc123)" + expect: + triggers: + - "![alt](https://drive.google.com/file/d/abc123)" + severity: error + - id: google-drive-rst-image + filetypes: [rst] + content: ".. image:: https://drive.google.com/file/d/abc123" + expect: + triggers: + - ".. image:: https://drive.google.com/file/d/abc123" + severity: error + - id: google-drive-rst-figure + filetypes: [rst] + content: ".. figure:: https://drive.google.com/file/d/abc123" + expect: + triggers: + - ".. figure:: https://drive.google.com/file/d/abc123" + severity: error + - id: asset-manager-md + filetypes: [md] + content: "![alt](https://assets.ubuntu.com/v1/abc123)" + expect: + triggers: + - "![alt](https://assets.ubuntu.com/v1/abc123)" + severity: error + - id: asset-manager-rst-image + filetypes: [rst] + content: ".. image:: https://assets.ubuntu.com/v1/abc123" + expect: + triggers: + - ".. image:: https://assets.ubuntu.com/v1/abc123" + severity: error + - id: asset-manager-rst-figure + filetypes: [rst] + content: ".. figure:: https://assets.ubuntu.com/v1/abc123" + expect: + triggers: + - ".. figure:: https://assets.ubuntu.com/v1/abc123" + severity: error + - id: asset-manager-myst-backtick-image + filetypes: [md] + content: "```{image} https://assets.ubuntu.com/v1/abc123" + expect: + triggers: + - "{image} https://assets.ubuntu.com/v1/abc123" + severity: error + - id: asset-manager-myst-colon-image + filetypes: [md] + content: ":::{image} https://assets.ubuntu.com/v1/abc123" + expect: + triggers: + - "{image} https://assets.ubuntu.com/v1/abc123" + severity: error + - id: asset-manager-myst-backtick-figure + filetypes: [md] + content: "```{figure} https://assets.ubuntu.com/v1/abc123" + expect: + triggers: + - "{figure} https://assets.ubuntu.com/v1/abc123" + severity: error + - id: asset-manager-myst-colon-figure + filetypes: [md] + content: ":::{figure} https://assets.ubuntu.com/v1/abc123" + expect: + triggers: + - "{figure} https://assets.ubuntu.com/v1/abc123" + severity: error + - id: local-image-md + filetypes: [md] + content: "![alt](images/local-image.png)" + expect: + triggers: [] + - id: local-image-rst + filetypes: [rst] + content: ".. image:: images/local-image.png" + expect: + triggers: [] + - id: local-image-myst + filetypes: [md] + content: "```{image} images/local-image.png" + expect: + triggers: [] + 025a-latinisms-with-english-equivalents: cases: - id: latin-terms-with-substitutions diff --git a/vale.ini b/vale.ini index 6c9da08..0e24831 100644 --- a/vale.ini +++ b/vale.ini @@ -25,7 +25,7 @@ Canonical.015-No-prompts-in-comments = warning Canonical.016-No-inline-comments = suggestion Canonical.017a-Suggest-code-over-25-lines = suggestion Canonical.017b-Warn-code-over-35-lines = warning -Canonical.019-no-google-drive-images = error +Canonical.019-no-external-images = error Canonical.025a-latinisms-with-english-equivalents = suggestion Canonical.025b-latinisms-to-reconsider = suggestion Canonical.025c-latinisms-to-avoid = suggestion