diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0635f1bdc..5cd7ed53a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,8 +17,8 @@ If you have questions or would like to communicate with the team, please [join u - [Learning the tech stack](#learning-the-tech-) - [Development environment](#dev-env-) - [Style guide](#style-guide-) -- [Testing](#testing-) - [Linting](#linting-) +- [Testing](#testing-) - [Issues and projects](#issues-projects-) - [Bug reports](#bug-reports-) - [Feature requests](#feature-requests-) @@ -57,11 +57,11 @@ The following are the current and planned technologies for [activist.org](https: ### Backend -- [Django](https://www.djangoproject.com) • [PostgreSQL](https://www.postgresql.org) (planned) +- [Django](https://www.djangoproject.com) • [PostgreSQL](https://www.postgresql.org) ### Deployment -- [Docker](https://www.docker.com) • [Netlify](https://www.netlify.com) • [Vitest](https://vitest.dev/) (planned) +- [Docker](https://www.docker.com) • [Netlify](https://www.netlify.com) • [Vitest](https://vitest.dev/) ### Localization @@ -343,6 +343,14 @@ From there you'll be able to visit http://localhost:6006/ to view the documentat Please see the [activist style guide](STYLEGUIDE.md) for details about how to follow the code style for the project. We made these guidelines to assure that we as a community write clean, cohesive code that's easy to write and review. Suggestions for the style guide are welcome. + + +## Linting [`⇧`](#contents) + +For the backend [Ruff](https://github.com/astral-sh/ruff) is installed via the required packages to assure that errors are reported correctly. We'd also suggest that VS Code users install the [Ruff extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff). + +For the frontend [eslint](https://eslint.org/), [eslint-vue](https://eslint.vuejs.org/) and [vue-a11y](https://vue-a11y.github.io/eslint-plugin-vuejs-accessibility/) are added via the dependencies to provide linting support. + ## Testing [`⇧`](#contents) @@ -395,7 +403,7 @@ yarn typecheck #### Automated Testing -We use vitest for component and unit testing. You can run them with the following command: +We use [Vitest](https://vitest.dev/) for component and unit testing. You can run them with the following command: ```bash # Within ./frontend: @@ -405,7 +413,7 @@ yarn test Please see the [frontend testing guide](FRONTEND_TESTING.md) for information on how to write component tests. > [!NOTE] -> The vitest test suite is still in a very early stage. There is a lot of work left to do to increase test coverage, and some features still need troubleshooting. If you need assistance then feel free to open a PR and we'll support! +> The Vitest test suite is still in a very early stage. There is a lot of work left to do to increase test coverage, and some features still need troubleshooting. If you need assistance then feel free to open a PR and we'll support! ### End to End Testing @@ -477,14 +485,6 @@ You can then visit the [actions of the repository](https://github.com/activist-o Thank you for testing your PRs! 🎉 - - -## Linting [`⇧`](#contents) - -For the backend [Ruff](https://github.com/astral-sh/ruff) is installed via the required packages to assure that errors are reported correctly. We'd also suggest that VS Code users install the [Ruff extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff). - -For the frontend [eslint](https://eslint.org/), [eslint-vue](https://eslint.vuejs.org/) and [vue-a11y](https://vue-a11y.github.io/eslint-plugin-vuejs-accessibility/) are added via the dependencies to provide linting support. - ## Issues and projects [`⇧`](#contents) diff --git a/utils/check_license.py b/utils/check_license.py deleted file mode 100644 index 602a009ba..000000000 --- a/utils/check_license.py +++ /dev/null @@ -1,102 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -""" -Checks project to assure that all files have an SPDX-License-Identifier. - -Usage: - python3 utils/check_license.py -""" - -import contextlib -import itertools -import os -from pathlib import Path - -# MARK: Paths / Files - -# Check for Windows and derive directory path separator. -path_separator = "\\" if os.name == "nt" else "/" - -root_dir = Path(__file__).parent.parent -backend_directory = Path(__file__).parent.parent / "backend" -frontend_directory = Path(__file__).parent.parent / "frontend" - -directories_to_skip = [ - str((root_dir / ".mypy_cache").resolve()), - str((backend_directory / ".mypy_cache").resolve()), - str((backend_directory / "htmlcov").resolve()), - str((frontend_directory / ".nuxt").resolve()), - str((frontend_directory / "node_modules").resolve()), -] - -SPDX_ID_DICT = { - ".py": "# SPDX-License-Identifier: AGPL-3.0-or-later", - ".vue": "", - ".js": "// SPDX-License-Identifier: AGPL-3.0-or-later", - ".mjs": "// SPDX-License-Identifier: AGPL-3.0-or-later", - ".ts": "// SPDX-License-Identifier: AGPL-3.0-or-later", -} - -files_to_check_without = [] -files_to_check_should_not_have = [] -for root, dir, files in itertools.chain( - os.walk(backend_directory), os.walk(frontend_directory) -): - if all(root[: len(d)] != d for d in directories_to_skip): - for f in files: - for t in list(SPDX_ID_DICT.keys()): - if f[-len(t) :] == t: - if f != "__init__.py": - files_to_check_without.append(os.path.join(root, f)) - - else: - files_to_check_should_not_have.append(os.path.join(root, f)) - -files_to_check_should_not_have += files_to_check_without - -# MARK: Files Missing ID - -files_without_spdx_id = [] -for file_to_check in files_to_check_without: - with open(file_to_check, mode="r") as f: - first_line = f.readline() - with contextlib.suppress(IndexError): - first_line = first_line[:-1] if first_line[-1] == "\n" else first_line - files_without_spdx_id.extend( - file_to_check - for k, v in SPDX_ID_DICT.items() - if file_to_check[-len(k) :] == k and v != first_line - ) - -if files_without_spdx_id: - print( - "Some files are missing or have an incorrect SPDX license identifier as the first line:\n" - ) - for i, f in enumerate(files_without_spdx_id): - print(f"{i + 1}. {f}") - - print() - -else: - print("All files have a correct SPDX license identifier as the first line.") - -# MARK: Files Wrong ID - -files_should_not_have_spdx_id = [] -for file_to_check in files_to_check_should_not_have: - if file_to_check[-len("__init__.py") :] == "__init__.py": - with open(file_to_check, mode="r") as f: - first_line = f.readline() - with contextlib.suppress(IndexError): - first_line = first_line[:-1] if first_line[-1] == "\n" else first_line - files_should_not_have_spdx_id.extend( - file_to_check - for k, v in SPDX_ID_DICT.items() - if file_to_check[-len(k) :] == k and v == first_line - ) - -if files_should_not_have_spdx_id: - print( - "Some files have an SPDX license identifier as the first line that shouldn't:\n" - ) - for i, f in enumerate(files_should_not_have_spdx_id): - print(f"{i + 1}. {f}")