Skip to content

Commit

Permalink
NTR - Updated lint and test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
cyl3x committed Dec 3, 2024
1 parent bfb20cd commit 88ad4b5
Show file tree
Hide file tree
Showing 29 changed files with 18,026 additions and 11,161 deletions.
6 changes: 6 additions & 0 deletions .github/actions/setup-paypal/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,9 @@ runs:
install-storefront: ${{ inputs.install-storefront }}
dependencies: ${{ steps.dependency-list.outputs.deps }}
extraRepositories: ${{ steps.dependency-list.outputs.repos }}
- name: Prepare Administration
shell: bash
if: ${{ inputs.install-admin == 'true' }}
run: |
bin/console bundle:dump
composer admin:generate-entity-schema-types
26 changes: 17 additions & 9 deletions .github/workflows/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
pull_request:
paths:
- src/Resources/app/administration/**/*
- tests/jest/administration/**/*
workflow_dispatch:

permissions:
Expand All @@ -23,19 +24,26 @@ jobs:
- name: Setup SwagPayPal
uses: ./custom/plugins/SwagPayPal/.github/actions/setup-paypal
with:
install-commercial: true
install-admin: true
- name: Prepare ESLint
run: |
bin/console bundle:dump
composer admin:generate-entity-schema-types
- name: Run ESLint
env:
ADMIN_PATH: ${{ github.workspace }}/src/Administration/Resources/app/administration
working-directory: custom/plugins/${{ github.event.repository.name }}
run: composer run lint:admin:ci

jest:
uses: shopware/github-actions/.github/workflows/admin-jest.yml@main
with:
extensionName: ${{ github.event.repository.name }}
uploadCoverage: false
runs-on: ubuntu-latest
steps:
- name: Checkout SwagPayPal
uses: actions/checkout@v4
with:
path: custom/plugins/${{ github.event.repository.name }}
- name: Setup SwagPayPal
uses: ./custom/plugins/SwagPayPal/.github/actions/setup-paypal
with:
install-admin: true
- name: Run ESLint
env:
ADMIN_PATH: ${{ github.workspace }}/src/Administration/Resources/app/administration
working-directory: custom/plugins/${{ github.event.repository.name }}
run: composer run jest
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
"scripts": {
"jest": [
"npm run unit-setup --prefix ../../../src/Administration/Resources/app/administration",
"npm run unit --prefix src/Resources/app/administration"
"npm run unit --prefix tests/jest/administration"
],
"jest:watch": [
"npm run unit-setup --prefix ../../../src/Administration/Resources/app/administration",
"npm run unit-watch --prefix src/Resources/app/administration"
"npm run unit-watch --prefix tests/jest/administration"
],
"lint": [
"@ecs-fix",
Expand All @@ -52,8 +52,14 @@
"ecs": "../../../vendor/bin/php-cs-fixer fix --dry-run",
"ecs-fix": "../../../vendor/bin/php-cs-fixer fix",
"init:admin": "npm ci --no-audit --prefer-offline --prefix src/Resources/app/administration",
"lint:admin": "npm run lint-fix --prefix src/Resources/app/administration",
"lint:admin:ci": "npm run lint --prefix src/Resources/app/administration",
"lint:admin": [
"npm run lint-fix --prefix src/Resources/app/administration",
"npm run lint-fix --prefix tests/jest/administration"
],
"lint:admin:ci": [
"npm run lint --prefix src/Resources/app/administration",
"npm run lint --prefix tests/jest/administration"
],
"init:storefront": "npm ci --no-audit --prefer-offline --prefix src/Resources/app/storefront",
"lint:storefront": "@lint:storefront:ci --fix",
"lint:storefront:ci": [
Expand Down
3 changes: 0 additions & 3 deletions src/Resources/app/administration/.eslintignore

This file was deleted.

120 changes: 0 additions & 120 deletions src/Resources/app/administration/.eslintrc.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/Resources/app/administration/babel.config.json

This file was deleted.

147 changes: 147 additions & 0 deletions src/Resources/app/administration/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import vue from 'eslint-plugin-vue';
import vueTs from '@vue/eslint-config-typescript';
import swESLintBase from '@shopware-ag/eslint-config-base';
import importPlugin from 'eslint-plugin-import' ;
import stylistic from '@stylistic/eslint-plugin';
import globals from 'globals';

// use ADMIN_PATH environment variable to change from default installation
process.env.ADMIN_PATH =
process.env.ADMIN_PATH ??
(new URL('../../../../../../../src/Administration/Resources/app/administration', import.meta.url)).toString();

// const twigVuePlugin = import(`${process.env.ADMIN_PATH}/twigVuePlugin`);

export default tseslint.config(
eslint.configs.recommended,
...vue.configs['flat/recommended'],
...vueTs({
extends: [
'recommended',
'recommendedTypeChecked',
'eslintRecommended',
],
}),
{
plugins: { import: importPlugin, stylistic },

ignores: [
'src/app/assets/icons/icons.js',
'**/*.d.ts',
],

languageOptions: {
ecmaVersion: 'latest',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
globals: {
Shopware: true,
},
},

settings: {
'import/resolver': {
node: {},
webpack: {
config: {
// Sync with webpack.config.js
resolve: {
extensions: ['.js', '.ts', '.vue', '.json', '.sass', '.twig'],
alias: {
SwagPayPal: (new URL('src', import.meta.url)).toString(),
src: `${process.env.ADMIN_PATH}/src`,
'@vue/test-utils': `${process.env.ADMIN_PATH}/node_modules/@vue/test-utils`,
vue: `${process.env.ADMIN_PATH}/node_modules/@vue/compat/dist/vue.cjs.js`,
},
},
},
},
},
},

rules: {
...swESLintBase.rules,
indent: 'off',
'comma-dangle': 'off',
'max-len': 'off',

'no-console': ['error', { allow: ['warn', 'error'] }],
'internal-rules/no-src-imports': 'off',

/* import rules */
// lets depend on shopware's deps (vue and @vue/test-utils)
'import/no-extraneous-dependencies': 'off',
'import/no-useless-path-segments': 'off',
'import/extensions': [
'error',
'ignorePackages',
{ js: 'never', ts: 'never' },
],
/* import rules */

/* stylistic rules */
'stylistic/semi': ['error', 'always'],
'stylistic/indent': ['error', 4, { SwitchCase: 1 }],
'stylistic/member-delimiter-style': ['error'],
'stylistic/no-multi-spaces': ['error'],
'stylistic/object-curly-spacing': ['error', 'always'],
'stylistic/space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
}],
'stylistic/spaced-comment': ['error', 'always'],
'stylistic/no-tabs': ['error'],
'stylistic/no-mixed-spaces-and-tabs': ['error'],
'stylistic/max-len': 'off',
'stylistic/quote-props': ['error', 'as-needed'],
'stylistic/no-extra-semi': ['error'],
'stylistic/comma-dangle': ['error', 'always-multiline'],
/* stylistic rules */

/* typescript rules */
'@typescript-eslint/ban-ts-comment': ['error', {
'ts-expect-error': false,
}],
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_|^(e|err)$',
}],
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
/* typescript rules */
},
},
{
files: ['**/*.js'],

ignores: ['src/app/assets/icons/icons.js'],

extends: [tseslint.configs.disableTypeChecked],

rules: {
'prefer-promise-reject-errors': 'error',
},
},
{
files: ['!src/**'],

languageOptions: {
globals: globals.node,
},
},
);
Loading

0 comments on commit 88ad4b5

Please sign in to comment.