Skip to content

Commit

Permalink
feat(#128): antfu/eslint code formating
Browse files Browse the repository at this point in the history
  • Loading branch information
barthofu committed Feb 9, 2024
1 parent ca90949 commit 54d2739
Show file tree
Hide file tree
Showing 5 changed files with 3,384 additions and 111 deletions.
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
],
}
44 changes: 43 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",

// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,

// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
// "editor.codeActionsOnSave": {
// "source.fixAll.eslint": "explicit",
// "source.organizeImports": "never"
// },

// Silent the stylistic rules in you IDE, but still auto fix them
// "eslint.rules.customizations": [
// { "rule": "style/*", "severity": "off" },
// { "rule": "format/*", "severity": "off" },
// { "rule": "*-indent", "severity": "off" },
// { "rule": "*-spacing", "severity": "off" },
// { "rule": "*-spaces", "severity": "off" },
// { "rule": "*-order", "severity": "off" },
// { "rule": "*-dangle", "severity": "off" },
// { "rule": "*-newline", "severity": "off" },
// { "rule": "*quotes", "severity": "off" },
// { "rule": "*semi", "severity": "off" }
// ],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml"
]
}
131 changes: 131 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
const antfu = require('@antfu/eslint-config').default
const pluginSimpleImportSort = require('eslint-plugin-simple-import-sort')

module.exports = antfu(
{
stylistic: {
indent: 'tab',
quotes: 'single',
semi: false,

// https://eslint.style/packages/ts
overrides: {
'curly': 'off',
'style/block-spacing': ['error', 'always'],
'style/brace-style': ['error', '1tbs'],
'style/comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
}],
'style/comma-spacing': ['error', { before: false, after: true }],
'style/func-call-spacing': ['error', 'never'],
'style/lines-around-comment': ['error', {
beforeBlockComment: true,
afterBlockComment: false,
beforeLineComment: false,
afterLineComment: false,
allowBlockStart: true,
allowBlockEnd: true,
allowObjectStart: true,
allowObjectEnd: true,
allowArrayStart: true,
allowArrayEnd: true,
}],
'style/member-delimiter-style': ['error', {
multiline: {
delimiter: 'none',
requireLast: true,
},
singleline: {
delimiter: 'comma',
requireLast: false,
},
}],
'style/object-curly-spacing': ['error', 'always'],
'style/padded-blocks': ['error', 'always'],
'style/padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'class' },
{ blankLine: 'always', prev: '*', next: 'block' },
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: '*', next: 'case' },
{ blankLine: 'always', prev: '*', next: 'default' },
],
'style/quote-props': ['error', 'consistent-as-needed'],

// 'style/space-before-blocks': ['error', 'always'],
'style/type-annotation-spacing': ['error', {
before: false,
after: true,
overrides: {
arrow: { before: true, after: true },
},
}],

},
},

jsonc: false,
yaml: false,

linterOptions: {
reportUnusedDisableDirectives: false,
},

ignores: [
'node_modules',
'build',
'logs',
'database',
],
},
{
plugins: {
'simple-import-sort': pluginSimpleImportSort,
},
rules: {
'ts/ban-ts-comment': 'off',
'ts/consistent-type-imports': 'off',
'eslint-comments/no-unlimited-disable': 'off',
'eslint-comments/no-unused-disable': 'off',

'no-unused-vars': 'off', // prefer unused-imports/no-unused-vars
'unused-imports/no-unused-vars': 'warn',

'no-console': 'off',

// Preferred "simple-import-sort" over "import/order"
// See: https://github.com/lydell/eslint-plugin-simple-import-sort#how-is-this-rule-different-from-importorder
'sort-imports': 'off',
'import/order': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [
// Side effect imports.
['^\\u0000'],
// Node.js builtins prefixed with `node:`.
['^node:'],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
['^@\\w'],
['^\\w'],
// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything not matched in another group.
['^'],
// Relative imports.
// Anything that starts with a dot.
['^\\.'],
// TypeScript import assignments.
['^\\u0001', '^\\u0002'],
],
},
],
'simple-import-sort/exports': 'off',
'import/no-duplicates': 'error',
},
}
)
Loading

0 comments on commit 54d2739

Please sign in to comment.