Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Add Prettier and ESLint standard configs #5

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*]
indent_style = space
indent_size = 2
68 changes: 34 additions & 34 deletions backend/base-backend-package/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
{
"env": {
"browser": true,
"es6": true,
"jest": true
},
"extends": [
"standard",
"eslint:recommended",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
"ignorePatterns": ["node_modules/*", "lib/*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"prettier",
"@typescript-eslint",
"jest"
],
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"no-underscore-dangle": "off"
}
"env": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: replace with actual eslint package we are creating here

"node": true,
"es6": true,
"jest": true
},
"extends": [
"standard",
"eslint:recommended",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
"ignorePatterns": ["node_modules/*", "lib/*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"prettier",
"@typescript-eslint",
"jest"
],
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"no-underscore-dangle": "off"
}
}

19 changes: 19 additions & 0 deletions backend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: change this for built

"noImplicitAny": true,
"sourceMap": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"preserveSymlinks": true,
"inlineSources": true,
"removeComments": true,
"forceConsistentCasingInFileNames": true,
"strict": true
},
"include": ["src"],
"exclude": ["node_modules"]
}
24 changes: 24 additions & 0 deletions eslint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @bufferapp/eslint-config

This is the standard ESLint config files for the projects within the @bufferapp
GitHub organization.

## Usage

```console
npm install --save-dev @bufferapp/eslint-config eslint
# or
yarn add -D @bufferapp/eslint-config eslint
```

NOTE: We will need to define custom installation instructions for front-end
and backend-based configs, depending on those we will have different
`peerDependencies` for the ESLint configs.

And then, on your `.eslintrc` use

```
"extends": "@bufferapp/eslint-config-backend"
#or
"extends": "@bufferapp/eslint-config-frontend"
```
28 changes: 28 additions & 0 deletions eslint/backend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
extends: [
"./index.js",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
plugins: [
"typescript-eslint",
],
parser: "@typescript-eslint/parser",
ignorePatterns: ["node_modules/*", "built/*", "lib/*", "build/*"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should standardize our tsconfig outDir folder for all repositories. Right now, we have: lib, build, and built depending on repos. I would go for built 😊

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

built sounds good to me!

env: {
node: true,
es6: true,
jest: true,
},
rules: {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"no-underscore-dangle": "off"
}
Comment on lines +17 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tempted to add these rules to the index.js as they should be applied to both FE and BE :in my opinion.

}
15 changes: 15 additions & 0 deletions eslint/frontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
extends: [
"./index.js",
"plugin:react/recommended",
"prettier/react"
],
plugins: [
"react",
],
env: {
browser: true,
es6: true,
jest: true,
}
}
13 changes: 13 additions & 0 deletions eslint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
extends: [
"standard",
"eslint:recommended",
"prettier",
],
parserOptions: {
ecmaVersion: 2018,
sourceType: "module"
},
plugins: ["prettier", "jest"],
}

14 changes: 14 additions & 0 deletions eslint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@bufferapp/eslint-config-bufferapp",
"version": "0.0.1",
"description": "This package provides Buffer's ESLint as an extensible shared config, and specific backend/frontend setups.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Mike San Román <[email protected]>",
"license": "ISC",
"peerDependencies": {
"eslint": ">= 6"
}
}
17 changes: 17 additions & 0 deletions prettier/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @bufferapp/prettier-config

This is the standard Prettier config file for the projects within the @bufferapp GitHub organization.

## Usage

```console
npm install --save-dev @bufferapp/prettier-config prettier
# or
yarn add -D @bufferapp/prettier-config prettier
```

And then, on your `package.json` use

```
"prettier": "@bufferapp/prettier-config"
```
7 changes: 7 additions & 0 deletions prettier/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
semi: false,
singleQuote: true,
trailingComma: "all",
tabWidth: 2,
bracketSpacing: true
}
5 changes: 5 additions & 0 deletions prettier/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions prettier/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@bufferapp/prettier-config",
"version": "0.0.1",
"description": "Buffer standard Prettier configuration",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Mike San Román <[email protected]>",
"license": "ISC",
"peerDependencies": {
"prettier": "^2.0.5"
}
}