Skip to content

Commit

Permalink
chore: enable eslint for vue files (#1529)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez authored Oct 16, 2022
1 parent ec3ce0a commit 31bb1e9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
36 changes: 19 additions & 17 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,12 @@ module.exports = {
'spaced-comment': 'off',
},
},
{
// Extend graphql operations defined in code files to separate "virtual" files
files: ['*.ts'],
processor: '@graphql-eslint/graphql',
},
{
// Configure rules for "virtual" operation files
files: ['**/*.{ts,vue}/*.graphql'],
parser: '@graphql-eslint/eslint-plugin',
extends: 'plugin:@graphql-eslint/operations-recommended',
rules: {
// Enforces unique fragment name.
'@graphql-eslint/unique-fragment-name': 'error',
// Enforces unique operation names.
'@graphql-eslint/unique-operation-name': 'error',
},
},
{
files: ['*.ts', '*.vue'],
// Parser supporting vue files
parser: 'vue-eslint-parser',
// Extract graphql tags
processor: '@graphql-eslint/graphql',
parserOptions: {
// Use ts parser for ts files and for the script tag in vue files
parser: '@typescript-eslint/parser',
Expand All @@ -107,6 +92,11 @@ module.exports = {
// Enable recommended rules for typescript that use typing information (may be CPU intensive)
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
rules: {
// The graphql processor disables the vue processor, so some rules need to be disenabled
// TODO: Remove this once https://github.com/eslint/eslint/issues/14745 is fixed and we can use multiple processors
'vue/comment-directive': 'off',
},
},
{
files: ['layouts/**/*.vue', 'pages/**/*.vue'],
Expand All @@ -115,6 +105,18 @@ module.exports = {
'vue/multi-word-component-names': 'off',
},
},
{
// Configure rules for "virtual" operation files
files: ['**/*.{ts,vue}/*.graphql'],
parser: '@graphql-eslint/eslint-plugin',
extends: 'plugin:@graphql-eslint/operations-recommended',
rules: {
// Enforces unique fragment name.
'@graphql-eslint/unique-fragment-name': 'error',
// Enforces unique operation names.
'@graphql-eslint/unique-operation-name': 'error',
},
},
{
// Special treatment for test files
files: ['**/*.test.ts', '**/*.spec.ts'],
Expand Down
4 changes: 3 additions & 1 deletion components/DocumentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const DocumentDetails = gql(/* GraphQL */ `
}
... on JournalArticle {
in {
id
volume
number
journal {
Expand All @@ -147,6 +148,7 @@ const DocumentDetails = gql(/* GraphQL */ `
}
... on ProceedingsArticle {
in {
id
title
}
}
Expand All @@ -168,7 +170,7 @@ const props = defineProps({
const { result } = useQuery(
gql(/* GraphQL */ `
query GetDocumentDetails($documentId: ID!) {
query DocumentDetails($documentId: ID!) {
userDocument(id: $documentId) {
...DocumentDetails
}
Expand Down
2 changes: 2 additions & 0 deletions components/DocumentView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const DocumentForView = gql(/* GraphQL */ `
}
... on JournalArticle {
in {
id
journal {
id
name
Expand All @@ -135,6 +136,7 @@ const DocumentForView = gql(/* GraphQL */ `
}
... on ProceedingsArticle {
in {
id
title
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default defineComponent({
setup() {
const { result } = useQuery(
gql(/* GraphQL */ `
query GetGroups {
query Groups {
me {
id
groups {
Expand Down
7 changes: 1 addition & 6 deletions pages/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ const ui = useUiStore()
const { result, fetchMore } = useQuery(
gql(/* GraphQL */ `
query GetDocuments(
$groupId: ID
$query: String
$first: Int
$after: String
) {
query Documents($groupId: ID, $query: String, $first: Int, $after: String) {
me {
id
documents(
Expand Down

0 comments on commit 31bb1e9

Please sign in to comment.