Leonardo Drici
Leonardo Drici

Reputation: 789

Eslint behaves differently between local and CI

It seems that eslint behaves different in GitHub actions and in local. On local I don't get any errors a part from ts warning which are fine. Wheres in the github actions I seems to get more errors related to some rule about file extension. It's like it doesn't find the files... I am pretty new do GitHub actions but I am not sure what is missing from my config.

CI.yml:

name: Continuous Integration
on:
  pull_request:
    branches: [main]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: '15.x'
      - uses: actions/checkout@v2
      - run: git fetch --prune --unshallow
      - name: Get yarn cache
        id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - uses: actions/cache@v1
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: Install deps
        run: yarn

      - name: Lint packages
        run: yarn lint

Package.json:

{
  "main": "index.js",
  "scripts": {
    ...
    "lint": "yarn lint:js && yarn lint:css",
    ...
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "@testing-library/jest-native": "^3.4.3",
    "@testing-library/react-native": "^7.1.0",
    "@types/jest": "^26.0.20",
    "@types/react": "^17.0.1",
    "@types/react-native": "^0.63.48",
    "@types/react-native-fbsdk": "^3.0.0",
    "@types/react-native-maps": "^0.24.0",
    "@types/react-native-snap-carousel": "^3.8.2",
    "@types/react-native-vector-icons": "^6.4.6",
    "@types/react-test-renderer": "^17.0.0",
    "@types/styled-components": "^5.1.9",
    "@types/styled-components-react-native": "^5.1.1",
    "@types/uuid": "^8.3.0",
    "@types/yup": "^0.29.11",
    "@typescript-eslint/eslint-plugin": "^4.20.0",
    "@typescript-eslint/parser": "^4.20.0",
    "babel-jest": "~25.2.6",
    "babel-plugin-styled-components": "^1.12.0",
    "eslint": "^7.19.0",
    "eslint-config-prettier": "^7.2.0",
    "eslint-import-resolver-typescript": "^2.4.0",
    "eslint-loader": "^4.0.2",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jest": "^24.1.5",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "eslint-plugin-react-native": "^3.10.0",
    "eslint-plugin-sort-destructure-keys": "^1.3.5",
    "husky": "^5.1.3",
    "jest": "~25.2.6",
    "lint-staged": "^10.5.4",
    "prettier": "^2.2.1",
    "react-test-renderer": "~16.13.1",
    "stylelint": "^13.9.0",
    "stylelint-config-standard": "^20.0.0",
    "stylelint-config-styled-components": "^0.1.1",
    "stylelint-processor-styled-components": "^1.10.0",
    "typescript": "^4.1.3"
  },
  "jest": {
    "preset": "react-native"
  },
  "private": true
}

CI error

Upvotes: 5

Views: 3389

Answers (1)

devgioele
devgioele

Reputation: 159

Solution

Rename using git mv <old_filepath> <new_filepath>. You could also first create the new file, copy the content and then delete the old file.

You should do this for all the reported files or directories.

Explanation

I had the same problem until I found out that Git did not save the correct casing of files and directories.

Because Windows and macOS use file systems that are case insensitive, renaming files and directories by just changing the casing, like from Test.js to test.js or from src/Api to src/api, does not change anything for Git.

You can see with git ls-files that there casing did not change from Git's perspective.

When you then go over to GitHub Actions that runs Ubuntu and therefore uses a case sensitive file system, the files can obviously not be found.

Upvotes: 2

Related Questions