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

chore: fix all remaining eslint errors #1010

Merged
merged 24 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
19eb3a1
chore: eslint composables and api-client properly
sethidden May 17, 2022
e4f360e
chore: autofix composables and api-client
sethidden May 17, 2022
bcf8662
refactor: simplify eslint tsconfig
sethidden May 17, 2022
09a6fda
chore: remove unused from composables/productHelpers.spec.ts
sethidden May 17, 2022
a546dcd
chore: fake incomplete product
sethidden May 17, 2022
ab9a0e5
chore: remove empty index file
sethidden May 17, 2022
ae40e1d
chore: remove unused gql
sethidden May 17, 2022
f64306f
chore: fix eslint errors in useWishlist
sethidden May 17, 2022
7ef94f2
chore: disable max-len eslint warning for cat search
sethidden May 17, 2022
5c433a9
chore: fix misc eslint errors
sethidden May 17, 2022
1b741cc
chore: fix eslint errors in productGetters
sethidden May 17, 2022
605c8b9
refactor: improve wishlistGetters typing
sethidden May 17, 2022
08f5712
refactor: improve categorytree typing
sethidden May 17, 2022
b6acd5b
refactor: orderGetters typings
sethidden May 17, 2022
6533a41
chore: fix facetGetters type issue
sethidden May 17, 2022
de253a9
refactor: fix usewishlist type issues
sethidden May 17, 2022
6ee4bb8
refactor: fix misc eslint errors
sethidden May 17, 2022
93c3b86
chore: fix misc eslint issues
sethidden May 17, 2022
2466e0f
chore: consistent array-callback
sethidden May 17, 2022
0dbf815
chore: remove redundant unsafe-argument eslint comment
sethidden May 17, 2022
db7d564
chore: don't break cartId implementation
sethidden May 17, 2022
efcfda7
chore: remove any
sethidden May 17, 2022
05d9146
ci: add eslint action
sethidden May 17, 2022
775b026
ci: run lint in build
sethidden May 17, 2022
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
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
**/node_modules/**/*
**/lib/*
packages/api-client/src/types/GraphQL.ts
packages/api-client/server
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(build output dirs)

packages/composables/lib
packages/api-client/lib
packages/theme/static/sw.js
.eslintrc.js
10 changes: 8 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = {
parser: '@typescript-eslint/parser',
project: [
resolve(__dirname, './tsconfig.json'),
resolve(__dirname, './packages/api-client/tsconfig.json'),
resolve(__dirname, './packages/composables/tsconfig.json'),
resolve(__dirname, './packages/api-client/tsconfig.eslint.json'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new .tsconfig file solely for eslint because typescript-eslint won't scan files unless a file is part of a typescript project. But some files are intentionally ignored by the regular tsconfig.json (when you don't want to include some types in the library dist published on NPM)

resolve(__dirname, './packages/composables/tsconfig.eslint.json'),
resolve(__dirname, './packages/theme/tsconfig.json'),
resolve(__dirname, './packages/theme/tests/e2e/tsconfig.json'),
],
Expand Down Expand Up @@ -48,6 +48,12 @@ module.exports = {
"promise/catch-or-return": "off", // conflicts with Cypress.Chainable
"promise/always-return": "off",
}
},
{
"files": ["internals/**/*"],
Copy link
Contributor Author

@sethidden sethidden May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to figure out whether I can use regular imports in eslint because I'll be removing the "many small internal eslint packages" soon

"rules": {
"unicorn/prefer-module": "off",
}
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ jobs:
- name: Build packages
run: yarn build

# typescript-eslint needs all packages to be built
# to check type-related linting rules
- name: Check for linting errors
run: yarn lint

