Skip to content

refactor: update indexOf () === -1 to ! includes #2963

refactor: update indexOf () === -1 to ! includes

refactor: update indexOf () === -1 to ! includes #2963

Workflow file for this run

name: ESLint
on:
pull_request:
branches: [master]
jobs:
build:
name: Lint updated JavaScript files with ESLint
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Get changed files
id: getfile
run: |
CHANGED_FILES="$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | xargs)"
export CHANGED_FILES # the export command will fail if the inner shell expansion failed
echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT
- name: Install ESLint
run: npm install eslint
- name: Lint changed files using ESLint
run: |
for i in ${{ steps.getfile.outputs.files }}
do
if [[ "$i" == "D" ]]
then
ignore=1
elif [[ ( "$i" == "M" ) || ( "$i" == "A" ) || ( "$i" == "R" ) || ( "$i" == "C" ) || ( "$i" == "U" ) ]]
then
ignore=0
fi
echo "file $i $ignore"
if [[ "$i" == *".js" && $ignore == 0 ]]
then
echo "linting $i"
npx eslint $i
fi
done