diff --git a/.prettierignore b/.prettierignore index 162a220..53a9a15 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,13 +4,16 @@ # 2. Allow directories !*/ -# 3. Specifically allow these FOUR types -!*.js +# 3. Specifically allow these SIX types +!*.mjs !*.ts -!*.css +!*.js !*.html +!*.css +!*.scss # 4. Standard ignores +.build-in-blocks/ node_modules/ build/ dist/ diff --git a/README.md b/README.md index ebf0182..ae9a677 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,24 @@ # @build-in-blocks/dev.setup -**Supported Node.js versions:** Node.js v20.x, v22.x, v24.x and v25.x +![Latest Version](https://img.shields.io/npm/v/@build-in-blocks/dev.setup.svg?label=latest&color=brightgreen&style=flat-square) ![NPM Downloads](https://img.shields.io/npm/d18m/%40build-in-blocks%2Fdev.setup?color=blue&label=downloads%20(last%2018%20months)) ![build passing](https://img.shields.io/badge/build-passing-brightgreen?style=flat-square) + +[![License: AGPL v3.0](https://img.shields.io/badge/license-AGPL%20v3.0-blue.svg?style=flat-square)](https://www.gnu.org/licenses/agpl-3.0) [![All Contributors](https://img.shields.io/github/all-contributors/build-in-blocks/dev.setup?color=ee8449&style=flat-square)](#contributors) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/build-in-blocks/dev.setup/blob/develop/docs.contributors/README.md) + +# + +**Built with:** Node.js v24.0.2 + +# + +**Supported Node.js versions:** Node.js v20.x, v22.x, v24.x and v25.x - Monitored by (internal) central Blocks CI # -**Description:** Code linting, formatting, pre-commit hook and GitHub actions development environment setup for your `typescript` code repository. +**Overview:** Code linting, formatting, pre-commit hook and GitHub actions development environment setup for your `typescript` code repository. # -**How it works:** Using code quality checks from `eslint`, `husky` works with `lint-staged` to prevent code that don't meet your code quality requirements, from being commited to git and pushed to your repository's remote - it also formats your code with `prettier` based on your code formatting preferences at this point. `GitHub Actions` then runs the code quality and node version compatibilty checks on pull requests, on push or on merge to your repository's `develop` and/or `main` branch. Ensuring code from all code contributors working on your project pass through the quality checks that you've configured. +**Description:** **@build-in-blocks/dev.setup** provides TS development environment setup and comes with preconfigured settings. It helps to automate code compatibilty, quality and formatting checks within your typescript code repository's Git workflow, ensuring that only clean, consistent code is committed to the repository. It also includes GitHub Actions Continuous Integration (CI) setup for running these checks on the contributions submitted to your repository, by your open source contributors or work colleagues. Of course, you can configure it to use your preferred settings too. # @@ -55,7 +65,7 @@ npm install -D @build-in-blocks/dev.setup // NOTE: Change folder name to where your ts files reside const TARGET_FOLDER = 'src'; - const TARGET_FILES = `${TARGET_FOLDER}/**/*.{ts,js,tsx}`; + const TARGET_FILES = `${TARGET_FOLDER}/**/*.{mjs,ts,js}`; export default defineConfig([ //------------------------------------------------------------------ @@ -230,7 +240,7 @@ Make sure to add and commit all your setup files to git, and push/merge it to yo ### Contributors -[![All Contributors](https://img.shields.io/github/all-contributors/build-in-blocks/dev.setup?color=ee8449&style=flat-square)](#contributors) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/build-in-blocks/dev.setup/blob/develop/docs.contributors/README.md) [![License: AGPL v3.0](https://img.shields.io/badge/License-AGPL%20v3.0-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) +Thanks to these amazing contributors to the **@build-in-blocks/dev.setup** project. This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. See [emoji key](https://allcontributors.org/docs/en/emoji-key). Contributions of any kind welcome! diff --git a/docs.users/README.md b/docs.users/README.md index fe95c77..b1046f1 100644 --- a/docs.users/README.md +++ b/docs.users/README.md @@ -41,6 +41,8 @@ In addition to `prettier`'s default settings, our preconfigured settings tells ` - Add trailing comma to the last item in an object - End every single code statement with a semicolon - Ensure that every file ends with exactly one empty line +- Allow e.g. import statements, function arguments etc. to be on straight line without breaking (only wrap to next line if printWidth exceeds 350) +- Add spaces between brackets in object literals, imports, and similar structures ```` { @@ -50,6 +52,8 @@ In addition to `prettier`'s default settings, our preconfigured settings tells ` trailingComma: 'all', semi: true, endOfLine: 'lf', + printWidth: 350, + bracketSpacing: true, }; ```` @@ -57,8 +61,8 @@ In addition to `prettier`'s default settings, our preconfigured settings tells ` ### Preconfigured Husky + lint-staged settings -- Run `eslint` and `prettier` anytime a developer tries to commit code to git. -- Prevent code commit to git when any of the code linting and formatting requirements are not met. +- Runs `eslint` and `prettier` anytime a developer tries to commit code to git. +- Prevents code commit to git when any of the code linting and formatting requirements are not met. # @@ -88,7 +92,7 @@ import { defineConfig } from 'eslint/config'; import blocksDevSetupConfig from '@build-in-blocks/dev.setup'; const TARGET_FOLDER = 'src'; // NOTE: Change folder name to where your ts files reside -const TARGET_FILES = `${TARGET_FOLDER}/**/*.{ts,js,tsx}`; +const TARGET_FILES = `${TARGET_FOLDER}/**/*.{mjs,ts,js}`; export default defineConfig([ //--------------------------------------------------------------------------- diff --git a/lint-staged.config.js b/lint-staged.config.js index d3926ba..3eed321 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -1,5 +1,5 @@ export default { - '*.{js,jsx,ts,tsx}': [ + '*.{mjs,ts,js}': [ // Formats script file types 'eslint --fix', 'prettier --write', diff --git a/package.json b/package.json index 27a4485..6883d61 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "scripts": { "eslint:lint": "eslint .", - "prettier:format": "prettier --write \"**/*.{js,ts,css,html}\"", + "prettier:format": "prettier --write \"**/*.{mjs,ts,js,html,css,scss}\"", "prepare": "husky" }, "dependencies": { @@ -52,6 +52,17 @@ "framework", "library", "package", + "typescript", + "javascript", + "node", + "web", + "shared", + "core", + "local development", + "local", + "development", + "dev", + "setup", "eslint", "prettier", "husky", @@ -60,12 +71,7 @@ "pre-commit hook", "code quality", "code formatting", - "typescript", - "javascript", - "node", "config", - "setup", - "dev environment", "ci", "continuous integration" ], diff --git a/prettier.config.mjs b/prettier.config.mjs index 6baf04e..68ff83e 100644 --- a/prettier.config.mjs +++ b/prettier.config.mjs @@ -5,4 +5,6 @@ export default { trailingComma: 'all', semi: true, endOfLine: 'lf', + printWidth: 350, + bracketSpacing: true, };