Skip to content
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

vue: Assert upstream config settings #420

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/fixtures/vue2-common/invalid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
{{ baz }}
</template>
</blah-component>

<!-- eslint-disable vue/attributes-order -->
<div
@click="functionCall"
my-prop="prop"
v-model="headerData"
id="uniqueID"
v-once
is="header"
/>
<!-- eslint-enable vue/attributes-order -->

<!-- eslint-disable-next-line vue/no-lone-template -->
<template />
<!-- eslint-disable-next-line vue/no-unregistered-components -->
<foo-component />
<!-- eslint-disable-next-line vue/no-static-inline-styles -->
Expand Down Expand Up @@ -72,6 +86,11 @@ module.exports = {
// eslint-disable-next-line vue/no-reserved-component-names, vue/no-unused-components
button: {},
BlahComponent: {}
},
// eslint-disable-next-line vue/require-render-return
render: function () {
// eslint-disable-next-line vue/no-multiple-slot-args, no-unused-vars
var children = this.$scopedSlots.default( 'foo', 'bar' );
}
};
</script>
9 changes: 9 additions & 0 deletions test/fixtures/vue2-common/valid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
<!-- Valid: vue/v-on-function-call -->
<a @click="foo">Click me</a>
<!-- Valid: vue/padding-line-between-blocks -->
<!-- Valid: vue/attributes-order -->
<div
is="header"
v-once
id="uniqueID"
v-model="headerData"
my-prop="prop"
@click="functionCall"
/>
</div>
</template>

Expand Down
32 changes: 24 additions & 8 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,33 @@ function getPluginExtends( config ) {
const extendsList = Array.isArray( config.extends ) ?
config.extends :
[ config.extends ];

if ( config.overrides ) {
config.overrides.forEach( ( override ) => {
Object.assign( extendsList, override.extends );
} );
}

// Fetch every upstream config we use via 'extends'.
extendsList.forEach( ( extend ) => {
const parts = extend.match( /plugin:(.*)\/([^/]+)/ );
let childConfig;
if ( !parts ) {
return;
}
let upstreamConfigs;
if ( parts[ 1 ].includes( 'eslint-plugin-' ) ) {
upstreamConfigs = require( parts[ 1 ] ).configs;
if ( fs.existsSync( extend ) ) {
childConfig = require( extend );
} else {
// Couldn't resolve extend path
return;
}
} else {
upstreamConfigs = require( 'eslint-plugin-' + parts[ 1 ] ).configs;
let upstreamConfigs;
if ( parts[ 1 ].includes( 'eslint-plugin-' ) ) {
upstreamConfigs = require( parts[ 1 ] ).configs;
} else {
upstreamConfigs = require( 'eslint-plugin-' + parts[ 1 ] ).configs;
}
childConfig = upstreamConfigs[ parts[ 2 ] ];
}
const childConfig = upstreamConfigs[ parts[ 2 ] ];
Object.assign(
rules,
getRules( childConfig )
Expand All @@ -57,7 +71,9 @@ configs.forEach( ( configPath ) => {
'json',
'mocha',
'qunit',
'selenium'
'selenium',
'vue2-common',
'vue3-common'
];

QUnit.module( `"${configName}" config`, () => {
Expand Down