Skip to content

Commit

Permalink
chore: update linter (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Feb 18, 2024
1 parent 8db582a commit 62f284d
Show file tree
Hide file tree
Showing 59 changed files with 937 additions and 1,440 deletions.
9 changes: 0 additions & 9 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
.vscode-test/
*.vsix
.DS_Store
.eslintcache
105 changes: 105 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
const { default: antfu, GLOB_SRC } = require('@antfu/eslint-config')

module.exports = antfu(
{
// Disable tests rules because we need to test with various setup
test: false,
// This replaces the old `.gitignore`
ignores: [
'**/coverage',
'**/*.snap',
'**/bench.json',
'**/fixtures',
'**/test',
'**/samples',
],
},
{
rules: {
// prefer global Buffer to not initialize the whole module
'node/prefer-global/buffer': 'off',
'node/prefer-global/process': 'off',
'no-empty-pattern': 'off',
'antfu/indent-binary-ops': 'off',
'unused-imports/no-unused-imports': 'error',
'style/member-delimiter-style': [
'error',
{
multiline: { delimiter: 'none' },
singleline: { delimiter: 'semi' },
},
],

'ts/no-invalid-this': 'off',

// TODO: migrate and turn it back on
'ts/ban-types': 'off',

'no-restricted-imports': [
'error',
{
paths: ['path'],
},
],

'import/no-named-as-default': 'off',
},
},
{
files: [`packages/*/*.{js,mjs,d.ts}`],
rules: {
'antfu/no-import-dist': 'off',
},
},
{
files: [`packages/${GLOB_SRC}`],
rules: {
'no-restricted-imports': [
'error',
{
paths: ['vitest', 'path'],
},
],
},
},
{
// these files define vitest as peer dependency
files: [`packages/{coverage-*,ui,browser,web-worker}/${GLOB_SRC}`],
rules: {
'no-restricted-imports': [
'error',
{
paths: ['path'],
},
],
},
},
{
files: [
`docs/${GLOB_SRC}`,
],
rules: {
'style/max-statements-per-line': 'off',
'import/newline-after-import': 'off',
'import/first': 'off',
'unused-imports/no-unused-imports': 'off',
},
},
{
files: [
`docs/${GLOB_SRC}`,
`packages/web-worker/${GLOB_SRC}`,
`test/web-worker/${GLOB_SRC}`,
],
rules: {
'no-restricted-globals': 'off',
},
},
{
files: [`packages/vite-node/${GLOB_SRC}`],
rules: {
// false positive on "exports" variable
'antfu/no-cjs-exports': 'off',
},
},
)
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
{
"publisher": "ZixuanChen",
"name": "vitest-explorer",
"displayName": "Vitest",
"version": "0.2.44",
"description": "Run and debug Vitest test cases",
"icon": "img/icon.png",
"preview": true,
"keywords": [
"vitest",
"test",
"typescript",
"javascript"
],
"license": "MIT",
"author": "zxch3n",
"publisher": "ZixuanChen",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/vitest-dev/vscode.git"
},
"bugs": {
"url": "https://github.com/vitest-dev/vscode/issues"
},
"engines": {
"vscode": "^1.77.0"
},
"keywords": [
"vitest",
"test",
"typescript",
"javascript"
],
"categories": [
"Testing"
],
"main": "./dist/extension.js",
"icon": "img/icon.png",
"preview": true,
"engines": {
"vscode": "^1.77.0"
},
"activationEvents": [
"onCommand:vitest-explorer.configureTest",
"workspaceContains:**/vitest.config.js",
Expand All @@ -35,7 +36,6 @@
"workspaceContains:**/vite.config.ts",
"workspaceContains:**/package.json"
],
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
Expand Down Expand Up @@ -142,15 +142,15 @@
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile": "tsup ./src/extension.ts --external vscode,lightningcss,esbuild --minify",
"watch": "tsup ./src/extension.ts --external vscode,lightningcss,esbuild --watch --sourcemap",
"compile": "tsup ./src/extension.ts --external vscode --minify",
"watch": "tsup ./src/extension.ts --external vscode --watch --sourcemap",
"test": "vitest run --config vite.global-config.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
"lint": "eslint --cache .",
"lint:fix": "eslint --cache --fix ."
},
"dependencies": {},
"devDependencies": {
"@antfu/eslint-config": "^0.23.1",
"@antfu/eslint-config": "^2.6.4",
"@babel/parser": "^7.20.15",
"@babel/types": "^7.20.7",
"@rauschma/stringio": "^1.4.0",
Expand Down
10 changes: 5 additions & 5 deletions samples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"name": "basic",
"version": "1.0.0",
"description": "",
"author": "",
"license": "ISC",
"main": "index.js",
"scripts": {
"test": "vitest run"
},
"author": "",
"license": "ISC",
"dependencies": {
"birpc": "^0.2.2"
},
"devDependencies": {
"vite": "^2.8.6",
"vitest": "^0.24.0"
},
"dependencies": {
"birpc": "^0.2.2"
}
}
2 changes: 1 addition & 1 deletion samples/basic/src/should_included_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest'
import { describe, it } from 'vitest'

