forked from hexojs/hexo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
79 lines (77 loc) · 2.97 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const prettier = require('./.prettierrc.json');
// or using prettier config javascript
// const prettier = require('./.prettierrc');
/**
* @type {import('eslint').ESLint.ConfigData}
*/
const config = {
root: true, // Specifies your current project has own eslint rules without extends parent folder eslint rules
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
env: {
browser: true, // add support for browser js (window,document,location,etc)
amd: true, // add amd support
node: true // add node support (module.export,etc)
},
globals: {
dataLayer: true,
hexo: true,
jQuery: true,
$: true,
_: true
},
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module' // Allows for the use of imports
},
extends: [
'eslint:recommended', // uses eslint default recommended
'plugin:@typescript-eslint/eslint-recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:prettier/recommended' // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
// override rules for js files
overrides: [
{
files: ['*.js', '**/bin/**'],
rules: {
'no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
], // warn unused vars on js files
'no-var-requires': 'off', // disable require vars on js files
'@typescript-eslint/no-var-requires': 'off' // disable require vars warning on js files
}
}
],
// specify your desired rules for eslint
rules: {
'prettier/prettier': ['error', prettier],
'@typescript-eslint/explicit-function-return-type': 'off', // disable function without return type
'no-unused-vars': 'off', // disable original eslint unused-vars
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
], // enable typescript-eslint unused-vars and allow unused vars start with underscore (_)
'@typescript-eslint/no-explicit-any': 'off', // allow any types
'@typescript-eslint/no-this-alias': [
// rules for this binding
'error',
{
allowDestructuring: false, // Disallow `const { props, state } = this`; true by default
allowedNames: ['self', 'hexo'] // Allow `const self = this`; `[]` by default
}
],
// "arrow-body-style" and "prefer-arrow-callback" are two ESLint core rules that can cause issues with prettier/prettier plugin, so turn them off.
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off'
}
};
module.exports = config;