はじめに
忘れそうな設定やコマンドたちを備忘録、自分用として残しておきます。
随時更新。
Nuxtの設定たち
ESlintとPrettierのオレオレ初期設定たち。
/.eslintrc.js
// 追記
rules: {
'prettier/prettier': 'error',
'no-multiple-empty-lines': ['error', { max: 1 }]
}
/.prettierrc
{
"printWidth": 100,
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"endOfLine": "lf"
}
ESlintのコマンド
ESlintとPrettierが競合したときに活躍する--fixコマンド。
$ node_modules/.bin/eslint --fix --ext .js,.vue --ignore-path .gitignore .
storybookの設定やコマンドたち。
nuxtを作ったディレクトリで以下のコマンド。
$ npx sb init
// storybookを立ち上げコマンド
$ yarn storybook
//.storiesを削除
storybookのディレクトリサンプル
.
├─front
│ ├─storybook
│ ├─components
│ │ ├─atoms
│ │ ├─button
│ │ ├─Button.vue
│ │ └─Button.stories.js
storybookの初期設定
/.storybook/main.js
module.exports = {
"stories": [
//⬇︎ componentsへ変更
"../components/**/*.stories.mdx",
"../components/**/*.stories.@(js|jsx|ts|tsx)"
]
}
storybookのサンプル
Button.vue
<template>
<button><slot/></button>
</template>
Button.stories.js
import { storiesOf } from '@storybook/vue'
import Button from './Button'
storiesOf('Atoms', module)
.add('Button', () => ({
components: { Button },
template: '<Button>ボタン</Button/>'
}))
Terminalの名前変えるやつ
/.zshrc
PS1="%1~ %# (好きな文字) "
エイリアス設定のやつ
$ vi .zshrc
# エイリアスサンプル
alias gi="git init"
$ :wq
$ source ~/.zshrc
gitのローカルブランチ名を変更する
$ git branch -m <古いブランチ名> <新しいブランチ名>
// 今開いているブランチをリネームする場合は、単純に新しいブランチ名を指定するだけ
$ git branch -m <新しいブランチ名>
gitのローカルブランチ名を削除する
$ git branch -d 削除したいブランチ
commit後に不必要なブランチ削除(データ削除)
$ git branch -D 削除したいブランチ
localstorageに保存、取得、削除
$ localStorage.setItem('myCat', 'Tom');
$ localStorage.getItem('myCat');
$ localStorage.removeItem('myCat');
$ localStorage.clear();
オブジェクト({})が空かどうかの判断
if (!Object.keys(obj).length) {
console.log('空やで');
}