- name: Test theme
run: yarn test:theme
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// eslint-disable-next-line unicorn/prefer-module
module.exports = { extends: ['@commitlint/config-conventional'] };
2 changes: 1 addition & 1 deletion internals/eslint-import/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module.exports = {
'./rules/extends',
'./rules/rules',
'./rules/settings',
].map(require.resolve),
].map((element) => require.resolve(element)),
};
2 changes: 1 addition & 1 deletion internals/eslint-jest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module.exports = {
'./rules/plugins',
'./rules/extends',
'./rules/rules',
].map(require.resolve),
].map((element) => require.resolve(element)),
};
2 changes: 1 addition & 1 deletion internals/eslint-typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module.exports = {
'./rules/plugins',
'./rules/extends',
'./rules/rules',
].map(require.resolve),
].map((element) => require.resolve(element)),
};
2 changes: 1 addition & 1 deletion internals/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ module.exports = {
'./rules/plugins',
'./rules/extends',
'./rules/rules',
].map(require.resolve),
].map((element) => require.resolve(element)),
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"internals/*"
],
"scripts": {
"build": "yarn build:api-client && yarn build:theme",
"build": "yarn build:api-client && yarn build:theme && yarn build:composables",
"build:api-client": "cd packages/api-client && yarn build",
"build:theme": "cd packages/theme && yarn build",
"build:composables": "cd packages/composables && yarn build",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate",
"dev:api-client": "cd packages/api-client && yarn dev",
Expand All @@ -22,7 +23,7 @@
"docs:dev": "cd docs && yarn dev",
"docs:build": "cd docs && yarn build",
"graphql:codegen": "graphql-codegen --config codegen.yml",
"lint": "eslint . --ext .ts,.vue --fix",
"lint": "eslint .",
"prepare": "[ -d '.husky' ] && (husky install && shx rm -rf .git/hooks && shx ln -s ../.husky .git/hooks) || true",
"publish:api-client": "node ./scripts/publishApi.js",
"start": "cd packages/theme && yarn start",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import request from '../../setup/request';
import {STORE_CONFIG_MOCK_RESP} from './../../mockData/api/storeConfig'
import { STORE_CONFIG_MOCK_RESP } from '../../mockData/api/storeConfig';

describe('[Magento-API-Client] storeConfig', () => {
it('Fetching the storeConfig', async () => {
Expand Down Expand Up @@ -60,8 +60,8 @@ describe('[Magento-API-Client] storeConfig', () => {
welcome
}
}
`
})
`,
}),
});
const { data } = await res.json();

Expand Down
Empty file.
9 changes: 5 additions & 4 deletions packages/api-client/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// eslint-disable-next-line unicorn/prefer-module
module.exports = {
presets: [
['@babel/preset-env', {
targets: {
node: 'current'
}
}]
]
node: 'current',
},
}],
],
};
2 changes: 1 addition & 1 deletion packages/api-client/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
testEnvironment: 'jsdom',
transform: {
'^.+\\.(m)js$': 'babel-jest',
'^.+\\.ts$': 'ts-jest'
'^.+\\.ts$': 'ts-jest',
},
transformIgnorePatterns: [
'node_modules',
Expand Down
4 changes: 4 additions & 0 deletions packages/api-client/possible-types.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable unicorn/prefer-module */
require('dotenv').config();
const fetch = require('cross-fetch');
const fs = require('fs');

// eslint-disable-next-line promise/catch-or-return
fetch(process.env.VSF_MAGENTO_GRAPHQL_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand All @@ -22,9 +24,11 @@ fetch(process.env.VSF_MAGENTO_GRAPHQL_URL, {
`,
}),
}).then((result) => result.json())
// eslint-disable-next-line promise/always-return
.then((result) => {
const possibleTypes = {};

// eslint-disable-next-line no-underscore-dangle
result.data.__schema.types.forEach((supertype) => {
if (supertype.possibleTypes) {
possibleTypes[supertype.name] = supertype.possibleTypes.map((subtype) => subtype.name);
Expand Down
1 change: 0 additions & 1 deletion packages/api-client/src/api/wishlist/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApolloQueryResult } from '@apollo/client/core';
import { CustomQuery } from '@vue-storefront/core';
import gql from 'graphql-tag';
import {
WishlistQuery,
WishlistQueryVariables,
Expand Down
7 changes: 7 additions & 0 deletions packages/api-client/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"exclude": [
"lib",
"node_modules"
]
}
6 changes: 3 additions & 3 deletions packages/composables/__tests__/_mountComposable.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { shallowMount } from '@vue/test-utils';
import { createComponent } from '@vue/composition-api';
import { defineComponent } from '@vue/composition-api';

const mountComposable = (composableFn) => {
const component = createComponent({
template: '<div>my component</div>',
const component = defineComponent({
setup() {
return composableFn();
},
template: '<div>my component</div>',
});

return shallowMount(component);
Expand Down
Loading