Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for eslint v9 #1779

Merged
merged 23 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 13 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ jobs:
uses: ./
with:
path: "test-app"
config_path: ".eslintrc.js"
config_path: "eslint.config.mjs"
file_extensions: |
**/*.ts
**/*.tsx
extra_args: "--max-warnings=0"
ignore_path: ".eslintignore"
ignore_patterns: "src/reportWebVitals.ts"

- name: Fix Lint Errors
if: failure()
Expand All @@ -64,13 +64,13 @@ jobs:
uses: ./
with:
path: "test-app"
config_path: ".eslintrc.js"
config_path: "eslint.config.mjs"
file_extensions: |
**/*.ts
**/*.tsx
extra_args: "--fix"
ignore_path: ".eslintignore"
skip_annotations: true
ignore_patterns: "src/reportWebVitals.ts"

- name: Verify Changed files
if: failure()
Expand Down Expand Up @@ -98,6 +98,8 @@ jobs:

eslint-changed-files:
runs-on: ${{ matrix.platform }}
needs:
- lint
strategy:
fail-fast: false
matrix:
Expand All @@ -119,61 +121,33 @@ jobs:
- name: Install dependencies
run: yarn
working-directory: test-app

- name: Run ESLint for a nested project with changed files and .eslintignore
uses: ./
with:
path: "test-app"
config_path: ".eslintrc.js"
file_extensions: |
**/*.ts
**/*.tsx
extra_args: "--max-warnings=0"
ignore_path: ".eslintignore"

- name: Run ESLint on changed files with .eslintignore
uses: ./
with:
config_path: "test-app/.eslintrc.js"
file_extensions: |
**/*.ts
**/*.tsx
extra_args: "--max-warnings=0"
ignore_path: "test-app/.eslintignore"

- name: Run ESLint on all files with .eslintignore
uses: ./
with:
config_path: "test-app/.eslintrc.js"
file_extensions: |
**/*.ts
**/*.tsx
extra_args: "--max-warnings=0"
all_files: true
ignore_path: "test-app/.eslintignore"

- name: Run ESLint on changed files
uses: ./
with:
config_path: "test-app/.eslintrc.js"
path: "test-app"
config_path: "eslint.config.mjs"
file_extensions: |
**/*.ts
**/*.tsx
extra_args: "--max-warnings=0"
ignore_patterns: "src/reportWebVitals.ts"

- name: Run ESLint on all files
uses: ./
with:
config_path: "test-app/.eslintrc.js"
path: "test-app"
config_path: "eslint.config.mjs"
file_extensions: |
**/*.ts
**/*.tsx
extra_args: "--max-warnings=0"
all_files: true

- name: Run ESLint on all files without a config_path
- name: Run ESLint on all files without a config_path on all files
uses: ./
with:
path: "test-app"
file_extensions: |
**/*.ts
**/*.tsx
Expand Down
14 changes: 7 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ inputs:
all_files:
description: "Run [ESlint](https://eslint.org) on all matching files."
required: false
default: false
default: 'false'
config_path:
description: "[ESlint](https://eslint.org/) [configuration file](https://eslint.org/docs/user-guide/configuring/). Optionally omit this input for Mono repositories."
description: "[ESLint](https://eslint.org/) [configuration file](https://eslint.org/docs/user-guide/configuring/). Optionally omit this input for Mono repositories."
required: false
default: ''
ignore_path:
description: "[ESlint](https://eslint.org/) [ignore file](https://eslint.org/docs/user-guide/configuring/ignoring-code)"
ignore_patterns:
description: "[ESLint](https://eslint.org/docs/latest/use/configure/ignore) [configuration file](https://eslint.org/docs/latest/use/configure/ignore#ignoring-files) ignores key. Optionally ignore files in the `ignores` key from being passed to ESLint not required when `all_files` is set to `true`."
required: false
default: ''
file_extensions:
Expand All @@ -30,7 +30,7 @@ inputs:
skip_annotations:
description: "Skip running reviewdog i.e don't add any annotations."
required: false
default: false
default: 'false'
level:
description: "Report level for reviewdog (info,warning,error)"
required: false
Expand Down Expand Up @@ -78,10 +78,11 @@ runs:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
if: inputs.all_files == 'false'
with:
path: ${{ inputs.path }}
files: ${{ inputs.file_extensions }}
files_ignore_from_source_file: ${{ inputs.ignore_path }}
files_ignore: ${{ inputs.ignore_patterns }}
diff_relative: true
skip_initial_fetch: ${{ inputs.skip_initial_fetch }}
use_rest_api: ${{ inputs.use_rest_api }}
Expand All @@ -105,7 +106,6 @@ runs:
INPUT_LEVEL: ${{ inputs.level }}
INPUT_ALL_FILES: ${{ inputs.all_files }}
INPUT_CONFIG_PATH: ${{ inputs.config_path }}
INPUT_IGNORE_PATH: ${{ inputs.ignore_path }}
INPUT_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
INPUT_EXTRA_ARGS: ${{ inputs.extra_args }}
INPUT_FILTER_MODE: ${{ inputs.filter_mode }}
Expand Down
25 changes: 4 additions & 21 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ if [[ "$INPUT_SKIP_ANNOTATIONS" != "true" ]]; then
export REVIEWDOG_GITHUB_API_TOKEN=$INPUT_TOKEN
fi

