Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving maintainability: ESLint and Prettier #193

Merged
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
63bd052
Removed unused fields from `package.json`: `main` and `author` from `…
mrauhu Jan 4, 2022
8bd9eee
Moved Prettier config from `package.json` to `.prettierrc` file
mrauhu Jan 4, 2022
bdb15c8
Removed `indent_style`, `indent_size` and `insert_final_newline` from…
mrauhu Jan 4, 2022
dba7255
Removed `.nvmrc`, it's pointing to old non-LTS version of Node.js
mrauhu Jan 4, 2022
0cde2b6
Using 2 spaces indent for `package.json` file
mrauhu Jan 4, 2022
372c704
Setup `engines.node` version to be greater or equal of current LTS ve…
mrauhu Jan 4, 2022
0e43659
Setup two spaces indent for `*.json` files in the `.editorconfig`
mrauhu Jan 4, 2022
9de9865
Created `.eslintignore` file
mrauhu Jan 4, 2022
4e2e26f
Installed ESLint with plugins as dev dependencies:
mrauhu Jan 4, 2022
7aab927
Created ESLint config in the `.eslintrc.js` file
mrauhu Jan 4, 2022
fc4996a
Set max line length to 120
mrauhu Jan 4, 2022
34a690b
Using ESlint for linting. Renamed scripts: from `lint` to `lint-ci`, …
mrauhu Jan 5, 2022
c8e135c
Removed `cross-env` package and usages
mrauhu Jan 5, 2022
44fce07
Removed `NODE_ENV=production` from `lint*` scripts
mrauhu Jan 5, 2022
22c3b98
Updated Prettier config, set `printWidth` to `120` (optionally, but f…
mrauhu Jan 5, 2022
49ac41c
Setup `lint-ci` for future usage in GitHub Actions.
mrauhu Jan 5, 2022
4ce1418
Revert "Updated Prettier config, set `printWidth` to `120` (optionall…
mrauhu Jan 6, 2022
aed5008
Created `.nvmrc` with the latest Node.js LTS version
mrauhu Jan 6, 2022
530b6b1
Installed TypeScript and ESLint dev dependencies:
mrauhu Jan 5, 2022
9033f73
Configure TypeScript ESLint parser and plugin
mrauhu Jan 5, 2022
eca612e
Added `*.ts` and `*.tsx` file patterns to `lint*` scripts
mrauhu Jan 5, 2022
6e9c8fe
Fix: disable `no-unused-vars` ESLint rule for TypeScript files
mrauhu Jan 5, 2022
2cc15fa
Ignoring comments for the `max-len` ESLint rule
mrauhu Jan 5, 2022
651c8f3
Enabled `no-console` and `no-debugger` warnings in development mode
mrauhu Jan 6, 2022
5a625e1
Removed `plugin:prettier/recommended` and put ESLint config `prettier…
mrauhu Jan 6, 2022
479236b
Updated `package.json`: run Prettier before ESLint
mrauhu Jan 6, 2022
d86d773
Removed `eslint-plugin-prettier` from `package.json`
mrauhu Jan 6, 2022
fdd592e
Updated `prettier` package
mrauhu Jan 6, 2022
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
10 changes: 7 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
root=true

[*]
indent_style = space
indent_size = 4
charset = utf-8
max_line_length = 120
mrauhu marked this conversation as resolved.
Show resolved Hide resolved
ij_visual_guides = 120
end_of_line = lf
insert_final_newline = true

# We are not running ESLint for JSON files, but we need to maintain the same style
[*.json]
indent_style = space
indent_size = 2
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github
.yarn
storybook-static
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
root: true,
env: {
node: true,
},
parserOptions: {
ecmaVersion: 2021,
},
plugins: ['only-warn'],
mrauhu marked this conversation as resolved.
Show resolved Hide resolved
extends: ['eslint:recommended', 'plugin:prettier/recommended', 'plugin:storybook/recommended'],
rules: {
// Set line length to 120
'max-len': ['error', { code: 120 }],
mrauhu marked this conversation as resolved.
Show resolved Hide resolved
// Prevent warnings when debugging
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
},
overrides: [
// Fix: import and export, see https://github.com/AtomLinter/linter-eslint/issues/462
// TODO: Remove temporary fix after adding `plugin:@typescript-eslint/eslint-recommended`
{
files: 'packages/example-*/**/*.*',
parserOptions: {
sourceType: 'module',
},
},
],
};
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v15.14.0
mrauhu marked this conversation as resolved.
Show resolved Hide resolved
lts/*
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
49 changes: 26 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{
"name": "storybook-builder-vite-parent",
"version": "0.1.13",
"description": "An experimental plugin to run and build Storybooks with Vite",
"main": "index.js",
"author": "",
"license": "MIT",
"scripts": {
"lint": "prettier --check .",
"format": "prettier --write ."
},
"workspaces": [
"packages/example-react",
"packages/example-svelte",
"packages/example-vue",
"packages/example-workspaces",
"packages/storybook-builder-vite"
],
"prettier": {
"singleQuote": true
},
"devDependencies": {
"prettier": "^2.3.2"
}
"name": "storybook-builder-vite-parent",
"version": "0.1.13",
"description": "An experimental plugin to run and build Storybooks with Vite",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"lint": "eslint \"packages/*/**/*.{js,jsx,mjs,cjs}\" --fix",
mrauhu marked this conversation as resolved.
Show resolved Hide resolved
"lint-ci": "eslint \"packages/*/**/*.{js,jsx,mjs,cjs}\" --max-warnings=0"
},
"workspaces": [
"packages/example-react",
"packages/example-svelte",
"packages/example-vue",
"packages/example-workspaces",
"packages/storybook-builder-vite"
],
"devDependencies": {
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-only-warn": "^1.0.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-storybook": "^0.5.5",
"prettier": "^2.3.2"
}
}
Loading