-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from Oksydan/coding-standards
Coding standards fixes and githubactions
- Loading branch information
Showing
24 changed files
with
2,803 additions
and
733 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Lint code | ||
|
||
on: [ push, pull_request ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
eslint: | ||
name: Code quality - ESLint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16.x' | ||
|
||
- name: Install dependencies | ||
run: cd ./_theme_dev && npm install | ||
|
||
- name: Eslint action | ||
run: cd ./_theme_dev && npm run js-lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: PHP tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
php-linter: | ||
name: PHP Syntax check 7.4 => 8.1 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: PHP syntax checker 7.4 | ||
uses: prestashop/github-action-php-lint/7.4@master | ||
|
||
- name: PHP syntax checker 8.0 | ||
uses: prestashop/github-action-php-lint/8.0@master | ||
|
||
- name: PHP syntax checker 8.1 | ||
uses: prestashop/github-action-php-lint/8.1@master | ||
|
||
php-cs-fixer: | ||
name: PHP-CS-Fixer | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.1' | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: php-${{ hashFiles('composer.lock') }} | ||
|
||
- name: Install dependencies | ||
run: composer install | ||
|
||
- name: Run PHP-CS-Fixer | ||
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
$config = new PrestaShop\CodingStandards\CsFixer\Config(); | ||
|
||
/** @var \Symfony\Component\Finder\Finder $finder */ | ||
$finder = $config->setUsingCache(true)->getFinder(); | ||
$finder->in(__DIR__)->exclude('vendor'); | ||
|
||
return $config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/node_modules/ | ||
/webpack/ | ||
postcss.config.js | ||
webpack.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
browser: true, | ||
node: false, | ||
es6: true, | ||
jquery: true, | ||
}, | ||
globals: { | ||
google: true, | ||
document: true, | ||
navigator: false, | ||
window: true, | ||
prestashop: true, | ||
}, | ||
extends: ['airbnb-base'], | ||
rules: { | ||
'max-len': ['error', {code: 140}], | ||
'no-underscore-dangle': 'off', | ||
'no-restricted-syntax': 'off', | ||
'no-param-reassign': 'off', | ||
'import/no-unresolved': 'off', | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 2022 | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v18.12.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "stylelint-config-recommended-scss", | ||
"rules": { | ||
"scss/at-extend-no-missing-placeholder": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,58 @@ | ||
function initListDisplay() { | ||
const handleClickEvent = (e) => { | ||
const target = e.target.closest('[data-toggle-listing]'); | ||
|
||
if(target && target.dataset.toggleListing !== undefined) { | ||
e.preventDefault(); | ||
|
||
if (target.classList.contains('active')) { | ||
return | ||
const handleClickEvent = (e) => { | ||
const target = e.target.closest('[data-toggle-listing]'); | ||
|
||
if (target && target.dataset.toggleListing !== undefined) { | ||
e.preventDefault(); | ||
|
||
if (target.classList.contains('active')) { | ||
return; | ||
} | ||
|
||
const display = target.dataset.displayType; | ||
const allButtons = document.querySelectorAll('[data-toggle-listing]'); | ||
|
||
allButtons.forEach((button) => { | ||
button.classList.remove('active'); | ||
}); | ||
|
||
target.classList.add('active'); | ||
|
||
let requestData = { | ||
displayType: display, | ||
ajax: 1, | ||
}; | ||
|
||
requestData = Object.keys(requestData).map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(requestData[key])}`).join('&'); | ||
|
||
fetch(window.listDisplayAjaxUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
}, | ||
body: requestData, | ||
}) | ||
.then((resp) => resp.text()) | ||
.then((resp) => { | ||
try { | ||
const response = JSON.parse(resp); | ||
|
||
if (response.success) { | ||
prestashop.emit('updateFacets', window.location.href); | ||
} | ||
|
||
const display = target.dataset.displayType; | ||
const allButtons = document.querySelectorAll('[data-toggle-listing]'); | ||
|
||
allButtons.forEach((button) => { | ||
button.classList.remove('active'); | ||
}) | ||
|
||
target.classList.add('active'); | ||
|
||
let requestData = { | ||
displayType: display, | ||
ajax: 1, | ||
}; | ||
|
||
requestData = Object.keys(requestData).map(key => encodeURIComponent(key) + '=' + encodeURIComponent(requestData[key])).join('&') | ||
|
||
fetch(listDisplayAjaxUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
}, | ||
body: requestData | ||
}) | ||
.then((resp) => resp.text()) | ||
.then((resp) => { | ||
try { | ||
const response = JSON.parse(resp) | ||
|
||
if (response.success) { | ||
prestashop.emit('updateFacets', window.location.href); | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
}) | ||
} | ||
} catch (error) { | ||
console.error(error); // eslint-disable-line no-console | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error(error); // eslint-disable-line no-console | ||
}); | ||
} | ||
}; | ||
|
||
document.addEventListener('click', handleClickEvent); | ||
document.addEventListener('click', handleClickEvent); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
initListDisplay(); | ||
initListDisplay(); | ||
}); | ||
|
Oops, something went wrong.