Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Update universal lint

Dhruv Bhanushali61b4c23c4070
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 000000000..e69de29bb
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 1e5b2f64a..bf7bbb5fa 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,10 +1,22 @@
# This file is being synced from WordPress/openverse. Any changes made to it
# here will be overwritten. Please make any necessary edits to these files:
-# - https://github.com/WordPress/openverse/blob/main/.pre-commit-config.yaml.jinja
+# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.yaml.jinja
+# - https://github.com/WordPress/openverse/blob/main/templates/.pre-commit-config.local.yaml.jinja
exclude: Pipfile\.lock|migrations|\.idea|node_modules|archive|retired
repos:
+ - repo: local # More local hooks are defined at the bottom.
+ hooks:
+ - id: i18n
+ name: i18n
+ files: ^frontend/.*$
+ # Check if the i18n files have been downloaded by checking if the Arabic translation exists
+ # Download the i18n files if they do not exist
+ entry: bash -c 'if [ ! -f "$(dirname "$dir")"/frontend/src/locales/ar.json ]; then just frontend/run i18n; fi'
+ language: system
+ pass_filenames: false
+
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
@@ -19,7 +31,7 @@ repos:
- id: check-xml
- id: check-yaml
- id: end-of-file-fixer
- exclude: test/tapes/.+\.json5
+ exclude: frontend/test/tapes/.+\.json5
- id: check-symlinks
- id: mixed-line-ending
- id: fix-encoding-pragma
@@ -78,6 +90,35 @@ repos:
# https://www.pydocstyle.org/en/6.2.3/error_codes.html#error-codes
- --add-ignore=D1,D202,D205,D211,D400
+ - repo: https://github.com/pre-commit/mirrors-eslint
+ rev: v8.15.0
+ hooks:
+ - id: eslint
+ files: \.(js|ts|vue)$
+ exclude: ^load_testing/.*|frontend/(nuxt-template-overrides/.*|.remake/.*)$ # ESLint raises warnings for ignored files.
+ "types": [file] # ESLint only accepts [javascript] by default.
+ args:
+ - --ignore-path=.gitignore
+ - --ignore-path=.eslintignore
+ - --max-warnings=0
+ additional_dependencies:
+ - "@babel/[email protected]"
+ - "@intlify/[email protected]"
+ - "@nuxtjs/[email protected]"
+ - "@typescript-eslint/[email protected]"
+ - "@typescript-eslint/[email protected]"
+
# Use the `.prettierignore` and `.prettier.config.js` files to configure project-specific requirements.
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.0
@@ -85,8 +126,45 @@ repos:
- id: prettier
additional_dependencies:
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.8.0
hooks:
- id: shellcheck
+
+ - repo: local # More local hooks are defined at the top.
+ hooks:
+ - id: types
+ name: types
+ files: ^frontend/.*$
+ entry: bash -c 'just frontend/run types'
+ language: system
+ pass_filenames: false
+ - id: test:unit
+ name: test:unit
+ files: ^frontend/.*$
+ entry: bash -c 'just frontend/run test:unit'
+ language: system
+ pass_filenames: false
+ stages:
+ - push
+ - id: render-precommit
+ name: render-precommit
+ files: ^templates/.*$
+ entry: bash -c 'just automations/js/render-precommit'
+ language: system
+ pass_filenames: false
+ - id: render-prettier
+ name: render-prettier
+ files: ^templates/.*$
+ entry: bash -c 'just automations/js/render-prettier'
+ language: system
+ pass_filenames: false
+ - id: render-github
+ name: render-github
+ files: ^templates/.*$
+ entry: bash -c 'just automations/js/render-github'
+ language: system
+ pass_filenames: false
diff --git a/prettier.config.js b/prettier.config.js
index 0a79e738b..8e8b2e5d5 100644
--- a/prettier.config.js
+++ b/prettier.config.js
@@ -1,6 +1,7 @@
// This file is being synced from WordPress/openverse. Any changes made to it
// here will be overwritten. Please make any necessary edits to these files:
-// - https://github.com/WordPress/openverse/blob/main/prettier.config.js.jinja
+// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.js.jinja
+// - https://github.com/WordPress/openverse/blob/main/templates/prettier.config.local.js.jinja
module.exports = {
trailingComma: "es5",
@@ -15,5 +16,13 @@ module.exports = {
proseWrap: "preserve",
},
},
+ {
+ files: ["frontend/**/*"],
+ options: {
+ plugins: [require("prettier-plugin-tailwindcss")],
+ tailwindConfig: "frontend/tailwind.config.js",
+ vueIndentScriptAndStyle: false,
+ },
+ },
],
}