diff --git a/doc/development/contributing/style_guides.md b/doc/development/contributing/style_guides.md index aad24663118b82f58336f954fc6de9c9047e99ed..444a067a780d962cd2723f43e21ba341533f4ee4 100644 --- a/doc/development/contributing/style_guides.md +++ b/doc/development/contributing/style_guides.md @@ -56,7 +56,7 @@ The current Lefthook configuration can be found in [`lefthook.yml`](https://gitl Before you push your changes, Lefthook automatically runs the following checks: - Danger: Runs a subset of checks that `danger-review` runs on your merge requests. -- ES lint: Run `yarn run internal:eslint` checks (with the [`.eslintrc.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.eslintrc.yml) configuration) on the modified `*.{js,vue}` files. Tags: `frontend`, `style`. +- ES lint: Run `yarn run lint:eslint` checks (with the [`.eslintrc.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.eslintrc.yml) configuration) on the modified `*.{js,vue}` files. Tags: `frontend`, `style`. - HAML lint: Run `bundle exec haml-lint` checks (with the [`.haml-lint.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.haml-lint.yml) configuration) on the modified `*.html.haml` files. Tags: `view`, `haml`, `style`. - Markdown lint: Run `yarn markdownlint` checks on the modified `*.md` files. Tags: `documentation`, `style`. - SCSS lint: Run `yarn lint:stylelint` checks (with the [`.stylelintrc`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.stylelintrc) configuration) on the modified `*.scss{,.css}` files. Tags: `stylesheet`, `css`, `style`. diff --git a/doc/development/fe_guide/style/javascript.md b/doc/development/fe_guide/style/javascript.md index 87054f7db86c7a12bc16215ad9846f06c4ba85b2..460d8f583129b1f28c5dcaad9947c50f67ad4ef9 100644 --- a/doc/development/fe_guide/style/javascript.md +++ b/doc/development/fe_guide/style/javascript.md @@ -14,7 +14,7 @@ In addition to the style guidelines set by Airbnb, we also have a few specific r listed below. NOTE: -You can run ESLint locally by running `yarn run lint:eslint` +You can run ESLint locally by running `yarn run lint:eslint:all` or `yarn run lint:eslint $PATH_TO_FILE`. ## Avoid forEach diff --git a/doc/development/fe_guide/tooling.md b/doc/development/fe_guide/tooling.md index c493ab9a206edf83e1bb56d42efa1e96575491ff..1ab97d8a1f5932cfd377c0568142498074e721b6 100644 --- a/doc/development/fe_guide/tooling.md +++ b/doc/development/fe_guide/tooling.md @@ -30,10 +30,16 @@ yarn run lint:eslint:staged:fix If manual changes are required, a list of changes are sent to the console. +To check a specific file in the repository with ESLINT, run the following script (replacing $PATH_TO_FILE): + +```shell +yarn run lint:eslint $PATH_TO_FILE +``` + To check **all** files in the repository with ESLint, run the following script: ```shell -yarn run lint:eslint +yarn run lint:eslint:all ``` A list of problems found are logged to the console. @@ -41,7 +47,7 @@ A list of problems found are logged to the console. To apply automatic ESLint fixes to **all** files in the repository, run the following script: ```shell -yarn run lint:eslint:fix +yarn run lint:eslint:all:fix ``` If manual changes are required, a list of changes are sent to the console. diff --git a/lefthook.yml b/lefthook.yml index f6e3fb68b0e9e2332a85aab21fe67fe73f96e170..8791cf612310cee647fec0ef2277afef5d7db792 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -7,7 +7,7 @@ pre-push: tags: frontend style files: git diff --name-only $(git merge-base origin/master HEAD)..HEAD glob: "*.{js,vue}" - run: yarn run internal:eslint {files} + run: yarn run lint:eslint {files} haml-lint: tags: view haml style files: git diff --name-only $(git merge-base origin/master HEAD)..HEAD diff --git a/lib/tasks/eslint.rake b/lib/tasks/eslint.rake index 35c3e834258784ca18a5961204b8479a90d33cd5..529f17d4d27a8210bb857eb6cbd5ba5acde06f6b 100644 --- a/lib/tasks/eslint.rake +++ b/lib/tasks/eslint.rake @@ -3,7 +3,7 @@ unless Rails.env.production? desc "GitLab | Run ESLint" task eslint: ['yarn:check'] do - unless system('yarn run lint:eslint') + unless system('yarn run lint:eslint:all') abort('rake eslint failed') end end diff --git a/package.json b/package.json index 7814aa04964c7bf97e1fc5ccf82cbe9ae059e6f5..1860e87b07039174b7be26a6f4c9f901ecd8627f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "block-dependencies": "node scripts/frontend/block_dependencies.js", "clean": "rm -rf public/assets tmp/cache/*-loader", "dev-server": "NODE_OPTIONS=\"--max-old-space-size=3584\" node scripts/frontend/webpack_dev_server.js", - "eslint-fix": "echo 'Please use `yarn lint:eslint:fix` instead' && exit 1", + "eslint-fix": "echo 'Please use `yarn lint:eslint:all:fix` instead' && exit 1", "eslint-staged": "echo 'Please use `yarn lint:eslint:staged` instead' && exit 1", "eslint-staged-fix": "echo 'Please use `yarn lint:eslint:staged:fix` instead' && exit 1", "eslint-report": "echo 'Please use `yarn lint:eslint:report` instead' && exit 1", @@ -21,8 +21,10 @@ "karma": "BABEL_ENV=${BABEL_ENV:=karma} karma start --single-run true config/karma.config.js", "karma-coverage": "BABEL_ENV=coverage karma start --single-run true config/karma.config.js", "karma-start": "BABEL_ENV=karma karma start config/karma.config.js", - "lint:eslint": "yarn run internal:eslint .", - "lint:eslint:fix": "yarn run lint:eslint --fix", + "lint:eslint": "yarn run internal:eslint", + "lint:eslint:fix": "yarn run internal:eslint --fix", + "lint:eslint:all": "yarn run internal:eslint .", + "lint:eslint:all:fix": "yarn run lint:eslint:all --fix", "lint:eslint:report": "yarn run internal:eslint --format html --output-file ./eslint-report.html --no-inline-config .", "lint:eslint:staged": "scripts/frontend/execute-on-staged-files.sh internal:eslint '(js|vue)'", "lint:eslint:staged:fix": "yarn run lint:eslint:staged --fix", diff --git a/scripts/static-analysis b/scripts/static-analysis index f0134b3df183e62bfbcbc3e232d30e85e39dd84e..2442455e6309978d1ec01d95006d8222e198bbc9 100755 --- a/scripts/static-analysis +++ b/scripts/static-analysis @@ -25,7 +25,7 @@ class StaticAnalysis # Most of the time, RuboCop finishes in 30 seconds, but sometimes it can take around 1200 seconds so we set a # duration of 300 to lower the likelihood that it will run in the same job as another long task... %w[bundle exec rubocop --parallel] => 300, - %w[yarn run lint:eslint] => 197, + %w[yarn run lint:eslint:all] => 197, %w[yarn run lint:prettier] => 124, %w[bin/rake gettext:lint] => 96, %w[bundle exec license_finder] => 49,