Skip to content

Commit

Permalink
Add initial shared prettier config
Browse files Browse the repository at this point in the history
Resolves #1
  • Loading branch information
kieranhall committed Feb 22, 2024
1 parent 2955c21 commit 9ded1f8
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 43 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
12 changes: 12 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: ["@dusk-network/eslint-config/js"],
plugins: [],
root: true,
rules: {},
settings: {},
};
30 changes: 30 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: check

on:
push:
branches: [main]

pull_request:

jobs:
checks:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]

name: Node ${{ matrix.node-version }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Installing dev dependencies
run: npm install

- name: Checking formatting
run: npm run check

- name: Linting
run: npm run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Dependencies
node_modules
package-lock.json

# Env files
.env
Expand Down
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import duskJsPrettierConfig from "./js/index.js";

export default {
...duskJsPrettierConfig,
};
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,4 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------

This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
defined by the Mozilla Public License, v. 2.0.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dusk Prettier configuration

Prettier config used by [Dusk](https://dusk.network/) JavaScript apps.
Prettier configs used by [Dusk](https://dusk.network/) JavaScript apps.

## Installation

Expand All @@ -10,11 +10,14 @@ npm i -D @dusk-network/prettier-config

## Usage

Edit `package.json`
You need to use a `.prettierrc.js` file to import one or more of the configurations.

```json
{
// ...
"prettier": "@azz/prettier-config"
}
```js
import duskJsPrettierConfig from "@dusk-network/prettier-config/js";
import duskSveltePrettierConfig from "@dusk-network/prettier-config/svelte"; // For Svelte projects only

export default {
...duskJsPrettierConfig,
...duskSveltePrettierConfig, // For Svelte projects only
};
```
Empty file removed index.json
Empty file.
6 changes: 6 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import("prettier").Config} */
const config = {
trailingComma: "es5",
};

export default config;
82 changes: 47 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
{
"author": {
"name": "Dusk Network B.V.",
"url": "https://dusk.network/",
"mail": "[email protected]"
},
"bugs": "https://github.com/dusk-network/prettier-config/issues/",
"contributors": [
"Kieran Hall <[email protected]>"
],
"description": "Prettier config used by Dusk JavaScript apps",
"engines": {
"node": ">=16.0.0"
},
"main": "index.json",
"homepage": "https://github.com/dusk-network/prettier-config/",
"keywords": [
"dusk",
"dusk network",
"prettier",
"prettierconfig"
],
"license": "MPL-2.0",
"name": "@dusk-network/prettier-config",
"repository": {
"type": "git",
"url": "https://github.com/dusk-network/prettier-config.git"
},
"scripts": {
"bump": "bump package.json package-lock.json"
},
"version": "1.0.0",
"devDependencies": {
"@jsdevtools/version-bump-prompt": "6.1.0"
}
}
"author": {
"name": "Dusk Network B.V.",
"url": "https://dusk.network/",
"mail": "[email protected]"
},
"bugs": "https://github.com/dusk-network/prettier-config/issues/",
"contributors": [
"Kieran Hall <[email protected]>"
],
"description": "Prettier config used by Dusk JavaScript apps",
"engines": {
"node": ">=16.0.0"
},
"files": [
"js/**/*.js",
"svelte/**/*.js"
],
"homepage": "https://github.com/dusk-network/prettier-config/",
"keywords": [
"dusk",
"dusk network",
"prettier",
"prettierconfig"
],
"license": "MPL-2.0",
"name": "@dusk-network/prettier-config",
"repository": {
"type": "git",
"url": "https://github.com/dusk-network/prettier-config.git"
},
"scripts": {
"bump": "bump package.json package-lock.json",
"check": "prettier . --check",
"lint": "eslint ."
},
"version": "1.0.0",
"devDependencies": {
"@dusk-network/eslint-config": "2.1.0",
"@jsdevtools/version-bump-prompt": "6.1.0",
"eslint": "8.54.0",
"prettier": "3.2.5"
},
"optionalDependencies": {
"prettier-plugin-svelte": ">=3.2.1"
},
"type": "module"
}
4 changes: 4 additions & 0 deletions svelte/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import("prettier").Config} */
const config = {};

export default config;

0 comments on commit 9ded1f8

Please sign in to comment.