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 9, 2024
1 parent bfb20cd commit cc3252b
Show file tree
Hide file tree
Showing 10 changed files with 9,957 additions and 9,835 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
6 changes: 1 addition & 5 deletions .github/workflows/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@ 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:
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.

14 changes: 9 additions & 5 deletions src/Resources/app/administration/babel.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"presets": ["@babel/preset-env"],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime"
]
"presets": [["@babel/preset-env", {
"corejs": 3,
"useBuiltIns": "usage",
"targets": {
"node": "current"
}
}]],

"plugins": ["@babel/plugin-proposal-class-properties"]
}
217 changes: 217 additions & 0 deletions src/Resources/app/administration/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
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 pluginJest from 'eslint-plugin-jest';
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 = await import(`${process.env.ADMIN_PATH}/twigVuePlugin/lib/index.js`);

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

ignores: ['**/*.d.ts'],

languageOptions: {
ecmaVersion: 'latest',
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 */
},
},
{
files: ['**/*.js', '**/*.ts'],

ignores: ['**/*.d.ts'],

languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},

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: ['**/*.html.twig'],

plugins: { twigVuePlugin },

processor: 'twigVuePlugin/twig-vue',

extends: [vue.configs['flat/recommended']],

rules: {
'vue/multiline-html-element-content-newline': 'off',

'vue/max-attributes-per-line': ['error', { singleline: 3 }],
'vue/component-definition-name-casing': ['error', 'kebab-case'],
'vue/require-explicit-emits': ['error'],
'vue/block-lang': ['error', { script: { lang: 'ts' } }],
'vue/html-indent': ['error', 4, { baseIndent: 0 }],
'vue/html-quotes': ['error', 'double', { avoidEscape: true }],
'vue/html-closing-bracket-newline': ['error', { singleline: 'never', multiline: 'always' }],
'vue/component-name-in-template-casing': ['error', 'kebab-case', { registeredComponentsOnly: true }],
},
},
{
files: [
'**/module/swag-paypal-disputes/**/*.html.twig',
'**/module/swag-paypal-payment/**/*.html.twig',
'**/module/swag-paypal-pos/**/*.html.twig',
'**/module/swag-paypal/**/*.html.twig',
'**/module/extension/**/*.html.twig',
],

rules: {
'vue/attribute-hyphenation': 'off', // $attrs doesn't normalize kebab -> camelCase
'vue/v-on-event-hyphenation': 'off',
'vue/no-v-html': 'off',
'vue/no-unused-vars': 'off',
'vue/valid-v-slot': 'off',
'vue/require-v-for-key': 'off',
'vue/valid-v-for': 'off',
'vue/no-lone-template': 'off',
'vue/valid-v-model': 'off',

// templates are all wrong formatted
'vue/first-attribute-linebreak': 'off',
'vue/html-closing-bracket-newline': 'off',
},
},
{
files: ['**/*.spec.js', '**/*.spec.ts'],

plugins: { jest: pluginJest },

languageOptions: {
globals: {
...globals.node,
...pluginJest.environments.globals.globals,
wrapTestComponent: true,
flushPromises: true,
}
},

rules: {
'jest/expect-expect': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-hooks-in-order': 'error',
'jest/prefer-hooks-on-top': 'error',
'jest/prefer-to-be': 'error',
'jest/require-top-level-describe': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error',
'jest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
},
},
{
files: ['**/*.js'],

extends: [tseslint.configs.disableTypeChecked],

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

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

0 comments on commit cc3252b

Please sign in to comment.