-
Notifications
You must be signed in to change notification settings - Fork 1
update all dep and tests #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0cc1669
fix
alibeknow 36d9338
Merge remote-tracking branch 'origin/master' into fix/dep
alibeknow 29a313d
Merge remote-tracking branch 'origin/master' into fix/dep
alibeknow b8df48a
fix
alibeknow 06ce189
fix
alibeknow 9ae7362
add in tests audit
alibeknow f7d6592
version v4.0.1-rc.0
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: pnpm | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Run tests | ||
| run: pnpm test | ||
|
|
||
| - name: Security | ||
| run: pnpm audit | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { describe, it, expect } from 'vitest' | ||
| import { ESLint } from 'eslint' | ||
| import config from './index.mjs' | ||
|
|
||
| function createLinter() { | ||
| return new ESLint({ | ||
| overrideConfigFile: true, | ||
| overrideConfig: config | ||
| }) | ||
| } | ||
|
|
||
| async function lintText(code, filePath = 'src/test.ts') { | ||
| const linter = createLinter() | ||
| const results = await linter.lintText(code, { filePath }) | ||
|
|
||
| return results[0].messages | ||
| } | ||
|
|
||
| function hasRule(messages, ruleId) { | ||
| return messages.some((m) => m.ruleId === ruleId) | ||
| } | ||
|
|
||
| describe('@1inch/eslint-config', () => { | ||
| it('exports a valid config array', () => { | ||
| expect(Array.isArray(config)).toBe(true) | ||
| expect(config.length).toBeGreaterThan(0) | ||
| }) | ||
|
|
||
| it('catches console.log (no-console)', async () => { | ||
| const messages = await lintText('console.log("hello")\n') | ||
| expect(hasRule(messages, 'no-console')).toBe(true) | ||
| }) | ||
|
|
||
| it('catches missing return type (@typescript-eslint/explicit-function-return-type)', async () => { | ||
| const messages = await lintText('export function foo() { return 1 }\n') | ||
| expect(hasRule(messages, '@typescript-eslint/explicit-function-return-type')).toBe(true) | ||
| }) | ||
|
|
||
| it('catches unused imports (unused-imports/no-unused-imports)', async () => { | ||
| const code = 'import { readFile } from "fs"\nexport const x: number = 1\n' | ||
| const messages = await lintText(code) | ||
| expect(hasRule(messages, 'unused-imports/no-unused-imports')).toBe(true) | ||
| }) | ||
|
|
||
| it('catches formatting issues via prettier (prettier/prettier)', async () => { | ||
| const code = 'export const arr: number[] = [1, 2, 3,]\n' | ||
| const messages = await lintText(code) | ||
| expect(hasRule(messages, 'prettier/prettier')).toBe(true) | ||
| }) | ||
|
|
||
| it('allows valid code without errors for key rules', async () => { | ||
| const code = `export function add(a: number, b: number): number { | ||
| return a + b | ||
| } | ||
| ` | ||
| const messages = await lintText(code) | ||
| const criticalRules = [ | ||
| 'no-console', | ||
| '@typescript-eslint/explicit-function-return-type', | ||
| 'unused-imports/no-unused-imports' | ||
| ] | ||
| for (const rule of criticalRules) { | ||
| expect(hasRule(messages, rule)).toBe(false) | ||
| } | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
publish.yml: устаревший actions/checkout@v3 test.yml уже использует v4, а publish.yml всё ещё на v3 (строки 16, 57). Стоит унифицировать.