Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 0 additions & 38 deletions .eslintrc.json

This file was deleted.

66 changes: 38 additions & 28 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI
name: CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
MYSQL_PASSWORD: rootpassword
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- run: npm run eslint

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

test:
name: Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
- uses: mirromutth/mysql-action@v1.1
with:
mysql root password: 'rootpassword'
- uses: supercharge/redis-github-action@1.7.0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- run: npm test
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
6 changes: 3 additions & 3 deletions cli/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const renameUnderscoreFiles = async (dir) => {
await fse.move(srcPath, destPath, { overwrite: true });
}
}
}
};

// replace all occurrences of a regexp in files in a directory
const replaceInDirectory = async (dir, replacements) => {
Expand Down Expand Up @@ -64,10 +64,10 @@ module.exports = async function (argv) {
const directory = './' + args[1];
const model = args.length === 3 ? args[2] : 'tailwind';

await fs.mkdir(directory)
await fs.mkdir(directory);

// recursive copy from skel to project directory
await fse.copy(path.join(__dirname, '../skel', model), directory, { overwrite: false })
await fse.copy(path.join(__dirname, '../skel', model), directory, { overwrite: false });

await renameUnderscoreFiles(directory);

Expand Down
8 changes: 4 additions & 4 deletions cli/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const migrations = require('../src/db/migrations');
const verbs = {

// igo db migrate
migrate: async (args) => {
migrate: async (_args) => {
for (const database of config.databases) {
const db = dbs[database];
db.config.debugsql = false;
Expand All @@ -22,7 +22,7 @@ const verbs = {
},

// igo db migrations
migrations: async (args) => {
migrations: async (_args) => {

for (const database of config.databases) {
const db = dbs[database];
Expand Down Expand Up @@ -90,7 +90,7 @@ const verbs = {
});
},

reverse: async (args) => {
reverse: async (_args) => {
const db = dbs.main;
const tables = await db.query('show tables');
for (const table of tables) {
Expand Down Expand Up @@ -143,7 +143,7 @@ module.exports = async (argv) => {
await dbs.init();

if (args.length > 1 && verbs[args[1]]) {
await verbs[args[1]](args)
await verbs[args[1]](args);
console.log('Done.');
process.exit(0);
} else {
Expand Down
10 changes: 5 additions & 5 deletions cli/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const csvWriter = require('csv-write-stream');
const config = require('../src/config');

const readJson = async(path) => {
const data = await fs.readFile(path)
const data = await fs.readFile(path);
return JSON.parse(data);
};

Expand Down Expand Up @@ -63,7 +63,7 @@ const writeTranslationFiles = async (translations) => {
const verbs = {

// igo i18n update
update: async function(args) {
update: async function(_args) {
if (!config.i18n.spreadsheet_id) {
return console.error('Missing config.i18n.spreadsheet_id');
}
Expand All @@ -86,11 +86,11 @@ const verbs = {
const translations = parseJson(json);
await writeTranslationFiles(translations);
});
})
});
},

// igo i18n csv
csv: async function(args) {
csv: async function(_args) {

const langs = config.i18n.whitelist;
const translations = [];
Expand Down Expand Up @@ -138,7 +138,7 @@ module.exports = function(argv) {
config.init();

if (args.length > 1 && verbs[args[1]]) {
verbs[args[1]](args)
verbs[args[1]](args);
// process.exit(0);
} else {
console.error('ERROR: Wrong options');
Expand Down
37 changes: 37 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const js = require('@eslint/js');
const globals = require('globals');

module.exports = [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2021,
sourceType: 'commonjs',
globals: {
...globals.node,
...globals.mocha,
},
},
rules: {
'indent': ['error', 2, {
'ArrayExpression': 'first',
'CallExpression': { 'arguments': 'first' },
'FunctionDeclaration': { 'body': 1, 'parameters': 'first' },
'MemberExpression': 0,
'ObjectExpression': 1,
}],
'linebreak-style': ['error', 'unix'],
'no-unused-vars': ['error', {
'vars': 'all',
'args': 'after-used',
'ignoreRestSiblings': false,
'argsIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'destructuredArrayIgnorePattern': '^_',
'caughtErrorsIgnorePattern': '^_',
}],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
},
},
];
Loading
Loading