IGNORE_PATH=$INPUT_IGNORE_PATH
EXTRA_ARGS=$INPUT_EXTRA_ARGS
CONFIG_ARG=""

Expand All @@ -35,19 +34,11 @@ if [[ -n "$INPUT_CONFIG_PATH" ]]; then
fi

if [[ "$INPUT_ALL_FILES" == "true" ]]; then
echo "Running ESlint on all files..."
echo "Running ESLint on all files..."
if [[ "$INPUT_SKIP_ANNOTATIONS" == "true" ]]; then
echo "Skipping annotations..."
if [[ -n ${IGNORE_PATH} ]]; then
# shellcheck disable=SC2086
npx eslint ${CONFIG_ARG} --ignore-path="${IGNORE_PATH}" ${EXTRA_ARGS} && exit_status=$? || exit_status=$?
else
# shellcheck disable=SC2086
npx eslint ${CONFIG_ARG} ${EXTRA_ARGS} && exit_status=$? || exit_status=$?
fi
elif [[ -n ${IGNORE_PATH} ]]; then
# shellcheck disable=SC2086
npx eslint ${CONFIG_ARG} --ignore-path="${IGNORE_PATH}" ${EXTRA_ARGS} -f="${ESLINT_FORMATTER}" . > "$RD_JSON_FILE" && exit_status=$? || exit_status=$?
npx eslint ${CONFIG_ARG} ${EXTRA_ARGS} && exit_status=$? || exit_status=$?
else
# shellcheck disable=SC2086
npx eslint ${CONFIG_ARG} ${EXTRA_ARGS} -f="${ESLINT_FORMATTER}" . > "$RD_JSON_FILE" && exit_status=$? || exit_status=$?
Expand All @@ -70,19 +61,11 @@ if [[ "$INPUT_ALL_FILES" == "true" ]]; then
fi
else
if [[ -n "${INPUT_CHANGED_FILES[*]}" ]]; then
echo "Running ESlint on changed files..."
echo "Running ESLint on changed files..."
if [[ "$INPUT_SKIP_ANNOTATIONS" == "true" ]]; then
echo "Skipping annotations..."
if [[ -n ${IGNORE_PATH} ]]; then
# shellcheck disable=SC2086
npx eslint ${CONFIG_ARG} --ignore-path="${IGNORE_PATH}" ${EXTRA_ARGS} ${INPUT_CHANGED_FILES} && exit_status=$? || exit_status=$?
else
# shellcheck disable=SC2086
npx eslint ${CONFIG_ARG} ${EXTRA_ARGS} ${INPUT_CHANGED_FILES} && exit_status=$? || exit_status=$?
fi
elif [[ -n ${IGNORE_PATH} ]]; then
# shellcheck disable=SC2086
npx eslint ${CONFIG_ARG} --ignore-path="${IGNORE_PATH}" ${EXTRA_ARGS} -f="${ESLINT_FORMATTER}" ${INPUT_CHANGED_FILES} > "$RD_JSON_FILE" && exit_status=$? || exit_status=$?
npx eslint ${CONFIG_ARG} ${EXTRA_ARGS} ${INPUT_CHANGED_FILES} && exit_status=$? || exit_status=$?
else
# shellcheck disable=SC2086
npx eslint ${CONFIG_ARG} ${EXTRA_ARGS} -f="${ESLINT_FORMATTER}" ${INPUT_CHANGED_FILES} > "$RD_JSON_FILE" && exit_status=$? || exit_status=$?
Expand Down
1 change: 0 additions & 1 deletion test-app/.eslintignore

This file was deleted.

30 changes: 0 additions & 30 deletions test-app/.eslintrc.js

This file was deleted.

23 changes: 23 additions & 0 deletions test-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
2 changes: 1 addition & 1 deletion test-app/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
v20.12.0
5 changes: 5 additions & 0 deletions test-app/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"singleQuote": false,
"endOfLine": "auto"
}
8 changes: 2 additions & 6 deletions test-app/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"extends": ["stylelint-config-standard"],
"rules": {
"selector-class-pattern": null,
"keyframes-name-pattern": null
}
}
"extends": ["stylelint-config-standard"]
}
8 changes: 4 additions & 4 deletions test-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo

In the project directory, you can run:

### `yarn start`
### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `yarn test`
### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`
### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
Expand All @@ -29,7 +29,7 @@ Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`
### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

Expand Down
42 changes: 42 additions & 0 deletions test-app/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import globals from "globals";
import path from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";
import pluginJs from "@eslint/js";
import styleLintConfig from "stylelint-config-recommended";
import prettierConfig from "eslint-config-prettier";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: pluginJs.configs.recommended,
});

export default [
{
languageOptions: { globals: globals.browser },
settings: { react: { version: "detect" } },
},
{
ignores: ["src/reportWebVitals.ts"]
},
...compat.extends("standard-with-typescript").map((config) => ({
...config,
files: ["**/*.tsx", "**/*.ts"],
rules: {
...config.rules,
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-non-null-assertion": "off",
},
})),
prettierConfig, // Turns off all ESLint rules that have the potential to interfere with Prettier rules.
eslintPluginPrettierRecommended,
{
files: ["*.css"],
rules: styleLintConfig.rules,
},
];
Loading
Loading