Skip to content

Commit

Permalink
feat(prettier-config): new package for prettier share configs (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd authored Dec 21, 2023
2 parents be2f48e + 4815007 commit d3043c6
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
max_line_length = 140

[*.{js,ts}]
block_comment_start = /**
Expand Down
4 changes: 0 additions & 4 deletions .prettierrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"workspaces": [
"packages/*"
],
"prettier": "@alwatr/prettier-config",
"scripts": {
"b": "yarn run build",
"c": "yarn run clean",
Expand All @@ -33,6 +34,7 @@
},
"devDependencies": {
"@alwatr/eslint-config": "workspace:^",
"@alwatr/prettier-config": "workspace:^",
"@lerna-lite/changed": "^3.1.0",
"@lerna-lite/cli": "^3.1.0",
"@lerna-lite/diff": "^3.1.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-config/eslint-config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
extends: [
'eslint:recommended',
Expand Down Expand Up @@ -31,7 +34,7 @@ module.exports = {
},
},
rules: {
'max-len': ['error', {code: 120}],
'max-len': ['error', {code: 140}],
'no-eval': ['error', {allowIndirect: true}],
'no-floating-decimal': 'error',
'space-infix-ops': 'error',
Expand Down
18 changes: 11 additions & 7 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "@alwatr/eslint-config",
"version": "1.0.0",
"description": "Build/bundle tools for ECMAScript, TypeScript, and JavaScript libraries. It's easy to use, doesn't require any setup, and adheres to best practices. It has no dependencies and uses esbuild for enhanced performance.",
"description": "Alwatr ECMAScript Style Guide as a ESLint shareable configurations.",
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
"keywords": [
"build",
"bundle",
"esbuild",
"eslint",
"eslint-config",
"lint",
"linter",
"style-guide",
"typescript",
"esm",
"alwatr"
Expand All @@ -29,7 +31,12 @@
"bugs": {
"url": "https://github.com/Alwatr/nanolib/issues"
},
"prettier": "@alwatr/prettier-config",
"dependencies": {
"esbuild": "^0.19.10"
},
"devDependencies": {
"@alwatr/prettier-config": "workspace:^",
"@alwatr/tsconfig-base": "workspace:^",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
Expand All @@ -38,9 +45,6 @@
"eslint-plugin-import": "^2.29.1",
"typescript": "^5.3.3"
},
"dependencies": {
"esbuild": "^0.19.10"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": ">6.0.0",
"@typescript-eslint/parser": ">6.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/flat-string/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"bugs": {
"url": "https://github.com/Alwatr/nanolib/issues"
},
"prettier": "@alwatr/prettier-config",
"scripts": {
"b": "yarn run build",
"w": "yarn run watch",
Expand All @@ -57,6 +58,7 @@
},
"devDependencies": {
"@alwatr/nano-build": "workspace:^",
"@alwatr/prettier-config": "workspace:^",
"@alwatr/tsconfig-base": "workspace:^",
"typescript": "^5.3.3"
}
Expand Down
2 changes: 2 additions & 0 deletions packages/nano-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
"bugs": {
"url": "https://github.com/Alwatr/nanolib/issues"
},
"prettier": "@alwatr/prettier-config",
"dependencies": {
"esbuild": "^0.19.10"
},
"devDependencies": {
"@alwatr/prettier-config": "workspace:^",
"@alwatr/tsconfig-base": "workspace:^",
"typescript": "^5.3.3"
}
Expand Down
21 changes: 21 additions & 0 deletions packages/prettier-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Prettier Configurations

Alwatr's [shareable configurations](https://prettier.io/docs/en/configuration.html#sharing-configurations) for [Prettier](https://prettier.io/).

## Installation

```bash
yarn add -D @alwatr/prettier-config
```

## Usage

Alwatr Prettier rules come bundled in `@alwatr/prettier-config`. To enable these rules, add a prettier property in your package.json. See the Prettier configuration docs for more details.

The Prettier rules from Alwatr are included in the `@alwatr/prettier-config` package. To use these rules, add a prettier property to your `package.json` file. Refer to the [Prettier configuration documentation](https://prettier.io/docs/en/configuration.html) for more information.

```json
{
"prettier": "@alwatr/prettier-config"
}
```
35 changes: 35 additions & 0 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@alwatr/prettier-config",
"version": "1.0.0",
"description": "Alwatr's shareable configurations for Prettier.",
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
"keywords": [
"prettier",
"config",
"typescript",
"esm",
"alwatr"
],
"type": "commonjs",
"main": "./prettier.config.cjs",
"license": "MIT",
"files": [
"**/*.{d.ts.map,d.ts,js.map,js,html,md,cjs,mjs,cjs.map,mjs.map}"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/Alwatr/nanolib",
"directory": "packages/prettier-config"
},
"homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/prettier-config#readme",
"bugs": {
"url": "https://github.com/Alwatr/nanolib/issues"
},
"prettier": "@alwatr/prettier-config",
"devDependencies": {
"@alwatr/prettier-config": "workspace:^"
}
}
15 changes: 15 additions & 0 deletions packages/prettier-config/prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @type {import('prettier').Config}
*/
module.exports = {
singleQuote: true,
semi: true,
trailingComma: 'all',
printWidth: 140,
arrowParens: 'always',
proseWrap: 'preserve',
bracketSpacing: false,
endOfLine: 'lf',
quoteProps: 'as-needed',
tabWidth: 2,
};
4 changes: 4 additions & 0 deletions packages/tsconfig-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@
"homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/tsconfig-base#readme",
"bugs": {
"url": "https://github.com/Alwatr/nanolib/issues"
},
"prettier": "@alwatr/prettier-config",
"devDependencies": {
"@alwatr/prettier-config": "workspace:^"
}
}
14 changes: 14 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@alwatr/eslint-config@workspace:packages/eslint-config"
dependencies:
"@alwatr/prettier-config": "workspace:^"
"@alwatr/tsconfig-base": "workspace:^"
"@typescript-eslint/eslint-plugin": "npm:^6.15.0"
"@typescript-eslint/parser": "npm:^6.15.0"
Expand All @@ -38,6 +39,7 @@ __metadata:
resolution: "@alwatr/flat-string@workspace:packages/flat-string"
dependencies:
"@alwatr/nano-build": "workspace:^"
"@alwatr/prettier-config": "workspace:^"
"@alwatr/tsconfig-base": "workspace:^"
typescript: "npm:^5.3.3"
languageName: unknown
Expand All @@ -47,6 +49,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@alwatr/nano-build@workspace:packages/nano-build"
dependencies:
"@alwatr/prettier-config": "workspace:^"
"@alwatr/tsconfig-base": "workspace:^"
esbuild: "npm:^0.19.10"
typescript: "npm:^5.3.3"
Expand All @@ -55,9 +58,19 @@ __metadata:
languageName: unknown
linkType: soft

"@alwatr/prettier-config@workspace:^, @alwatr/prettier-config@workspace:packages/prettier-config":
version: 0.0.0-use.local
resolution: "@alwatr/prettier-config@workspace:packages/prettier-config"
dependencies:
"@alwatr/prettier-config": "workspace:^"
languageName: unknown
linkType: soft

"@alwatr/tsconfig-base@workspace:^, @alwatr/tsconfig-base@workspace:packages/tsconfig-base":
version: 0.0.0-use.local
resolution: "@alwatr/tsconfig-base@workspace:packages/tsconfig-base"
dependencies:
"@alwatr/prettier-config": "workspace:^"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -1255,6 +1268,7 @@ __metadata:
resolution: "alwatr-nanolib@workspace:."
dependencies:
"@alwatr/eslint-config": "workspace:^"
"@alwatr/prettier-config": "workspace:^"
"@lerna-lite/changed": "npm:^3.1.0"
"@lerna-lite/cli": "npm:^3.1.0"
"@lerna-lite/diff": "npm:^3.1.0"
Expand Down

0 comments on commit d3043c6

Please sign in to comment.