Skip to content

Conversation

@mark-pitblado
Copy link
Collaborator

@mark-pitblado mark-pitblado commented Sep 23, 2025

Fixes #7402

This PR removes the link between Max Platiiuk's dotfiles and the Specify repository for formatting, linting and the pre-commit config. I have tried to stay as close to a copy and paste operation as possible, however the following two changes were made:

  1. Previously, flake was pulling from a repository on GitLab, which required a login when I was testing with pre-commit. Since developers and testers for Specify are developing on GitHub, it seemed to make sense to switch to a GitHub based repo so that no additional setup is required.
  2. The markdownlint used in pre-commit required ruby during my testing. Since ruby isn't one of the languages used by the Specify project, it seemed prudent to swap this out for a markdownlint based on nodejs. Markdownlinters should be pretty similar, there are very few rules for markdown.

Eslint is definitely where things get the most complicated, particularly because I don't think eslint has been a part of the ci pipeline for a while due to the high number of errors it produces?

run: |
# TODO: Once most errors are fixed remove "set +e" to not ignore errors
set +e
npx eslint --fix --color `echo "${{steps.changed.outputs.changed}}" | tr " " "\n"`
set -e

I think it may be prudent to think about where in the pipeline each type of error is expected to be caught, and which tools are mandatory to setup. For example, if a developer has pre-commit setup, are they good to go? Or should they also run npm run test on their machine? Which jobs are handled by the ci runners, compared to local testing? A good candidate for developer documentation.

Note

Gitguardian has a pre-commit config that can catch secrets before they are commited as a pre-commit check (or pushed as a pre-push check), whereas I believe the PR integration will only catch the secret after it has been committed (it can be then rotated/revoked, but that's a pain). An example of a case where it matters where a check is run.

Dependency changes

The following dependencies were added to the Specify frontend. These were always dependencies for the project, they were just further upstream because they were dependencies for the dotfiles.

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)

Testing instructions

  • These changes are meta-changes, and shouldn't change any functionality of application code. The only test to be done is to run the ci and pre-commit pipelines and observe that there are no big changes suggested for files that have already been through the pipeline. Note that running the existing pre-commit configuration over the entire codebase will result in a lot of changes, it appears like many directories have never been touched by pre-commit (perhaps because they haven't seen changes in a while, or pre-commit is not consistently used).

Previously the code removed prettier-plugin-tailwindcss from base,
however, now that all settings are defined directly, can just remove the
plugin from the list.
This can be kept because it is like any other dependency in the
pre-commit config, however, it should have a description since the title
of the repository is ambiguous.
With gitlab, the user has to login to gitlab in order to use the hook.
Since development of specify occurs on github, it makes sense to use the
github version to prevent developers from having to setup another
account.
markdownlint relies on a ruby gem, which requires a version of ruby that
macOS machines don't ship with by default. Since ruby isn't a language
that is in the specify codebase, it would be better to use a markdown
linter that uses node.
Copies the rules previously in the import. There is no need for
stylelint-config-prettier after stylelint version 15, see
https://www.npmjs.com/package/stylelint-config-prettier
No longer necessary since these configuration variables are now directly
in the file
Some debugging remains for how testFiles and abbreviationsConfig are
handled
Tested and eslint now runs fine without errors
@github-project-automation github-project-automation bot moved this to 📋Back Log in General Tester Board Sep 23, 2025
@mark-pitblado mark-pitblado changed the title Issue 7402 Decouple linting, formatting, and pre-commit from external dotfiles Sep 23, 2025
These are no longer necessary as dev dependencies
These were requirements in  max's dotfiles, and so are now required by
specify
Changes look good, single quote is respected, which is the biggest
difference between specify's settings and the default. Ran over the
entirety of js_src and no changes to 99% of files.
The ci pipeline requires the lockfile and package.json to be in sync,
this should resolve that error.
Triggered by 28d7155 on branch refs/heads/issue-7402
@mark-pitblado
Copy link
Collaborator Author

04cc77c installs the latest versions of prettier and the plugins, don't see a reason not to use the latest version, as these are just formatters.

eslint-plugin-markdown is depracated, npm suggests eslint/markdown as a
replacement
Triggered by c030cba on branch refs/heads/issue-7402
Since eslint is largely ignored in the current ci pipeline, starting
from the defaults and building up may make sense.
@grantfitzsimmons grantfitzsimmons added this to the 7.12.0 milestone Oct 8, 2025
Copy link
Member

@grantfitzsimmons grantfitzsimmons left a comment

Choose a reason for hiding this comment

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

Thank you so much for doing this! @CarolineDenis, we should discuss what changes need to be made to address

Note that running the existing pre-commit configuration over the entire codebase will result in a lot of changes, it appears like many directories have never been touched by pre-commit (perhaps because they haven't seen changes in a while, or pre-commit is not consistently used).

@mark-pitblado
Copy link
Collaborator Author

mark-pitblado commented Oct 8, 2025

This pull request isn't ready to merge just yet, mostly because I'm trying to work out a proposal for what to do with eslint. The current config is using a version of eslint (version 8) that is depracated. However, just switching back to the recommended configuration1 will litter the codebase with comment strings that say to ignore a previous rule. In a perfect world I could get all the plugins and rules to line up.

As far as I can tell, the following are done at each stage of the pipeline:

Stage Testing
Pre-commit Runs frontend jest tests, regex testing, python typechecking, python linting, python formatting (black), prettier formatting, doctstring linting, markdown linting, docker compose linting.
On PR GitGuardian (secret checking)
CI Workers Eslint, prettier formatting, frontend tests, backend tests

Currently, the only thing that eslint will do is autofix what it can (which isn't supported for all rules, just some). Errors are ignored for both prettier and eslint in the pipeline, presumably because they were too restrictive at some time. Warnings are... well just warnings.

# TODO: Once most errors are fixed remove "set +e" to not ignore errors

Example: https://github.com/specify/specify7/actions/runs/18353184533/job/52278324256
image

I don't think stylelint is used anywhere, but there is a config for it, I guess if an individual developer wanted to set it up in their IDE they could use it.

Footnotes

  1. Since the current ruleset is being ignored, I think it would be better to pull back to just the recommended config and see if that is something that should be adhered too, but that's just my two cents. Using the recommended would reduce dependencies by eliminating the need for all the plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

Bring configuration files from maxpatiiuk's dotfiles into Specify respository

3 participants