Skip to content

Commit 4894af3

Browse files
committed
Add initial typescript config for eslint
1 parent fb7b743 commit 4894af3

File tree

9 files changed

+191
-37
lines changed

9 files changed

+191
-37
lines changed

Diff for: .eslintrc.yaml

+25-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@ ignorePatterns:
66
- /web_src/fomantic
77
- /public/assets/js
88

9+
parser: "@typescript-eslint/parser"
10+
911
parserOptions:
1012
sourceType: module
1113
ecmaVersion: latest
14+
project: true
15+
extraFileExtensions: [".vue"]
16+
17+
settings:
18+
import/extensions: [".js", ".ts"]
19+
import/parsers:
20+
"@typescript-eslint/parser": [".js", ".ts"]
21+
import/resolver:
22+
typescript: true
1223

1324
plugins:
1425
- "@eslint-community/eslint-plugin-eslint-comments"
@@ -103,6 +114,18 @@ overrides:
103114
- files: ["web_src/js/modules/fetch.js", "web_src/js/standalone/**/*"]
104115
rules:
105116
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression]
117+
- files: ["**/*.vue"]
118+
plugins:
119+
- eslint-plugin-vue
120+
- eslint-plugin-vue-scoped-css
121+
extends:
122+
- plugin:vue/vue3-recommended
123+
- plugin:vue-scoped-css/vue3-recommended
124+
rules:
125+
vue/attributes-order: [0]
126+
vue/html-closing-bracket-spacing: [2, {startTag: never, endTag: never, selfClosingTag: never}]
127+
vue/max-attributes-per-line: [0]
128+
vue/singleline-html-element-content-newline: [0]
106129

107130
rules:
108131
"@eslint-community/eslint-comments/disable-enable-pair": [2]
@@ -264,7 +287,7 @@ rules:
264287
i/no-internal-modules: [0]
265288
i/no-mutable-exports: [0]
266289
i/no-named-as-default-member: [0]
267-
i/no-named-as-default: [2]
290+
i/no-named-as-default: [0]
268291
i/no-named-default: [0]
269292
i/no-named-export: [0]
270293
i/no-namespace: [0]
@@ -274,7 +297,7 @@ rules:
274297
i/no-restricted-paths: [0]
275298
i/no-self-import: [2]
276299
i/no-unassigned-import: [0]
277-
i/no-unresolved: [2, {commonjs: true, ignore: ["\\?.+$", ^vitest/]}]
300+
i/no-unresolved: [2, {commonjs: true}]
278301
i/no-unused-modules: [2, {unusedExports: true}]
279302
i/no-useless-path-segments: [2, {commonjs: true}]
280303
i/no-webpack-loader-syntax: [2]

Diff for: Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,11 @@ lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig
373373

374374
.PHONY: lint-js
375375
lint-js: node_modules
376-
npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES)
376+
npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES)
377377

378378
.PHONY: lint-js-fix
379379
lint-js-fix: node_modules
380-
npx eslint --color --max-warnings=0 --ext js,vue $(ESLINT_FILES) --fix
380+
npx eslint --color --max-warnings=0 --ext js,ts,vue $(ESLINT_FILES) --fix
381381

382382
.PHONY: lint-css
383383
lint-css: node_modules

Diff for: package-lock.json

+121-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@
6767
"@stoplight/spectral-cli": "6.11.1",
6868
"@stylistic/eslint-plugin-js": "2.1.0",
6969
"@stylistic/stylelint-plugin": "2.1.2",
70+
"@typescript-eslint/parser": "7.11.0",
7071
"@vitejs/plugin-vue": "5.0.4",
7172
"eslint": "8.57.0",
73+
"eslint-import-resolver-typescript": "3.6.1",
7274
"eslint-plugin-array-func": "4.0.0",
7375
"eslint-plugin-github": "5.0.0-2",
7476
"eslint-plugin-i": "2.29.1",

Diff for: tsconfig.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"include": [
3+
"*",
4+
"tests/e2e/**/*",
5+
"tools/**/*",
6+
"web_src/js/**/*",
7+
],
8+
"exclude": [
9+
"**/.git/**",
10+
"**/.venv/**",
11+
"**/node_modules/**",
12+
"**/vendor/**",
13+
],
14+
"compilerOptions": {
15+
"target": "esnext",
16+
"module": "nodenext",
17+
"moduleResolution": "nodenext",
18+
"moduleDetection": "force",
19+
"lib": ["dom", "dom.iterable", "dom.asynciterable", "esnext"],
20+
"allowImportingTsExtensions": true,
21+
"allowJs": true,
22+
"allowSyntheticDefaultImports": true,
23+
"alwaysStrict": true,
24+
"esModuleInterop": true,
25+
"isolatedModules": true,
26+
"noEmit": true,
27+
"resolveJsonModule": true,
28+
"skipLibCheck": true,
29+
"verbatimModuleSyntax": true,
30+
"stripInternal": true,
31+
"strict": false,
32+
"noUnusedLocals": true,
33+
"noUnusedParameters": true,
34+
"noPropertyAccessFromIndexSignature": false,
35+
"exactOptionalPropertyTypes": false,
36+
}
37+
}

Diff for: web_src/js/components/.eslintrc.yaml

-22
This file was deleted.

Diff for: web_src/js/components/RepoActionView.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ export function initRepositoryActionView() {
797797
}
798798
</style>
799799
800-
<style>
800+
<style> /* eslint-disable-line vue-scoped-css/enforce-style-type */
801801
/* some elements are not managed by vue, so we need to use global style */
802802
.job-status-rotate {
803803
animation: job-status-rotate-keyframes 1s linear infinite;

Diff for: web_src/js/features/repo-code.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function initRepoCodeView() {
153153
});
154154

155155
$(window).on('hashchange', () => {
156-
let m = window.location.hash.match(rangeAnchorRegex);
156+
let m = rangeAnchorRegex.exec(window.location.hash.match);
157157
const $linesEls = $(getLineEls());
158158
let $first;
159159
if (m) {
@@ -170,7 +170,7 @@ export function initRepoCodeView() {
170170
return;
171171
}
172172
}
173-
m = window.location.hash.match(singleAnchorRegex);
173+
m = singleAnchorRegex.exec(window.location.hash.match);
174174
if (m) {
175175
$first = $linesEls.filter(`[rel=L${m[2]}]`);
176176
if ($first.length) {

Diff for: web_src/js/webcomponents/overflow-menu.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {isDocumentFragmentOrElementNode} from '../utils/dom.js';
44
import octiconKebabHorizontal from '../../../public/assets/img/svg/octicon-kebab-horizontal.svg';
55

66
window.customElements.define('overflow-menu', class extends HTMLElement {
7-
updateItems = throttle(100, () => {
7+
updateItems = throttle(100, () => { // eslint-disable-line unicorn/consistent-function-scoping -- https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2088
88
if (!this.tippyContent) {
99
const div = document.createElement('div');
1010
div.classList.add('tippy-target');

0 commit comments

Comments
 (0)