Skip to content

Commit

Permalink
Initialize Audio Lab Style Guide
Browse files Browse the repository at this point in the history
  • Loading branch information
weiland committed Jun 30, 2024
0 parents commit a1a772d
Show file tree
Hide file tree
Showing 29 changed files with 1,320 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
charset = utf-8
end_of_line = lf
# indent_size = 8 # should be set in the local editor
# `max_line_length` will overwrite prettier's default print_width
max_line_length = 120
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
indent_style = space
indent_size = 2

[*.{yml,yaml}]
indent_style = space
indent_size = 2
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
open-pull-requests-limit: 10
schedule:
interval: 'weekly'
day: 'sunday'
- package-ecosystem: npm
directory: '/'
open-pull-requests-limit: 10
schedule:
interval: 'weekly'
day: 'sunday'
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dependency directories
node_modules/
.yarn/
package-lock.json
**/*.bun

# Editor folders
.idea/
.vscode/

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Operating system files
.DS_Store

# Keys
.env
15 changes: 15 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2024 SWR Audio lab

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
126 changes: 126 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<h1 align="center">@swrlab/style-guide</h1>
<center>
> SWR Audio Lab Style Guide
</center>
<div align="center">

[![license](https://img.shields.io/github/license/swrlab/style-guide?label=license)](https://github.com/swrlab/style-guide/blob/main/LICENSE)
[![version](https://img.shields.io/npm/v/@swrlab/style-guide)](https://www.npmjs.com/package/swrlab/style-guide)

</div>

<table><tr></tr><tr><td>
SWR Audio Lab's Style Guide 💅
</td></tr></table>


## Introduction

This repository is the home of an based on Vercel's style guide, which includes configs for
popular linting and styling tools.

The following configs are available, and are designed to be used together.

- [Prettier](#prettier)
- [ESLint](#eslint)
- [Biome](#biome)

## Installation

All of our configs are contained in one package, `@swrlab/style-guide`. To install:

```sh
# If you use Bun
bun add --dev @swrlab/style-guide

# If you use Yarn
yarn add --dev @swrlab/style-guide

# If you use npm
npm i --save-dev @swrlab/style-guide

# If you use pmpm
pnpm i --save-dev @swrlab/style-guide

```

Some of our ESLint configs require peer dependencies. We'll note those
alongside the available configs in the [ESLint](#eslint) section.

## Prettier

> Note: Prettier is a peer-dependency of this package, and should be installed
> at the root of your project.
>
> See: https://prettier.io/docs/en/install.html
To use the shared Prettier config, set the following in `package.json`.

```json
{
"prettier": "@swrlab/style-guide/prettier"
}
```

## ESLint

> Note: ESLint is a peer-dependency of this package, and should be installed
> at the root of your project.
>
> See: https://eslint.org/docs/user-guide/getting-started#installation-and-usage
Usage:

```js
// eslint.config.mjs
import { audiolab } from '@swrlab/style-guide/eslint/presets.js'

export default audiolab(
[
/* your custom ESLint config */
],
{
prettier: true,
vue: true
},
)
```

### Presets

You can also import and compose individual presets. However, it is recommended that you use the factory function above.

```js
// eslint.config.js
import { presetAll, presetBasic } from '@swrlab/style-guide/eslint/presets.js'

export default presetBasic;
```


## Biome

To use the shared Biome config, set the following in `biome.json`:

```json
{
"extends": ["@swrlab/style-guide/biome"]
}
```

## Credits

This config is inspired by the work of [The Vercel Style Guide](https://github.com/vercel/style-guide) and is further
based on

* https://github.com/antfu/eslint-config
* https://github.com/sxzz/eslint-config

## Contributing

After cloning, you can run `bun install` (or `npm install`) to install the npm dependencies.

## License

ISC
17 changes: 17 additions & 0 deletions biome/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"formatter": {
"indentStyle": "tab",
"formatWithErrors": true
},
"javascript": {
"formatter": {
"semicolons": "asNeeded",
"trailingComma": "es5",
"quoteStyle": "single"
}
}
}
Binary file added bun.lockb
Binary file not shown.
19 changes: 19 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { audiolab } from './eslint/presets.js'

export default audiolab(
[
{
ignores: [],
},
{
rules: {
'import/extensions': ['error', 'ignorePackages'],
},
},
],
{
prettier: true,
comments: true,
vue: true,
}
)
31 changes: 31 additions & 0 deletions eslint/configs/comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { pluginComments } from '../plugins.js'

/**
* @typedef {import("eslint-define-config").FlatESLintConfigItem} FlatESLintConfigItem
*/

/**
* @returns {FlatESLintConfigItem[]}
*/
export const comments = [
{
plugins: {
'eslint-comments': pluginComments,
},
rules: {
...pluginComments.configs.recommended.rules,
/**
* Warn if ESlint enable directives are missing after disable directives.
*
* 🚫 Not fixable - https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html
*/
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
/**
* Require comments on ESlint disable directives.
*
* 🚫 Not fixable - https://mysticatea.github.io/eslint-plugin-eslint-comments/rules/require-description.html
*/
'eslint-comments/require-description': 'error',
},
},
]
44 changes: 44 additions & 0 deletions eslint/configs/errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/** @type {import("eslint-define-config").FlatESLintConfigItem[]} */
export const errors = [
{
rules: {
/**
* Disallow await inside of loops.
*
* 🚫 Not fixable - https://eslint.org/docs/rules/no-await-in-loop
*/
'no-await-in-loop': 'error',
/**
* Allow the use of console.
*
* 🚫 Not fixable - https://eslint.org/docs/rules/no-console
*/
'no-console': 'error',
/**
* Disallow expressions where the operation doesn't affect the value.
*
* 🚫 Not fixable - https://eslint.org/docs/rules/no-constant-binary-expression
*/
'no-constant-binary-expression': 'error',
/**
* Disallow returning values from Promise executor functions.
*
* 🚫 Not fixable - https://eslint.org/docs/rules/no-promise-executor-return
*/
'no-promise-executor-return': 'error',
/**
* Disallow template literal placeholder syntax in regular strings, as
* these are likely errors.
*
* 🚫 Not fixable - https://eslint.org/docs/rules/no-template-curly-in-string
*/
'no-template-curly-in-string': 'error',
/**
* Disallow loops with a body that allows only one iteration.
*
* 🚫 Not fixable - https://eslint.org/docs/rules/no-unreachable-loop
*/
'no-unreachable-loop': 'error',
},
},
]
6 changes: 6 additions & 0 deletions eslint/configs/ignores.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { GLOB_EXCLUDE } from '../constants.js'

/**
* @type {import("eslint-define-config").FlatESLintConfigItem[]}
*/
export const ignores = [{ ignores: GLOB_EXCLUDE }]
Loading

0 comments on commit a1a772d

Please sign in to comment.