From d39bce963f0a48d9349101828776fd280a1e11c5 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Wed, 31 May 2023 20:25:13 -0400 Subject: [PATCH] Add fix/lint helper dev targets (#23561) --- .github/workflows/lint-css.yml | 2 +- .github/workflows/lint-js.yml | 4 ++-- .github/workflows/lint-json.yml | 2 +- .github/workflows/lint-md.yml | 5 ++++- .github/workflows/lint-yml.yml | 2 +- .github/workflows/test-js.yml | 2 +- package.json | 29 ++++++++++++++++++----------- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.github/workflows/lint-css.yml b/.github/workflows/lint-css.yml index e13d227bdb..51bde39bc1 100644 --- a/.github/workflows/lint-css.yml +++ b/.github/workflows/lint-css.yml @@ -48,4 +48,4 @@ jobs: - run: echo "::add-matcher::.github/stylelint-matcher.json" - name: Stylelint - run: yarn test:lint:sass + run: yarn lint:sass diff --git a/.github/workflows/lint-js.yml b/.github/workflows/lint-js.yml index 7700e48512..547035ab3f 100644 --- a/.github/workflows/lint-js.yml +++ b/.github/workflows/lint-js.yml @@ -48,7 +48,7 @@ jobs: run: yarn --frozen-lockfile - name: ESLint - run: yarn test:lint:js --max-warnings 0 + run: yarn lint:js --max-warnings 0 - name: Typecheck - run: yarn test:typecheck + run: yarn typecheck diff --git a/.github/workflows/lint-json.yml b/.github/workflows/lint-json.yml index 98f101ad95..7dfc0e0588 100644 --- a/.github/workflows/lint-json.yml +++ b/.github/workflows/lint-json.yml @@ -40,4 +40,4 @@ jobs: run: yarn --frozen-lockfile - name: Prettier - run: yarn prettier --check "**/*.json" + run: yarn lint:json diff --git a/.github/workflows/lint-md.yml b/.github/workflows/lint-md.yml index 6f76dd60c2..b489ce9684 100644 --- a/.github/workflows/lint-md.yml +++ b/.github/workflows/lint-md.yml @@ -5,6 +5,7 @@ on: - 'dependabot/**' paths: - '.github/workflows/lint-md.yml' + - '.nvmrc' - '.prettier*' - '**/*.md' - '!AUTHORS.md' @@ -14,6 +15,7 @@ on: pull_request: paths: - '.github/workflows/lint-md.yml' + - '.nvmrc' - '.prettier*' - '**/*.md' - '!AUTHORS.md' @@ -32,9 +34,10 @@ jobs: uses: actions/setup-node@v3 with: cache: yarn + node-version-file: '.nvmrc' - name: Install all yarn packages run: yarn --frozen-lockfile - name: Prettier - run: yarn prettier --check "**/*.md" + run: yarn lint:md diff --git a/.github/workflows/lint-yml.yml b/.github/workflows/lint-yml.yml index 6f79babcfd..d77451ee62 100644 --- a/.github/workflows/lint-yml.yml +++ b/.github/workflows/lint-yml.yml @@ -42,4 +42,4 @@ jobs: run: yarn --frozen-lockfile - name: Prettier - run: yarn prettier --check "**/*.{yml,yaml}" + run: yarn lint:yml diff --git a/.github/workflows/test-js.yml b/.github/workflows/test-js.yml index 1c4958550e..32e21d23ce 100644 --- a/.github/workflows/test-js.yml +++ b/.github/workflows/test-js.yml @@ -44,4 +44,4 @@ jobs: run: yarn --frozen-lockfile - name: Jest testing - run: yarn test:jest --reporters github-actions summary + run: yarn jest --reporters github-actions summary diff --git a/package.json b/package.json index c299bd509b..b71f1dff42 100644 --- a/package.json +++ b/package.json @@ -5,21 +5,28 @@ "node": ">=16" }, "scripts": { - "postversion": "git push --tags", "build:development": "cross-env RAILS_ENV=development NODE_ENV=development ./bin/webpack", "build:production": "cross-env RAILS_ENV=production NODE_ENV=production ./bin/webpack", - "manage:translations": "node ./config/webpack/translationRunner.js", + "fix:js": "yarn lint:js --fix", + "fix:json": "prettier --write \"**/*.json\"", + "fix:md": "prettier --write \"**/*.md\"", + "fix:sass": "stylelint --fix \"**/*.{css,scss}\" && prettier --write \"**/*.{css,scss}\"", + "fix:yml": "prettier --write \"**/*.{yaml,yml}\"", + "fix": "yarn fix:js && yarn fix:json && yarn fix:sass && yarn fix:yml", "i18n:extract": "formatjs extract 'app/javascript/**/*.{js,jsx,ts,tsx}' '--ignore=**/*.d.ts' --out-file app/javascript/mastodon/locales/en.json --format config/formatjs-formatter.js", + "jest": "cross-env NODE_ENV=test jest", + "lint:js": "eslint . --ext=.js,.jsx,.ts,.tsx --cache --report-unused-disable-directives", + "lint:json": "prettier --check \"**/*.json\"", + "lint:md": "prettier --check \"**/*.md\"", + "lint:sass": "stylelint \"**/*.{css,scss}\" && prettier --check \"**/*.{css,scss}\"", + "lint:yml": "prettier --check \"**/*.{yaml,yml}\"", + "lint": "yarn lint:js && yarn lint:json && yarn lint:sass && yarn lint:yml", + "manage:translations": "node ./config/webpack/translationRunner.js", + "postversion": "git push --tags", + "prepare": "husky install", "start": "node ./streaming/index.js", - "test": "${npm_execpath} run test:lint:js && ${npm_execpath} run test:typecheck && ${npm_execpath} run test:jest", - "test:lint": "${npm_execpath} run test:lint:js && ${npm_execpath} run test:lint:sass", - "test:lint:js": "eslint --ext=.js,.jsx,.ts,.tsx . --cache --report-unused-disable-directives", - "test:lint:sass": "stylelint \"**/*.{css,scss}\" && prettier --check \"**/*.{css,scss}\"", - "test:typecheck": "tsc --noEmit", - "test:jest": "cross-env NODE_ENV=test jest", - "format": "prettier --write .", - "format-check": "prettier --check .", - "prepare": "husky install" + "test": "yarn lint && yarn run typecheck && yarn jest", + "typecheck": "tsc --noEmit" }, "repository": { "type": "git",