chore: init
This commit is contained in:
137
packages/common/index.js
Normal file
137
packages/common/index.js
Normal file
@@ -0,0 +1,137 @@
|
||||
module.exports = {
|
||||
plugins: [
|
||||
'@typescript-eslint',
|
||||
],
|
||||
parser: '@typescript-eslint/parser',
|
||||
extends: [
|
||||
'standard',
|
||||
'plugin:import/errors',
|
||||
'plugin:import/warnings',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
],
|
||||
plugins: [
|
||||
'unicorn',
|
||||
],
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
node: { extensions: ['.js', '.mjs'] }
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
// import
|
||||
'import/order': 'error',
|
||||
'import/first': 'error',
|
||||
'import/no-mutable-exports': 'error',
|
||||
'import/no-unresolved': 'off',
|
||||
|
||||
// Common
|
||||
'semi': [2, 'never'],
|
||||
'curly': [2, 'multi-or-nest', 'consistent'],
|
||||
'quotes': ['error', 'single'],
|
||||
'no-unused-vars': 'warn',
|
||||
'no-param-reassign': 'off',
|
||||
'array-bracket-spacing': ['error', 'never'],
|
||||
'brace-style': ['error', 'stroustrup', { 'allowSingleLine': true }],
|
||||
'block-spacing': ['error', 'always'],
|
||||
'camelcase': 'off',
|
||||
'comma-spacing': ['error', { before: false, after: true }],
|
||||
'comma-style': ['error', 'last'],
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'no-constant-condition': 'warn',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-cond-assign': ['error', 'always'],
|
||||
'func-call-spacing': ['off', 'never'],
|
||||
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
||||
'indent': ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],
|
||||
'no-restricted-syntax': [
|
||||
'error',
|
||||
'DebuggerStatement',
|
||||
'ForInStatement',
|
||||
'LabeledStatement',
|
||||
'WithStatement',
|
||||
],
|
||||
'no-spaced-func': 'error',
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
'no-return-await': 'off',
|
||||
'prefer-const': ['error', {
|
||||
'destructuring': 'any',
|
||||
'ignoreReadBeforeAssign': false
|
||||
}],
|
||||
|
||||
// es6
|
||||
'no-var': 'error',
|
||||
'prefer-const': ['error', {
|
||||
destructuring: 'any',
|
||||
ignoreReadBeforeAssign: true,
|
||||
}],
|
||||
'prefer-arrow-callback': ['error', {
|
||||
allowNamedFunctions: false,
|
||||
allowUnboundThis: true,
|
||||
}],
|
||||
'object-shorthand': ['error', 'always', {
|
||||
ignoreConstructors: false,
|
||||
avoidQuotes: true,
|
||||
}],
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'prefer-template': 'error',
|
||||
'template-curly-spacing': 'error',
|
||||
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
|
||||
'generator-star-spacing': 'off',
|
||||
|
||||
// best-practice
|
||||
'array-callback-return': 'error',
|
||||
'block-scoped-var': 'error',
|
||||
'consistent-return': 'off',
|
||||
'complexity': ['off', 11],
|
||||
'eqeqeq': ['error', 'allow-null'],
|
||||
'no-alert': 'warn',
|
||||
'no-case-declarations': 'error',
|
||||
'no-multi-spaces': 'error',
|
||||
'no-multi-str': 'error',
|
||||
'no-with': 'error',
|
||||
'no-void': 'error',
|
||||
'no-useless-escape': 'error',
|
||||
'vars-on-top': 'error',
|
||||
'require-await': 'off',
|
||||
'no-return-assign': 'off',
|
||||
'operator-linebreak': [2, 'before'],
|
||||
|
||||
// TS
|
||||
'@typescript-eslint/no-unused-vars': [2, { args: 'none' }],
|
||||
'@typescript-eslint/indent': ['error', 2],
|
||||
'@typescript-eslint/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }],
|
||||
'@typescript-eslint/type-annotation-spacing': ['error', {}],
|
||||
'@typescript-eslint/camelcase': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-member-accessibility': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
|
||||
// unicorns
|
||||
// Pass error message when throwing errors
|
||||
'unicorn/error-message': 'error',
|
||||
// Uppercase regex escapes
|
||||
'unicorn/escape-case': 'error',
|
||||
// Array.isArray instead of instanceof
|
||||
'unicorn/no-array-instanceof': 'error',
|
||||
// Prevent deprecated `new Buffer()`
|
||||
'unicorn/no-new-buffer': 'error',
|
||||
// Keep regex literals safe!
|
||||
'unicorn/no-unsafe-regex': 'off',
|
||||
// Lowercase number formatting for octal, hex, binary (0x12 instead of 0X12)
|
||||
'unicorn/number-literal-case': 'error',
|
||||
// ** instead of Math.pow()
|
||||
'unicorn/prefer-exponentiation-operator': 'error',
|
||||
// includes over indexOf when checking for existence
|
||||
'unicorn/prefer-includes': 'error',
|
||||
// String methods startsWith/endsWith instead of more complicated stuff
|
||||
'unicorn/prefer-starts-ends-with': 'error',
|
||||
// textContent instead of innerText
|
||||
'unicorn/prefer-text-content': 'error',
|
||||
// Enforce throwing type error when throwing error while checking typeof
|
||||
'unicorn/prefer-type-error': 'error',
|
||||
// Use new when throwing error
|
||||
'unicorn/throw-new-error': 'error',
|
||||
}
|
||||
}
|
32
packages/common/package.json
Normal file
32
packages/common/package.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@antfu/eslint-config",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"keywords": [],
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"lint": "eslint . --config=index.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"eslint": ">=5.16.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "1.11.0",
|
||||
"@typescript-eslint/parser": "^1.10.2",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.18.0",
|
||||
"eslint-plugin-node": "^9.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-unicorn": "^9.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.0.1",
|
||||
"standard-version": "^6.0.1"
|
||||
}
|
||||
}
|
10
packages/vue/index.js
Normal file
10
packages/vue/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
extends: [
|
||||
'@antfu/eslint-config',
|
||||
],
|
||||
plugins: [
|
||||
],
|
||||
rules: {
|
||||
}
|
||||
}
|
26
packages/vue/package.json
Normal file
26
packages/vue/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@antfu/eslint-config-vue",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"keywords": [],
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"lint": "eslint . --config=index.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"eslint": ">=5.16.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@antfu/eslint-config": "*",
|
||||
"eslint-plugin-nuxt": "0.4.3",
|
||||
"eslint-plugin-vue": "5.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.0.1"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user