Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

#

Expand Down Expand Up @@ -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([
//------------------------------------------------------------------
Expand Down Expand Up @@ -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!

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
Expand Down
10 changes: 7 additions & 3 deletions docs.users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

````
{
Expand All @@ -50,15 +52,17 @@ In addition to `prettier`'s default settings, our preconfigured settings tells `
trailingComma: 'all',
semi: true,
endOfLine: 'lf',
printWidth: 350,
bracketSpacing: true,
};
````

#

### 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.

#

Expand Down Expand Up @@ -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([
//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
'*.{js,jsx,ts,tsx}': [
'*.{mjs,ts,js}': [
// Formats script file types
'eslint --fix',
'prettier --write',
Expand Down
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -52,6 +52,17 @@
"framework",
"library",
"package",
"typescript",
"javascript",
"node",
"web",
"shared",
"core",
"local development",
"local",
"development",
"dev",
"setup",
"eslint",
"prettier",
"husky",
Expand All @@ -60,12 +71,7 @@
"pre-commit hook",
"code quality",
"code formatting",
"typescript",
"javascript",
"node",
"config",
"setup",
"dev environment",
"ci",
"continuous integration"
],
Expand Down
2 changes: 2 additions & 0 deletions prettier.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export default {
trailingComma: 'all',
semi: true,
endOfLine: 'lf',
printWidth: 350,
bracketSpacing: true,
};
Loading