describe('should included', () => {
it('is included because of workspace plugin setting', () => {})
Expand Down
34 changes: 17 additions & 17 deletions samples/basic/test/console.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { describe, it } from "vitest";
import { describe, it } from 'vitest'

describe("console", () => {
it("basic", () => {
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))

describe('console', () => {
it('basic', () => {
console.log([
"string",
{ hello: "world" },
'string',
{ hello: 'world' },
1234,
/regex/g,
true,
false,
null,
]);
});

it("async", async () => {
console.log("1st");
await sleep(200);
console.log("2nd");
await sleep(200);
console.log("3rd");
});
});
])
})

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
it('async', async () => {
console.log('1st')
await sleep(200)
console.log('2nd')
await sleep(200)
console.log('3rd')
})
})
12 changes: 6 additions & 6 deletions samples/monorepo-no-root/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"name": "monorepo",
"version": "1.0.1",
"description": "",
"author": "",
"license": "ISC",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"mime-types": "^2.1.35"
},
"devDependencies": {
"happy-dom": "^2.49.0",
"vitest": "^1.3.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const STATUS = {
NORMAL: 'normal',
}

const Link = ({ page, children }: any) => {
function Link({ page, children }: any) {
const [status, setStatus] = useState(STATUS.NORMAL)

const onMouseEnter = () => {
Expand Down
4 changes: 2 additions & 2 deletions samples/monorepo-nx/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getJestProjects } from '@nx/jest';
import { getJestProjects } from '@nx/jest'

export default {
projects: getJestProjects(),
};
}
4 changes: 2 additions & 2 deletions samples/monorepo-nx/jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default

module.exports = { ...nxPreset };
module.exports = { ...nxPreset }
2 changes: 1 addition & 1 deletion samples/monorepo-nx/library/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './lib/library';
export * from './lib/library'
8 changes: 4 additions & 4 deletions samples/monorepo-nx/library/src/lib/library.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { library } from './library';
import { library } from './library'

describe('library', () => {
it('should work', () => {
expect(library()).toEqual('library');
});
});
expect(library()).toEqual('library')
})
})
2 changes: 1 addition & 1 deletion samples/monorepo-nx/library/src/lib/library.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function library(): string {
return 'library';
return 'library'
}
6 changes: 3 additions & 3 deletions samples/monorepo-nx/library/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"compilerOptions": {
"module": "commonjs"
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
],
"files": [],
"include": []
}
8 changes: 4 additions & 4 deletions samples/monorepo-nx/library/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../dist/out-tsc",
"types": ["node"],
"declaration": true,
"types": ["node"]
"outDir": "../dist/out-tsc"
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
4 changes: 2 additions & 2 deletions samples/monorepo-nx/library/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
],
"outDir": "../dist/out-tsc"
},
"include": [
"vite.config.ts",
Expand Down
Loading

0 comments on commit 62f284d

Please sign in to comment.