Skip to content

Commit

Permalink
add ESLint to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
oallain committed Jan 6, 2024
1 parent 8381e58 commit 7c2f67d
Show file tree
Hide file tree
Showing 11 changed files with 722 additions and 75 deletions.
16 changes: 16 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
},
extends: [
"eslint:recommended",
],
parserOptions: {
sourceType: "module"
},
globals: {
Translator: 'readonly',
},
};
10 changes: 10 additions & 0 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,15 @@ jobs:
- name: Composer - Update dependencies
run: composer update --no-progress

- name: Yarn install
uses: borales/actions-yarn@v4
with:
cmd: install

- name: Yarn ESLint
uses: borales/actions-yarn@v4
with:
cmd: lint

- name: TwigCS - Check
run: vendor/bin/twigcs templates/ --severity error --display blocking --reporter githubAction
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/vendor/
/node_modules
/composer.lock

/etc/build/*
Expand All @@ -10,8 +8,6 @@

/.phpunit.result.cache
/behat.yml
/phpspec.yml
/phpunit.xml

###> symfony/webpack-encore-bundle ###
/node_modules/
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,19 @@ yarn build

#### Localhost

```bash
$ (cd tests/Application && yarn install)
$ (cd tests/Application && yarn build)
$ (cd tests/Application && APP_ENV=test bin/console assets:install public)
This command will install the selected version of Sylius and the Bootstrap theme with its configuration.
You just need to activate the theme in admin panel as described in the point above.

:information_source: To be able to setup the plugin database, remember to configure you database credentials
in `install/Application/.env.local` and/or `install/Application/.env.test.local`.

$ (cd tests/Application && APP_ENV=test bin/console doctrine:database:create)
$ (cd tests/Application && APP_ENV=test bin/console doctrine:schema:create)
```bash
$ make install -e SYLIUS_VERSION=XX SYMFONY_VERSION=YY PHP_VERSION=ZZ
```

To be able to setup a plugin's database, remember to configure you database credentials in `tests/Application/.env` and `tests/Application/.env.test`.
Default values : XX=1.12.0 and YY=6.3 and ZZ=8.2

:information_source: To reset (drop database and delete files) test environment:
```bash
$ make reset
```
2 changes: 1 addition & 1 deletion assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ axios.defaults.headers.post['X-Requested-With'] = 'XMLHttpRequest';

document.addEventListener('DOMContentLoaded', () => {
// Lightbox
const glightbox = GLightbox({ selector: '.glightbox' });
GLightbox({ selector: '.glightbox' });

// Add to cart
document.querySelectorAll('[data-js-add-to-cart="form"]')
Expand Down
1 change: 1 addition & 0 deletions assets/js/sylius-api-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const SyliusApiToggle = (el) => {
const toggleableElement = document.querySelector('[data-js-login="form"]');

const debounce = (callback, duration) => {
// eslint-disable-next-line
let timeout = null;

return (...args) => {
Expand Down
4 changes: 2 additions & 2 deletions assets/js/sylius-variants-prices.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const handleProductOptionsChange = function handleProductOptionsChange() {

const handleProductVariantsChange = function handleProductVariantsChange() {
document.querySelectorAll('[name="sylius_add_to_cart[cartItem][variant]"]').forEach((item) => {
item.addEventListener('change', (e) => {
item.addEventListener('change', () => {
const priceElement = item.closest('tr').querySelector('[data-js-product-variant-price]');
const price = priceElement.innerHTML;

document.querySelector('[data-js-product-price]').innerHTML = price;

if (priceElement.hasAttribute('data-original-price')) {
Expand Down
45 changes: 0 additions & 45 deletions bin/create_node_symlink.php

This file was deleted.

20 changes: 4 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "sylius/bootstrap-theme",
"type": "sylius-plugin",
"keywords": ["sylius", "sylius-plugin"],
"keywords": ["sylius", "sylius-plugin", "sylius-theme"],
"description": "Bootstrap Theme for Sylius",
"license": "MIT",
"authors": [
{
"name": "Szymon Kulczyński",
"email": "szymon.kulczynski@sylius.com"
"name": "Community contributions",
"homepage": "https://github.com/SyliusCrafts/BootstrapTheme/graphs/contributors"
}
],
"require": {
Expand All @@ -30,7 +30,6 @@
"friends-of-behat/variadic-extension": "^1.3",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
"friendsoftwig/twigcs": "^6.4",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^5.4",
"symfony/debug-bundle": "^5.4",
Expand All @@ -49,7 +48,7 @@
"title": "Sylius Bootstrap Theme"
},
"branch-alias": {
"dev-master": "0.8-dev"
"dev-master": "1.0-dev"
}
},
"config": {
Expand All @@ -58,16 +57,5 @@
"dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true
}
},
"scripts": {
"post-install-cmd": [
"php bin/create_node_symlink.php"
],
"post-update-cmd": [
"php bin/create_node_symlink.php"
],
"post-create-project-cmd": [
"php bin/create_node_symlink.php"
]
}
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "sylius-bootstrap-theme",
"license": "MIT",
"scripts": {
"lint": "eslint -c .eslintrc.cjs ./assets"
},
"devDependencies": {
"eslint": "^8.56.0"
}
}
Loading

0 comments on commit 7c2f67d

Please sign in to comment.