Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: setup linter and fomatter #14

Merged
merged 3 commits into from
Nov 28, 2024
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
15 changes: 0 additions & 15 deletions .editorconfig

This file was deleted.

87 changes: 0 additions & 87 deletions .eslintrc

This file was deleted.

45 changes: 24 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"

- name: Install Dependencies
run: npm ci
- name: Install Dependencies
run: npm ci

- name: Build
run: npm run build
- name: Build
run: npm run build

- name: Test
run: npm test
- name: Lint
run: npm run lint

- name: Test
run: npm test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
lib/
node_modules
screenshots/
screenshots/
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npx pretty-quick --staged --pattern "**/*.{js,ts,mjs,cjs}"
npm run lint
8 changes: 4 additions & 4 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hooks": {
"before:init": ["npm test"],
"after:bump": "npm run build"
}
"hooks": {
"before:init": ["npm test"],
"after:bump": "npm run build"
}
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
- Fixed issue #1 - an invalid function call when no platform was specified

## [0.0.1] - 2017-01-24
- Initial release
- Initial release
69 changes: 26 additions & 43 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
const babel = require('gulp-babel');
const del = require('del');
const eslint = require('gulp-eslint');
const gulp = require('gulp');
const mocha = require('gulp-mocha');

function clean () {
return del(['lib']);
}

function lint () {
return gulp
.src([
'src/**/*.js',
'test/**/*.js',
'Gulpfile.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}

function build () {
return gulp
.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'));
}

function test () {
return gulp
.src('test/**.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec',
timeout: typeof v8debug === 'undefined' ? 2000 : Infinity // NOTE: disable timeouts in debug
}));
}

exports.clean = clean;
exports.lint = lint;
exports.build = gulp.series(clean, lint, build);
exports.test = gulp.series(build, lint, test);
const babel = require("gulp-babel");
const del = require("del");
const gulp = require("gulp");
const mocha = require("gulp-mocha");

function clean() {
return del(["lib"]);
}

function build() {
return gulp.src("src/**/*.js").pipe(babel()).pipe(gulp.dest("lib"));
}

function test() {
return gulp.src("test/**.js").pipe(
mocha({
ui: "bdd",
reporter: "spec",
timeout: typeof v8debug === "undefined" ? 2000 : Infinity, // NOTE: disable timeouts in debug
}),
);
}

exports.clean = clean;
exports.build = gulp.series(clean, build);
exports.test = gulp.series(build, test);
39 changes: 39 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import js from "@eslint/js";
import prettier from "eslint-config-prettier";
import mocha from "eslint-plugin-mocha";

export default [
{
files: ["src/**/*.js"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
rules: {
...prettier.rules,
...js.configs.recommended.rules,
},
},
{
files: ["test/**/*.js"],
plugins: {
mocha,
},
rules: {
...mocha.configs.recommended.rules,
"mocha/no-exclusive-tests": "error",
"mocha/no-skipped-tests": "warn",
},
},
{
languageOptions: {
globals: {
__dirname: true,
console: true,
exports: true,
module: true,
require: true,
},
},
},
];
Loading