-
-
Notifications
You must be signed in to change notification settings - Fork 288
/
.eslintrc.js
66 lines (57 loc) · 2.84 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
const config = require('zotero-plugin/.eslintrc')
Object.assign(config.rules, {
'max-classes-per-file': 'off',
'no-console': 'error',
'no-new-func': 'off',
'no-underscore-dangle': [ 'error', { "allowAfterThis": true } ],
'prefer-template': 'off',
// '@stylistic/js/operator-linebreak': ['error', 'before' ],
'prefer-arrow/prefer-arrow-functions': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/member-ordering': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-unused-vars': [ 'error', { "argsIgnorePattern": "^_" } ],
'no-magic-numbers': 'off',
'max-len': [ 'warn', { code: 320 } ],
'prefer-arrow/prefer-arrow-functions': 'off',
'@stylistic/array-bracket-spacing': 'off',
'@stylistic/template-curly-spacing': 'off',
'@stylistic/quotes': ['error', 'single', { "avoidEscape": true }],
'@stylistic/lines-between-class-members': 'off',
})
const shell = require('shelljs')
const branch = (process.env.GITHUB_REF && process.env.GITHUB_REF.startsWith('refs/heads/'))
? process.env.GITHUB_REF.replace('refs/heads/', '')
: shell.exec('git rev-parse --abbrev-ref HEAD', { silent: true }).stdout.trim()
const no_restricted_syntax = {master: 'error', minlog: 'warn'}[branch] || 'off'
config.rules['no-restricted-syntax'] = [
{master: 'error'}[branch] || 'off',
{ selector: "CallExpression[callee.name='dump']", message: 'use of dump is not allowed' },
{ selector: "CallExpression[callee.object.name='Zotero'][callee.property.name='debug']", message: 'use of Zotero.debug is not allowed' },
{ selector: "CallExpression[callee.object.name='Zotero'][callee.property.name='logError']", message: 'use of Zotero.logError is not allowed' },
{ selector: "CallExpression[callee.object.name='log'][callee.property.name='debug']", message: 'use of log.debug is not allowed' },
{ selector: "CallExpression[callee.object.name='log'][callee.property.name='dump']", message: 'use of log.dump is not allowed' },
{ selector: "CallExpression[callee.name='trace']", message: 'use of trace is not allowed' },
]
config.ignorePatterns = [
'gen/**/*.ts',
'gen/**/*.js',
'setup/**/*.ts',
'setup/**/*.js',
'util/*.ts',
'minitests/*.ts',
'content/minitests/*.ts',
'zotero-odf-scan-plugin',
]
module.exports = config