Skip to content

Commit

Permalink
refactor: structure improvements
Browse files Browse the repository at this point in the history
add eslint, prettier, sass, pug
  • Loading branch information
selimdoyranli committed May 8, 2023
1 parent 0efb86b commit a4de217
Show file tree
Hide file tree
Showing 25 changed files with 3,317 additions and 1,100 deletions.
11 changes: 11 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dist
/vue2
/vue3
/docs
/meta
coverage
node_modules
package.json
package-lock.json
yarn.lock
pnpm-lock.yaml
93 changes: 93 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
jest: true
},
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
},
warnOnUnsupportedTypeScriptVersion: false,
templateTokenizer: {
pug: 'vue-eslint-parser-template-tokenizer-pug'
}
},
extends: ['plugin:vue/strongly-recommended', 'eslint-config-prettier', 'prettier'],
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': [
'error',
{
endOfLine: 'crlf'
}
],
'max-len': [
'error',
{
code: 150,
ignoreComments: true,
ignoreStrings: true,
ignoreTemplateLiterals: true
}
],
'no-multiple-empty-lines': [2, { max: 2 }],
semi: ['error', 'never'],
'arrow-parens': ['error', 'as-needed'],
'no-extend-native': 'off',
'space-before-function-paren': 'off',
camelcase: 'off',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-throw-literal': 'off',
'no-param-reassign': [
'error',
{
props: false
}
],
'@typescript-eslint/no-var-requires': 'off',
'vue/component-definition-name-casing': ['error', 'PascalCase'],
'vue/multi-word-component-names': 'off',
'vue/component-tags-order': ['error', { order: ['template', 'script', 'style', 'docs'] }],
'vue/padding-line-between-blocks': ['error'],
'vue/block-lang': [
'error',
{
script: {
allowNoLang: true,
lang: 'ts'
},
style: {
allowNoLang: true,
lang: 'scss'
}
}
],
'vue/no-empty-component-block': ['error'],
'vue/no-static-inline-styles': 'off',
'vue/require-prop-types': ['error'],
'vue/require-default-prop': ['error'],
'vue/attribute-hyphenation': ['error', 'always'],
'vue/v-on-event-hyphenation': ['error', 'always'],
'vue/html-self-closing': 'off',
'vue/no-v-html': 'off',
'vue/order-in-components': ['error'],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: '*', next: 'if' },
{ blankLine: 'always', prev: '*', next: 'switch' },
{ blankLine: 'always', prev: '*', next: 'for' },
{ blankLine: 'always', prev: '*', next: 'function' },
{ blankLine: 'never', prev: 'import', next: 'import' },
{ blankLine: 'always', prev: 'import', next: 'export' },
{ blankLine: 'always', prev: 'expression', next: 'export' },
{ blankLine: 'always', prev: 'import', next: 'expression' }
]
}
}
1 change: 1 addition & 0 deletions .huskyrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
hooks: {
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
'pre-commit': 'lint-staged'
}
}
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./demo
./dev
./docs
.vscode
11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dist
/vue2
/vue3
/docs
/meta
coverage
node_modules
package.json
package-lock.json
yarn.lock
pnpm-lock.yaml
60 changes: 60 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module.exports = {
pugPrintWidth: 140,
pugSingleQuote: false,
pugAttributeSeparator: 'none',
pugEmptyAttributes: 'none',
singleQuote: true,
printWidth: 140,
trailingComma: 'none',
tabWidth: 2,
semi: false,
bracketSpacing: true,
arrowParens: 'avoid',
pugSortAttributesBeginning: [
'^cols$',
'^v-else$',
'^v-for$',
'^:key$',
'^v-if$',
'^v-else-if$',
'^v-on$',
'^v-bind$',
'^ref$',
'^v-model',
'^name$',
'^:?type$',
'^:value$',
'^v-text$',
'^:?label$',
'^:headers$',
'^:items$',
'^:?item-text$',
'^:?item-value$',
'^:?item-disabled$',
'^:?placeholder$',
'^:?src$',
'^:?color$',
'^:?text-color$',
'^:?icon$',
'^:?small$'
],
pugSortAttributesEnd: [
'^:?hint$',
'^:?persistent-hint$',
'^prepend-',
'^@click:prepend',
'^append-',
'^@click:append',
'^:to$',
'^exact$',
'^:(?!(width|height|loading|disabled|data-))',
'^target$',
'^:?width$',
'^:?height$',
'^:loading$',
'^:disabled$',
'^:?data-',
'^@click',
'^@'
]
}
8 changes: 8 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dist
/vue2
/docs
/meta
*.min.*
assets/**/*/vendor
static/
public/
51 changes: 51 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module.exports = {
extends: [
//https://github.com/constverum/stylelint-config-rational-order
'stylelint-config-rational-order',
// https://github.com/shannonmoeller/stylelint-config-prettier
'stylelint-config-prettier'
],
overrides: [
{
customSyntax: 'postcss-scss',
files: ['**/*.{css,sass,scss,less,stylus}']
},
{
customSyntax: 'postcss-html',
files: ['*.vue', '**/*.vue']
}
],
plugins: [
// https://github.com/kristerkari/stylelint-scss#list-of-rules
'stylelint-scss',
// https://github.com/hudochenkov/stylelint-order
'stylelint-order',
'stylelint-config-rational-order/plugin'
],
rules: {
indentation: [
2,
{
baseIndentLevel: 0
}
],
'color-named': 'never',
'color-function-notation': 'legacy',
'at-rule-no-unknown': null,
'declaration-empty-line-before': [
'always',
{
except: ['after-declaration'],
ignore: ['after-comment', 'first-nested', 'inside-single-line-block'],
severity: 'warning'
}
],
'rule-empty-line-before': [
'always',
{
ignore: ['after-comment', 'first-nested'],
severity: 'warning'
}
]
}
}
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"stylelint.vscode-stylelint",
"editorconfig.editorconfig",
"octref.vetur",
"fallenmax.mithril-emmet"
]
}
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"emmet.showAbbreviationSuggestions": true,
"emmet.showExpandedAbbreviation": "always",
"emmet.includeLanguages": {
"vue-html": "html",
"vue": "jade"
},
"files.insertFinalNewline": true,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"css.validate": false,
"less.validate": false,
"scss.validate": false,
"stylelint.validate": ["css", "scss", "html", "vue"],
"editor.codeActionsOnSave": {
"source.fixAll.stylelint": true,
"source.fixAll.eslint": true
},
"editor.tabSize": 2,
"explorer.compactFolders": false
}
12 changes: 6 additions & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const devPresets = ['@vue/babel-preset-app'];
const devPresets = ['@vue/babel-preset-app']
const buildPresets = [
[
'@babel/preset-env',
Expand All @@ -8,10 +8,10 @@ const buildPresets = [
// include: [
// /(optional-chaining|nullish-coalescing)/
// ],
},
}
],
'@babel/preset-typescript',
];
'@babel/preset-typescript'
]
module.exports = {
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
};
presets: process.env.NODE_ENV === 'development' ? devPresets : buildPresets
}
Loading

0 comments on commit a4de217

Please sign in to comment.