1- // Generated using recommended approach
2- // https://code.visualstudio.com/api/advanced-topics/tslint-eslint-migration
3- module . exports = {
4- "env" : {
5- "browser" : true ,
6- "es6" : true ,
7- "node" : true
8- } ,
9- "extends" : [
10- "plugin:@typescript-eslint/recommended" ,
11- "plugin:@typescript-eslint/recommended-requiring-type-checking"
1+ import js from '@eslint/js' ;
2+ import typescript from '@typescript-eslint/eslint-plugin' ;
3+ import typescriptParser from '@typescript-eslint/parser' ;
4+ import jsdoc from 'eslint-plugin-jsdoc' ;
5+ import preferArrow from 'eslint-plugin-prefer-arrow' ;
6+ import importPlugin from 'eslint-plugin-import' ;
7+ import globals from 'globals' ;
8+
9+ export default [
10+ js . configs . recommended ,
11+ {
12+ files : [ '**/*.{js,ts,tsx}' ] ,
13+ ignores : [
14+ '**/*.test*' ,
15+ '**/test/**/*'
1216 ] ,
13- "parser" : "@typescript-eslint/parser" ,
14- "parserOptions" : {
15- "project" : "tsconfig.json" ,
16- "sourceType" : "module"
17+ languageOptions : {
18+ parser : typescriptParser ,
19+ parserOptions : {
20+ project : 'tsconfig.json' ,
21+ sourceType : 'module'
22+ } ,
23+ globals : {
24+ ...globals . browser ,
25+ ...globals . node ,
26+ ...globals . es20222 ,
27+ }
1728 } ,
18- "plugins" : [
19- "eslint-plugin-jsdoc" ,
20- "eslint-plugin-prefer-arrow" ,
21- "@typescript-eslint" ,
22- "import" ,
23- ] ,
24- /**
25- * ESLint rules
26- *
27- * All available rules: http://eslint.org/docs/rules/
28- *
29- * Rules take the following form:
30- * 'rule-name', [severity, { opts }]
31- * Severity: 2 == error, 1 == warning, 0 == off.
32- */
33- 'rules' : {
34- /**
35- * Enforced rules
36- */
37-
38-
39- // syntax preferences
40- 'quotes' : [ 2 , 'single' , { 'avoidEscape' : true , 'allowTemplateLiterals' : true } ] ,
41- 'semi' : 2 ,
42- 'no-extra-semi' : 2 ,
43- 'comma-style' : [ 2 , 'last' ] ,
44- 'wrap-iife' : [ 2 , 'inside' ] ,
45- 'spaced-comment' : [ 2 , 'always' , { 'markers' : [ '*' ] } ] ,
46- 'eqeqeq' : [ 2 ] ,
47- 'accessor-pairs' : [ 2 , { 'getWithoutSet' : false , 'setWithoutGet' : false } ] ,
48- 'curly' : 2 ,
49- 'new-parens' : 2 ,
50- 'func-call-spacing' : 2 ,
51- 'arrow-parens' : [ 2 , 'as-needed' ] ,
52- 'eol-last' : 2 ,
53-
54- // anti-patterns
55- 'no-caller' : 2 ,
56- // MSFT: Not supported by esprima which is used by localization scripts.
57- //no-case-declarations': 2,
58- 'no-cond-assign' : 2 ,
59- 'no-console' : [ 2 , { 'allow' : [ 'assert' , 'context' , 'error' , 'timeStamp' , 'time' , 'timeEnd' , 'warn' ] } ] ,
60- 'no-debugger' : 2 ,
61- 'no-dupe-keys' : 2 ,
62- 'no-duplicate-case' : 2 ,
63- 'no-else-return' : [ 2 , { 'allowElseIf' : false } ] ,
64- 'no-empty-character-class' : 2 ,
65- 'no-global-assign' : 2 ,
66- 'no-implied-eval' : 2 ,
67- 'no-labels' : 2 ,
68- 'no-multi-str' : 2 ,
69- 'no-new-object' : 2 ,
70- 'no-octal-escape' : 2 ,
71- 'no-self-compare' : 2 ,
72- 'no-shadow-restricted-names' : 2 ,
73- 'no-unreachable' : 2 ,
74- 'no-unsafe-negation' : 2 ,
75- 'no-unused-vars' : [ 2 , { 'args' : 'none' , 'vars' : 'local' } ] ,
76- 'no-var' : 2 ,
77- 'no-with' : 2 ,
78- 'prefer-const' : 2 ,
79- 'radix' : 2 ,
80- 'valid-typeof' : 2 ,
81- 'no-return-assign' : [ 2 , 'always' ] ,
82-
83- // es2015 features
84- 'require-yield' : 2 ,
85- 'template-curly-spacing' : [ 2 , 'never' ] ,
86-
87- // spacing details
88- 'space-infix-ops' : 2 ,
89- 'space-in-parens' : [ 2 , 'never' ] ,
90- 'space-before-function-paren' : [ 2 , { 'anonymous' : 'never' , 'named' : 'never' , 'asyncArrow' : 'always' } ] ,
91- 'no-whitespace-before-property' : 2 ,
92- 'keyword-spacing' : [
93- 2 , {
94- 'overrides' : {
95- 'if' : { 'after' : true } ,
96- 'else' : { 'after' : true } ,
97- 'for' : { 'after' : true } ,
98- 'while' : { 'after' : true } ,
99- 'do' : { 'after' : true } ,
100- 'switch' : { 'after' : true } ,
101- 'return' : { 'after' : true }
102- }
29+ plugins : {
30+ '@typescript-eslint' : typescript ,
31+ 'jsdoc' : jsdoc ,
32+ 'prefer-arrow' : preferArrow ,
33+ 'import' : importPlugin
34+ } ,
35+ rules : {
36+ // Apply TypeScript recommended rules manually
37+ ...typescript . configs . recommended . rules ,
38+ ...typescript . configs [ 'recommended-requiring-type-checking' ] . rules ,
39+
40+ // Let TypeScript handle undefined variables
41+ 'no-undef' : 'off' ,
42+
43+ // syntax preferences
44+ 'quotes' : [ 'error' , 'single' , { 'avoidEscape' : true , 'allowTemplateLiterals' : true } ] ,
45+ 'semi' : 'error' ,
46+ 'no-extra-semi' : 'error' ,
47+ 'comma-style' : [ 'error' , 'last' ] ,
48+ 'wrap-iife' : [ 'error' , 'inside' ] ,
49+ 'spaced-comment' : [ 'error' , 'always' , { 'markers' : [ '*' ] } ] ,
50+ 'eqeqeq' : [ 'error' ] ,
51+ 'accessor-pairs' : [ 'error' , { 'getWithoutSet' : false , 'setWithoutGet' : false } ] ,
52+ 'curly' : 'error' ,
53+ 'new-parens' : 'error' ,
54+ 'func-call-spacing' : 'error' ,
55+ 'arrow-parens' : [ 'error' , 'as-needed' ] ,
56+ 'eol-last' : 'error' ,
57+
58+ // anti-patterns
59+ 'no-caller' : 'error' ,
60+ 'no-cond-assign' : 'error' ,
61+ 'no-console' : [ 'error' , { 'allow' : [ 'assert' , 'context' , 'error' , 'timeStamp' , 'time' , 'timeEnd' , 'warn' ] } ] ,
62+ 'no-debugger' : 'error' ,
63+ 'no-dupe-keys' : 'error' ,
64+ 'no-duplicate-case' : 'error' ,
65+ 'no-else-return' : [ 'error' , { 'allowElseIf' : false } ] ,
66+ 'no-empty-character-class' : 'error' ,
67+ 'no-global-assign' : 'error' ,
68+ 'no-implied-eval' : 'error' ,
69+ 'no-labels' : 'error' ,
70+ 'no-multi-str' : 'error' ,
71+ 'no-new-object' : 'error' ,
72+ 'no-octal-escape' : 'error' ,
73+ 'no-self-compare' : 'error' ,
74+ 'no-shadow-restricted-names' : 'error' ,
75+ 'no-unreachable' : 'error' ,
76+ 'no-unsafe-negation' : 'error' ,
77+ 'no-var' : 'error' ,
78+ 'no-with' : 'error' ,
79+ 'prefer-const' : 'error' ,
80+ 'radix' : 'error' ,
81+ 'valid-typeof' : 'error' ,
82+ 'no-return-assign' : [ 'error' , 'always' ] ,
83+
84+ // es2015 features
85+ 'require-yield' : 'error' ,
86+ 'template-curly-spacing' : [ 'error' , 'never' ] ,
87+
88+ // spacing details
89+ 'space-infix-ops' : 'error' ,
90+ 'space-in-parens' : [ 'error' , 'never' ] ,
91+ 'space-before-function-paren' : [ 'error' , { 'anonymous' : 'never' , 'named' : 'never' , 'asyncArrow' : 'always' } ] ,
92+ 'no-whitespace-before-property' : 'error' ,
93+ 'keyword-spacing' : [
94+ 'error' , {
95+ 'overrides' : {
96+ 'if' : { 'after' : true } ,
97+ 'else' : { 'after' : true } ,
98+ 'for' : { 'after' : true } ,
99+ 'while' : { 'after' : true } ,
100+ 'do' : { 'after' : true } ,
101+ 'switch' : { 'after' : true } ,
102+ 'return' : { 'after' : true }
103103 }
104- ] ,
105- 'arrow-spacing' : [ 2 , { 'after' : true , 'before' : true } ] ,
106-
107- // file whitespace
108- 'no-multiple-empty-lines' : [ 2 , { 'max' : 2 } ] ,
109- 'no-mixed-spaces-and-tabs' : 2 ,
110- 'no-trailing-spaces' : 2 ,
111- 'linebreak-style' : [ 2 , process . platform === 'win32' ? 'windows' : 'unix' ] ,
112-
113- /**
114- * Disabled, aspirational rules
115- */
116-
117-
118- 'indent' : [ 0 , 2 , { 'SwitchCase' : 1 , 'CallExpression' : { 'arguments' : 2 } , 'MemberExpression' : 2 } ] ,
119-
120- // brace-style is disabled, as eslint cannot enforce 1tbs as default, but allman for functions
121- 'brace-style' : [ 0 , 'allman' , { 'allowSingleLine' : true } ] ,
122-
123- // key-spacing is disabled, as some objects use value-aligned spacing, some not.
124- 'key-spacing' : [ 0 , { 'beforeColon' : false , 'afterColon' : true , 'align' : 'value' } ] ,
125- // quote-props is diabled, as property quoting styles are too varied to enforce.
126- 'quote-props' : [ 0 , 'as-needed' ] ,
127-
128- // no-implicit-globals will prevent accidental globals
129- 'no-implicit-globals' : [ 0 ] ,
130-
131- '@typescript-eslint/explicit-member-accessibility' : [ 0 ] ,
132- '@typescript-eslint/no-explicit-any' : 2 ,
133- '@typescript-eslint/restrict-template-expressions' : 0 ,
134-
135- // Closure does not properly typecheck default exports
136- 'import/no-default-export' : 2 ,
137- } ,
138- 'overrides' : [ {
139- 'files' : [ '*.ts' ] ,
140- 'rules' : {
141- '@typescript-eslint/explicit-member-accessibility' : [ 2 , { 'accessibility' : 'no-public' } ] ,
142- 'comma-dangle' : [ 2 , 'always-multiline' ] ,
143- // run just the TypeScript unused-vars rule, else we get duplicate errors
144- 'no-unused-vars' : 0 ,
145- '@typescript-eslint/no-unused-vars' : [ 2 , { 'argsIgnorePattern' : '^_' } ] ,
146104 }
147- } ]
148- } ;
105+ ] ,
106+ 'arrow-spacing' : [ 'error' , { 'after' : true , 'before' : true } ] ,
107+
108+ // file whitespace
109+ 'no-multiple-empty-lines' : [ 'error' , { 'max' : 2 } ] ,
110+ 'no-mixed-spaces-and-tabs' : 'error' ,
111+ 'no-trailing-spaces' : 'error' ,
112+ 'linebreak-style' : [ 'error' , process . platform === 'win32' ? 'windows' : 'unix' ] ,
113+
114+ // Disabled rules
115+ 'indent' : 'off' ,
116+ 'brace-style' : 'off' ,
117+ 'key-spacing' : 'off' ,
118+ 'quote-props' : 'off' ,
119+ 'no-implicit-globals' : 'off' ,
120+
121+ // TypeScript rules (overrides to the recommended configs)
122+ '@typescript-eslint/explicit-member-accessibility' : 'off' ,
123+ '@typescript-eslint/no-explicit-any' : 'error' ,
124+ '@typescript-eslint/restrict-template-expressions' : 'off' ,
125+ '@typescript-eslint/no-unsafe-call' : 'off' ,
126+
127+ // skiping variables that start with underscore
128+ 'no-unused-vars' : 'off' , // Turn off for TypeScript files
129+ '@typescript-eslint/no-unused-vars' : [ 'error' , { 'argsIgnorePattern' : '^_' , 'varsIgnorePattern' : '^_' } ] ,
130+
131+ // Import rules
132+ 'import/no-default-export' : 'error'
133+ }
134+ }
135+ ] ;
0 commit comments