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

Move from JSHint to ESLint #145

Merged
merged 1 commit into from
Feb 29, 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
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: "eslint:recommended",
ignorePatterns: [
"dist"
],
env: {
node: true,
es2024: true
},
overrides: [
{
env: {
mocha: true
},
files: [
"test/**/*.js"
]
}
],
rules: {
"curly": "error",
"eqeqeq": "error",
"new-cap": ["error", { capIsNew: false }],
"no-caller": "error"
}
}
34 changes: 25 additions & 9 deletions .github/workflows/main.yml
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've split the test run from the other tasks, this speeds up the performance of the runners a little. This is also needed, as ESLint doesn't support all the Node.js versions we have on CI.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,31 @@ on:
pull_request:
branches: [master]
jobs:
run:
run-tasks:
name: Run other tasks
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 21
check-latest: true
cache: npm

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint

- name: Run build
run: npx gulp dist

run-tests:
name: Run tests on Node.js v${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -14,8 +38,6 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: true

- name: Set up Node.js
uses: actions/setup-node@v4
Expand All @@ -29,11 +51,5 @@ jobs:
# but it is not compatible with older versions of Node.js that we still support.
run: npm install

- name: Run linter
run: npx gulp lint

- name: Run build
run: npx gulp dist

- name: Run tests
run: npx gulp test karma
19 changes: 0 additions & 19 deletions .jshintrc

This file was deleted.

12 changes: 0 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

var gulp = require('gulp');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var browserify = require('gulp-browserify');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
Expand Down Expand Up @@ -39,12 +37,6 @@ function testKarma(done){
}, done).start();
}

function lint(src){
return gulp.src(src)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish));
}

gulp.task('dist', function(){
return Promise.all([
gulp.src([paths.index])
Expand Down Expand Up @@ -85,7 +77,3 @@ gulp.task('coveralls', function() {
return gulp.src('coverage/**/lcov.info')
.pipe(coveralls());
});

gulp.task('lint', function () {
return lint([paths.index]);
});
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function isNativeFunction(f) {
return false;
}
var exp = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i;
return exp.exec(Function.prototype.toString.call(f)) != null;
return exp.exec(Function.prototype.toString.call(f)) !== null;
}

function hash(object, options) {
Expand Down
Loading