-
-
Notifications
You must be signed in to change notification settings - Fork 700
test: rewrite some files in .ts
#2968
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
Open
9romise
wants to merge
5
commits into
vuejs:master
Choose a base branch
from
9romise:rewrite-test-ts
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+83
−96
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
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
6 changes: 2 additions & 4 deletions
6
tests/lib/configs/eslintrc.js → tests/lib/configs/eslintrc.ts
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 |
|---|---|---|
|
|
@@ -3,14 +3,13 @@ | |
| * @author 唯然<[email protected]> | ||
| */ | ||
|
|
||
| 'use strict' | ||
| import { Linter } from 'eslint' | ||
| import plugin from '../../../lib' | ||
| import { strict as assert } from 'assert' | ||
| import { FlatESLint } from '../../eslint-compat' | ||
|
|
||
| const plugin = require('../../../lib/index') | ||
| const { strict: assert } = require('assert') // node v14 does not support 'assert/strict' | ||
| const { FlatESLint } = require('../../eslint-compat') | ||
|
|
||
| function mergeConfig(configs) { | ||
| let config = { rules: {}, plugins: {} } | ||
| function mergeConfig(configs: Linter.FlatConfig[]): Linter.FlatConfig { | ||
| let config: Linter.FlatConfig = { rules: {}, plugins: {} } | ||
| for (const item of configs) { | ||
| config = { | ||
| ...config, | ||
|
|
@@ -37,16 +36,16 @@ describe('flat configs', () => { | |
| const forVue = mergeConfig( | ||
| base.filter((config) => config.files?.includes('*.vue') || !config.files) | ||
| ) | ||
| assert.strictEqual(forVue.plugins.vue, plugin) | ||
| assert.strictEqual(forVue.plugins!.vue, plugin) | ||
| assert.strictEqual(forVue.processor, 'vue/vue') | ||
| assert.strictEqual(forVue.rules['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/comment-directive'], 'error') | ||
|
|
||
| const forOtherThanVue = mergeConfig( | ||
| base.filter((config) => !config.files?.includes('*.vue')) | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.plugins.vue, plugin) | ||
| assert.strictEqual(forOtherThanVue.plugins!.vue, plugin) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/comment-directive'], | ||
| forOtherThanVue.rules!['vue/comment-directive'], | ||
| undefined | ||
| ) | ||
| }) | ||
|
|
@@ -61,20 +60,20 @@ describe('flat configs', () => { | |
| (config) => config.files?.includes('*.vue') || !config.files | ||
| ) | ||
| ) | ||
| assert.strictEqual(forVue.plugins.vue, plugin) | ||
| assert.strictEqual(forVue.rules['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules['vue/multi-word-component-names'], 'error') | ||
| assert.strictEqual(forVue.plugins!.vue, plugin) | ||
| assert.strictEqual(forVue.rules!['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/multi-word-component-names'], 'error') | ||
|
|
||
| const forOtherThanVue = mergeConfig( | ||
| essential.filter((config) => !config.files?.includes('*.vue')) | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.plugins.vue, plugin) | ||
| assert.strictEqual(forOtherThanVue.plugins!.vue, plugin) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/comment-directive'], | ||
| forOtherThanVue.rules!['vue/comment-directive'], | ||
| undefined | ||
| ) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/multi-word-component-names'], | ||
| forOtherThanVue.rules!['vue/multi-word-component-names'], | ||
| 'error' | ||
| ) | ||
| }) | ||
|
|
@@ -89,20 +88,20 @@ describe('flat configs', () => { | |
| (config) => config.files?.includes('*.vue') || !config.files | ||
| ) | ||
| ) | ||
| assert.strictEqual(forVue.plugins.vue, plugin) | ||
| assert.strictEqual(forVue.rules['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules['vue/multi-word-component-names'], 'error') | ||
| assert.strictEqual(forVue.plugins!.vue, plugin) | ||
| assert.strictEqual(forVue.rules!['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/multi-word-component-names'], 'error') | ||
|
|
||
| const forOtherThanVue = mergeConfig( | ||
| stronglyRecommended.filter((config) => !config.files?.includes('*.vue')) | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.plugins.vue, plugin) | ||
| assert.strictEqual(forOtherThanVue.plugins!.vue, plugin) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/comment-directive'], | ||
| forOtherThanVue.rules!['vue/comment-directive'], | ||
| undefined | ||
| ) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/multi-word-component-names'], | ||
| forOtherThanVue.rules!['vue/multi-word-component-names'], | ||
| 'error' | ||
| ) | ||
| }) | ||
|
|
@@ -117,24 +116,24 @@ describe('flat configs', () => { | |
| (config) => config.files?.includes('*.vue') || !config.files | ||
| ) | ||
| ) | ||
| assert.strictEqual(forVue.plugins.vue, plugin) | ||
| assert.strictEqual(forVue.rules['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules['vue/multi-word-component-names'], 'error') | ||
| assert.strictEqual(forVue.rules['vue/attributes-order'], 'warn') | ||
| assert.strictEqual(forVue.plugins!.vue, plugin) | ||
| assert.strictEqual(forVue.rules!['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/multi-word-component-names'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/attributes-order'], 'warn') | ||
|
|
||
| const forOtherThanVue = mergeConfig( | ||
| recommended.filter((config) => !config.files?.includes('*.vue')) | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.plugins.vue, plugin) | ||
| assert.strictEqual(forOtherThanVue.plugins!.vue, plugin) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/comment-directive'], | ||
| forOtherThanVue.rules!['vue/comment-directive'], | ||
| undefined | ||
| ) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/multi-word-component-names'], | ||
| forOtherThanVue.rules!['vue/multi-word-component-names'], | ||
| 'error' | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.rules['vue/attributes-order'], 'warn') | ||
| assert.strictEqual(forOtherThanVue.rules!['vue/attributes-order'], 'warn') | ||
| }) | ||
|
|
||
| it('should export vue2-essential config', () => { | ||
|
|
@@ -147,20 +146,20 @@ describe('flat configs', () => { | |
| (config) => config.files?.includes('*.vue') || !config.files | ||
| ) | ||
| ) | ||
| assert.strictEqual(forVue.plugins.vue, plugin) | ||
| assert.strictEqual(forVue.rules['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules['vue/multi-word-component-names'], 'error') | ||
| assert.strictEqual(forVue.plugins!.vue, plugin) | ||
| assert.strictEqual(forVue.rules!['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/multi-word-component-names'], 'error') | ||
|
|
||
| const forOtherThanVue = mergeConfig( | ||
| essential.filter((config) => !config.files?.includes('*.vue')) | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.plugins.vue, plugin) | ||
| assert.strictEqual(forOtherThanVue.plugins!.vue, plugin) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/comment-directive'], | ||
| forOtherThanVue.rules!['vue/comment-directive'], | ||
| undefined | ||
| ) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/multi-word-component-names'], | ||
| forOtherThanVue.rules!['vue/multi-word-component-names'], | ||
| 'error' | ||
| ) | ||
| }) | ||
|
|
@@ -175,20 +174,20 @@ describe('flat configs', () => { | |
| (config) => config.files?.includes('*.vue') || !config.files | ||
| ) | ||
| ) | ||
| assert.strictEqual(forVue.plugins.vue, plugin) | ||
| assert.strictEqual(forVue.rules['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules['vue/multi-word-component-names'], 'error') | ||
| assert.strictEqual(forVue.plugins!.vue, plugin) | ||
| assert.strictEqual(forVue.rules!['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/multi-word-component-names'], 'error') | ||
|
|
||
| const forOtherThanVue = mergeConfig( | ||
| stronglyRecommended.filter((config) => !config.files?.includes('*.vue')) | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.plugins.vue, plugin) | ||
| assert.strictEqual(forOtherThanVue.plugins!.vue, plugin) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/comment-directive'], | ||
| forOtherThanVue.rules!['vue/comment-directive'], | ||
| undefined | ||
| ) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/multi-word-component-names'], | ||
| forOtherThanVue.rules!['vue/multi-word-component-names'], | ||
| 'error' | ||
| ) | ||
| }) | ||
|
|
@@ -203,24 +202,24 @@ describe('flat configs', () => { | |
| (config) => config.files?.includes('*.vue') || !config.files | ||
| ) | ||
| ) | ||
| assert.strictEqual(forVue.plugins.vue, plugin) | ||
| assert.strictEqual(forVue.rules['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules['vue/multi-word-component-names'], 'error') | ||
| assert.strictEqual(forVue.rules['vue/attributes-order'], 'warn') | ||
| assert.strictEqual(forVue.plugins!.vue, plugin) | ||
| assert.strictEqual(forVue.rules!['vue/comment-directive'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/multi-word-component-names'], 'error') | ||
| assert.strictEqual(forVue.rules!['vue/attributes-order'], 'warn') | ||
|
|
||
| const forOtherThanVue = mergeConfig( | ||
| recommended.filter((config) => !config.files?.includes('*.vue')) | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.plugins.vue, plugin) | ||
| assert.strictEqual(forOtherThanVue.plugins!.vue, plugin) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/comment-directive'], | ||
| forOtherThanVue.rules!['vue/comment-directive'], | ||
| undefined | ||
| ) | ||
| assert.strictEqual( | ||
| forOtherThanVue.rules['vue/multi-word-component-names'], | ||
| forOtherThanVue.rules!['vue/multi-word-component-names'], | ||
| 'error' | ||
| ) | ||
| assert.strictEqual(forOtherThanVue.rules['vue/attributes-order'], 'warn') | ||
| assert.strictEqual(forOtherThanVue.rules!['vue/attributes-order'], 'warn') | ||
| }) | ||
|
|
||
| it('should work the suppress comments with base config', async () => { | ||
|
|
@@ -281,7 +280,7 @@ describe('flat configs', () => { | |
| const result = await eslint.lintText(code, { filePath: 'MyComponent.vue' }) | ||
|
|
||
| assert.deepStrictEqual( | ||
| result[0].messages.map((message) => message.ruleId), | ||
| result[0].messages.map((message: Linter.LintMessage) => message.ruleId), | ||
| [ | ||
| 'vue/no-parsing-error', | ||
| 'vue/max-attributes-per-line', | ||
|
|
||
21 changes: 11 additions & 10 deletions
21
tests/lib/rules/block-order.js → tests/lib/rules/block-order.ts
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
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.
Uh oh!
There was an error while loading. Please reload this page.