Skip to content

Commit

Permalink
feat: add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenki committed Jun 2, 2024
1 parent b1b3a37 commit 9c18a56
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 145 deletions.
15 changes: 0 additions & 15 deletions geochemistrypi/frontend/.eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion geochemistrypi/frontend/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
}
1 change: 1 addition & 0 deletions geochemistrypi/frontend/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": ["stylelint-config-standard"] }
2 changes: 1 addition & 1 deletion geochemistrypi/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ npm install
### Compile and Hot-Reload for Development

```sh
npm run dev
npm run start
```

### Compile and Minify for Production
Expand Down
9 changes: 9 additions & 0 deletions geochemistrypi/frontend/auto-imports.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {

}
14 changes: 14 additions & 0 deletions geochemistrypi/frontend/components.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
NavBar: typeof import('./src/components/nav-bar.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
}
1 change: 1 addition & 0 deletions geochemistrypi/frontend/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
22 changes: 22 additions & 0 deletions geochemistrypi/frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import globals from 'globals'
import pluginJs from '@eslint/js'
// import tseslint from "typescript-eslint";
import pluginVue from 'eslint-plugin-vue'

export default [
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
// ...tseslint.configs.recommended,
...pluginVue.configs['flat/essential'],
{
rules: {
semi: ['warn', 'never'],
'comma-dangle': ['error', 'never'],
'no-unused-vars': 2,
'space-before-function-paren': 0,
'generator-star-spacing': 'off',
'object-curly-spacing': 0, // 强制在大括号中使用一致的空格
'array-bracket-spacing': 0 // 方括号
}
}
]
10 changes: 5 additions & 5 deletions geochemistrypi/frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
26 changes: 16 additions & 10 deletions geochemistrypi/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "frontend",
"name": "frontend-new",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "vite",
"build": "vite build",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"build-only": "vite build",
"type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
Expand All @@ -16,24 +18,28 @@
"vue": "^3.4.21",
"vue-router": "^4.3.0"
},
"@rushstack/eslint-patch": "^1.8.0",
"devDependencies": {
"@eslint/js": "^9.3.0",
"@eslint/js": "^9.4.0",
"@tsconfig/node20": "^20.1.4",
"@types/node": "^20.12.5",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/cli-plugin-typescript": "~5.0.0",
"@vue/compiler-sfc": "^3.4.27",
"@vue/eslint-config-prettier": "^9.0.0",
"eslint": "^9.3.0",
"@vue/tsconfig": "^0.5.1",
"eslint": "^9.4.0",
"eslint-plugin-vue": "^9.26.0",
"globals": "^15.3.0",
"npm-run-all2": "^6.1.2",
"prettier": "^3.2.5",
"sass": "^1.76.0",
"sass-loader": "^14.2.1",
"typescript": "^5.4.5",
"typescript": "~5.4.0",
"typescript-eslint": "^7.11.0",
"unplugin-auto-import": "^0.17.5",
"unplugin-vue-components": "^0.27.0",
"vite": "^5.2.8",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-vue-devtools": "^7.0.25"
"vite-plugin-vue-devtools": "^7.0.25",
"vue-tsc": "^2.0.11"
}
}
2 changes: 1 addition & 1 deletion geochemistrypi/frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts" up>
<script lang="ts" setup>
import { RouterView } from 'vue-router'
import NavBar from './components/nav-bar.vue'
</script>
Expand Down
2 changes: 1 addition & 1 deletion geochemistrypi/frontend/src/components/nav-bar.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="'ts'" setup>
<script lang="ts" setup>
import { RouterLink } from 'vue-router'
</script>

Expand Down
2 changes: 1 addition & 1 deletion geochemistrypi/frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const router = createRouter({
{
path: '/guide',
name: 'about',
component: () => import('../views/guide/guide-page.vue')
component: () => import('../views/guide-view/guide-page.vue')
}
]
})
Expand Down
4 changes: 2 additions & 2 deletions geochemistrypi/frontend/src/views/guide-view/guide-page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="guide-page">
<div class="text-wrapper">
<h1>Meet Our Team Member</h1>
<p>Data Organization: ZJU Earth Data Team</p>
<p>Data Organization: ZJU Earth Data Team111</p>
</div>
<div class="member-group">
<el-card body-class="member-box" v-for="item in memberInfo" :key="item.id">
Expand All @@ -16,7 +16,7 @@
</template>
<script lang="ts" setup>
import { memberInfo } from './config'
import { ElCard, ElSpace } from 'element-plus'
import { ElCard } from 'element-plus'
</script>
<style lang="scss" scoped>
.guide-page {
Expand Down
14 changes: 14 additions & 0 deletions geochemistrypi/frontend/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",

"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
116 changes: 9 additions & 107 deletions geochemistrypi/frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,109 +1,11 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */

/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */

/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.app.json"
}
]
}
19 changes: 19 additions & 0 deletions geochemistrypi/frontend/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
],
"compilerOptions": {
"composite": true,
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",

"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
}
}
14 changes: 13 additions & 1 deletion geochemistrypi/frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import VueDevTools from 'vite-plugin-vue-devtools'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import eslint from 'vite-plugin-eslint'

// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -27,7 +28,18 @@ export default defineConfig({
}),
Components({
resolvers: [ElementPlusResolver()]
})
}),
{
// do not fail on serve (i.e. local development)
...eslint({
lintOnStart: true,
include: ['./src'],
failOnWarning: false,
failOnError: false
}),
apply: 'serve',
enforce: 'post'
}
],
resolve: {
alias: {
Expand Down

0 comments on commit 9c18a56

Please sign in to comment.