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

Resolving Eslint Errors #634

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

FutzMonitor
Copy link
Collaborator

Pull Request Description

Closes #600. Adds an .eslintignore file that prevents eslint from running on JavaScript files. This file is located inside the /docker/dev directory which has a new addition to its Dockerfile which copies it into this directory. I couldn't run Cypress test on my host machine (Windows 10) and check to see if this .eslintignore would also suffice to stop any errors for testing outside the dev container.


Licensing Certification

FarmData2 is a Free Cultural Work and all accepted contributions are licensed as described in the LICENSE.md file. This requires that the contributor holds the rights to do so. By submitting this pull request I certify that I satisfy the terms of the Developer Certificate of Origin for its contents.

- Added the creation of the .eslintignore file which is used to ignore the linting of javascript files.
2. Changes to test_runner.bash
- Indentation fixes
- Created an eslintignore file that ignores the Cypress tests
- Added a line to ignore the .eslintignore.
2. Changes to the dev/Dockerfile
- Copied the .eslint file inside the docker/dev directory into the container. Built the container locally, and this did the trick.
- Unfortunately, I couldn't get Cypress to work on my machine to be able to verify that it works on the host machine. You only need one .eslintignore file, and it might be that the one in the docker/dev directory is good enough.
- Making sure the .eslintignore file remained hidden
- Realized that ignoring the .eslintignore is NOT what we want. We want it to be included in the project.
2. Addition of the dev/.eslintignore file
- File that prevents eslint from running on js files.
docker/dev/.eslintignore Outdated Show resolved Hide resolved
docker/dev/Dockerfile Outdated Show resolved Hide resolved
- Moved the new COPY command below line 187 w/explaination for its existence
Copy link
Collaborator Author

@FutzMonitor FutzMonitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the COPY ./.eslintignore . command below line 187 below the other copy commands with an accompanying comment explaining its use.

2. Changes to dev/Dockerfile
- Changed the COPY command to make the visible eslintignore file invisible inside the dev container
Copy link
Collaborator Author

@FutzMonitor FutzMonitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed the .eslintignore file to eslintignore.

@braughtg
Copy link
Member

Renamed the .eslintignore file to eslintignore.

Looks good. As one last check for possible other impacts, please try to install an eslint extension in VSCodium in the dev container to be sure that it is not affected by the .eslintignore in fd2test. It should not be, but it would be good to check because a coming improvement will be to install eslint into VSCodium in the dev container and then also to run it during CI/CD when PRs are made.

@FutzMonitor
Copy link
Collaborator Author

Looks good. As one last check for possible other impacts, please try to install an eslint extension in VSCodium in the dev container to be sure that it is not affected by the .eslintignore in fd2test. It should not be, but it would be good to check because a coming improvement will be to install eslint into VSCodium in the dev container and then also to run it during CI/CD when PRs are made.

I installed the ESLint extension by dbaeumer that integrates ESLint JavaScript into VS Code.
image

The tests continued to run without issue:
image

The first time I opened the extension tab in VS codium the application crashed. It didn't crash when I tried again, and I took the container down and up again and the crash didn't occur again. I couldn't re-create it either.

@braughtg
Copy link
Member

Great! We should check it the other way around also. Can you use the extension to lint js code in VSCodium in the dev container?

@FutzMonitor
Copy link
Collaborator Author

I was testing out some potential solutions for allowing the linter to run on the file without running on the tests, but I couldn't get very far because VS Codium has stopped working. I actually removed the volume and image for the dev container and reinstalled it, but it crashes when clicking on the eslint extension.

example.mp4

@FutzMonitor
Copy link
Collaborator Author

FutzMonitor commented Mar 29, 2023

Tried this, and it also didn't work.
image

Edit: I noticed there's a period missing in **/comp.js. I added it in. This still doesn't work. This file is located in the Cypress directory.

@FutzMonitor
Copy link
Collaborator Author

FutzMonitor commented Mar 29, 2023

I resolved the issue another way. First, I manually installed the Eslint plugin for Cypress [here] into the fd2test directory. Afterwards, I made modifications to the package.json file:

{
  "name": "fd2test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@cypress/vue2": "^1.1.2",
    "@cypress/webpack-dev-server": "^2.5.0",
    "axios": "^0.24.0",
    "core-js": "^3.8.3",
    "cypress": "^12.2.0",
    "path": "^0.12.7",
    "vue": "^2.6.14",
    "webpack": "^5.74.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.16",
    "@babel/eslint-parser": "^7.12.16",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "eslint": "^7.32.0",
    "eslint-plugin-cypress": "^2.13.1",
    "eslint-plugin-vue": "^8.0.3",
    "vue-template-compiler": "^2.6.14"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true,
      "cypress/globals": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended",
      "plugin:cypress/recommended"
    ],
    "parserOptions": {
      "parser": "@babel/eslint-parser"
    },
    "rules": {
      "cypress/unsafe-to-chain-command": "off",
      "cypress/no-assigning-return-values": "off",
      "cypress/no-unnecessary-waiting": "off",
      "cypress/no-async-tests": "off",
      "cypress/no-force": "off",
      "cypress/assertion-before-screenshot": "off",
      "cypress/require-data-selector": "off",
      "cypress/no-pause": "off",
      "no-empty" : ["error", { "allowEmptyCatch": true }]
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

After all that hard work, I was able to observe the fruits of my labor.
image

Now the final piece in this saga is actually figuring out if this still allows the files inside VS codium to work. Unfortunately...I cannot test that. It keeps crashing. But I feel so close to a solution!

Edit: I finally was able to both install the extension and click on a Cypress component test. No linting occurs. I have no clue if this is a back to the drawing boards moment or if VS codium isn't working correctly. Regardless, it was an interesting night.

example.mp4

@braughtg
Copy link
Member

Edit: I finally was able to both install the extension and click on a Cypress component test. No linting occurs. I have no clue if this is a back to the drawing boards moment or if VS codium isn't working correctly. Regardless, it was an interesting night.

It seems like maybe it is the particular eslint extension that you are using that is leading to the VSCodium crashes. Maybe try one of the others to see if that makes a difference. I think FarmData2 is likely to use the Prettier extension so that would be a good one to try.

@FutzMonitor
Copy link
Collaborator Author

This PR should be flipped back to a draft.

@braughtg braughtg marked this pull request as draft April 4, 2023 21:21
- somehow my changes were removed from my system. I had to add these files back before working. No changes here besides incorporating the stylesheet.
Changes to BCalendarDateSelection.js
- no noteable changes. Could not figure out how to make BCalendar work.
Changes to BCalendarDateSelection.spec.comp.js
- No noteable changes. Basically the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cypress component tests report eslint erorrs
2 participants