Skip to content

Commit

Permalink
Add initial typescript config for eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed May 30, 2024
1 parent fb7b743 commit 4894af3
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 37 deletions.
27 changes: 25 additions & 2 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@ ignorePatterns:
- /web_src/fomantic
- /public/assets/js

parser: "@typescript-eslint/parser"

parserOptions:
sourceType: module
ecmaVersion: latest
project: true
extraFileExtensions: [".vue"]

settings:
import/extensions: [".js", ".ts"]
import/parsers:
"@typescript-eslint/parser": [".js", ".ts"]
import/resolver:
typescript: true

plugins:
- "@eslint-community/eslint-plugin-eslint-comments"
Expand Down Expand Up @@ -103,6 +114,18 @@ overrides:
- files: ["web_src/js/modules/fetch.js", "web_src/js/standalone/**/*"]
rules:
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression]
- files: ["**/*.vue"]
plugins:
- eslint-plugin-vue
- eslint-plugin-vue-scoped-css
extends:
- plugin:vue/vue3-recommended
- plugin:vue-scoped-css/vue3-recommended
rules:
vue/attributes-order: [0]
vue/html-closing-bracket-spacing: [2, {startTag: never, endTag: never, selfClosingTag: never}]
vue/max-attributes-per-line: [0]
vue/singleline-html-element-content-newline: [0]

rules:
"@eslint-community/eslint-comments/disable-enable-pair": [2]
Expand Down Expand Up @@ -264,7 +287,7 @@ rules:
i/no-internal-modules: [0]
i/no-mutable-exports: [0]
i/no-named-as-default-member: [0]
i/no-named-as-default: [2]
i/no-named-as-default: [0]
i/no-named-default: [0]
i/no-named-export: [0]
i/no-namespace: [0]
Expand All @@ -274,7 +297,7 @@ rules:
i/no-restricted-paths: [0]
i/no-self-import: [2]
i/no-unassigned-import: [0]
i/no-unresolved: [2, {commonjs: true, ignore: ["\\?.+$", ^vitest/]}]
i/no-unresolved: [2, {commonjs: true}]
i/no-unused-modules: [2, {unusedExports: true}]
i/no-useless-path-segments: [2, {commonjs: true}]
i/no-webpack-loader-syntax: [2]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ lint-backend-fix: lint-go-fix lint-go-vet lint-editorconfig

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

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

.PHONY: lint-css
lint-css: node_modules
Expand Down
128 changes: 121 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@
"@stoplight/spectral-cli": "6.11.1",
"@stylistic/eslint-plugin-js": "2.1.0",
"@stylistic/stylelint-plugin": "2.1.2",
"@typescript-eslint/parser": "7.11.0",
"@vitejs/plugin-vue": "5.0.4",
"eslint": "8.57.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-array-func": "4.0.0",
"eslint-plugin-github": "5.0.0-2",
"eslint-plugin-i": "2.29.1",
Expand Down
37 changes: 37 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"include": [
"*",
"tests/e2e/**/*",
"tools/**/*",
"web_src/js/**/*",
],
"exclude": [
"**/.git/**",
"**/.venv/**",
"**/node_modules/**",
"**/vendor/**",
],
"compilerOptions": {
"target": "esnext",
"module": "nodenext",
"moduleResolution": "nodenext",
"moduleDetection": "force",
"lib": ["dom", "dom.iterable", "dom.asynciterable", "esnext"],
"allowImportingTsExtensions": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"esModuleInterop": true,
"isolatedModules": true,
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"verbatimModuleSyntax": true,
"stripInternal": true,
"strict": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": false,
"exactOptionalPropertyTypes": false,
}
}
22 changes: 0 additions & 22 deletions web_src/js/components/.eslintrc.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion web_src/js/components/RepoActionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ export function initRepositoryActionView() {
}
</style>
<style>
<style> /* eslint-disable-line vue-scoped-css/enforce-style-type */
/* some elements are not managed by vue, so we need to use global style */
.job-status-rotate {
animation: job-status-rotate-keyframes 1s linear infinite;
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/repo-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export function initRepoCodeView() {
});

$(window).on('hashchange', () => {
let m = window.location.hash.match(rangeAnchorRegex);
let m = rangeAnchorRegex.exec(window.location.hash.match);
const $linesEls = $(getLineEls());
let $first;
if (m) {
Expand All @@ -170,7 +170,7 @@ export function initRepoCodeView() {
return;
}
}
m = window.location.hash.match(singleAnchorRegex);
m = singleAnchorRegex.exec(window.location.hash.match);
if (m) {
$first = $linesEls.filter(`[rel=L${m[2]}]`);
if ($first.length) {
Expand Down
2 changes: 1 addition & 1 deletion web_src/js/webcomponents/overflow-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {isDocumentFragmentOrElementNode} from '../utils/dom.js';
import octiconKebabHorizontal from '../../../public/assets/img/svg/octicon-kebab-horizontal.svg';

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

0 comments on commit 4894af3

Please sign in to comment.