Skip to content

Commit

Permalink
ci: setup linter
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng92 committed Nov 27, 2024
1 parent 270dbca commit 951bd1e
Show file tree
Hide file tree
Showing 14 changed files with 21,423 additions and 19,648 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[{.eslintrc,*.json,.travis.yml}]
[{*.json,.travis.yml, **/*.js}]
indent_size = 2
87 changes: 0 additions & 87 deletions .eslintrc

This file was deleted.

46 changes: 25 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
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: Lint
run: npm run lint

- name: Test
run: npm test

- name: Test
run: npm test
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
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

0 comments on commit 951bd1e

Please sign in to comment.