From 4846d3bad1bf51db3acb1cbdfb81ccc60165aa71 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 1 Jan 2021 02:19:55 +0000 Subject: [PATCH] HTML Reporter: Move files to src/ directory Simplifies the directory structure, and also fixes an omission in grunt `watch-repeatable` and `search` tasks, which didn't monitor the `runner/` directory. Also simply ESLint config while at it. Moving the config to eslintrc, means that `eslint .`, `eslint --fix .` and IDE integration also understands it, instead of being hidden inside Grunt-specific wiring. --- .eslintrc.json | 19 +++++++++++++++---- Gruntfile.js | 19 +++---------------- package.json | 2 -- rollup.config.js | 5 ++++- runner/runner.js | 1 - {reporter => src/html-reporter}/diff.js | 2 +- {reporter => src/html-reporter}/es6-map.js | 2 +- {runner => src/html-reporter}/fixture.js | 4 ++-- {reporter => src/html-reporter}/html.js | 10 +++++----- {reporter => src/html-reporter}/reporter.js | 1 + {reporter => src/html-reporter}/urlparams.js | 4 ++-- src/qunit.js | 3 +-- 12 files changed, 35 insertions(+), 37 deletions(-) delete mode 100644 runner/runner.js rename {reporter => src/html-reporter}/diff.js (99%) rename {reporter => src/html-reporter}/es6-map.js (95%) rename {runner => src/html-reporter}/fixture.js (93%) rename {reporter => src/html-reporter}/html.js (99%) rename {reporter => src/html-reporter}/reporter.js (62%) rename {reporter => src/html-reporter}/urlparams.js (97%) diff --git a/.eslintrc.json b/.eslintrc.json index c4dcb1ced..ab36d8ecd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,11 +13,11 @@ "constructor-super": "error", "indent": ["error", "tab", { "CallExpression": { - "arguments": 1 + "arguments": 1 }, - "MemberExpression": 1, - "SwitchCase": 0, - "outerIIFEBody": 1 + "MemberExpression": 1, + "SwitchCase": 0, + "outerIIFEBody": 1 }], "no-console": "off", "no-const-assign": "error", @@ -33,6 +33,7 @@ "wrap-iife": ["error", "any"] }, "ignorePatterns": [ + "__codeorigin/**", "coverage/**", "docs/_site/**", "dist/**", @@ -61,6 +62,16 @@ "rules": { "no-process-exit": "off" } + }, + { + "files": [ + "test/**/*.html" + ], + "extends": ["eslint:recommended", "jquery"], + "rules": { + "wrap-iife": ["error", "any"], + "indent": "off" + } } ] } diff --git a/Gruntfile.js b/Gruntfile.js index 2936b79c4..5caf03f9c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -60,19 +60,7 @@ module.exports = function( grunt ) { } }, eslint: { - js: ".", - html: { - options: { - rules: { - indent: "off" - } - }, - src: [ - - // Linting HTML files via eslint-plugin-html - "test/**/*.html" - ] - } + all: "." }, search: { options: { @@ -85,8 +73,7 @@ module.exports = function( grunt ) { failOnMatch: true }, xhtml: [ - "src/**/*.js", - "reporter/**/*.js" + "src/**/*.js" ] }, qunit: { @@ -204,7 +191,7 @@ module.exports = function( grunt ) { ".eslintrc.json", "*.js", "build/*.js", - "{src,test,reporter}/**/*.js", + "{src,test}/**/*.js", "src/qunit.css", "test/*.{html,js}", "test/**/*.html" diff --git a/package.json b/package.json index 62b438058..ceb9d3417 100644 --- a/package.json +++ b/package.json @@ -100,8 +100,6 @@ "include": [ "bin/**", "dist/**", - "reporter/**", - "runner/**", "src/**" ], "reporter": [ diff --git a/rollup.config.js b/rollup.config.js index dcce70d3b..f55086fe9 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -36,7 +36,10 @@ module.exports = { // 1. Must not leak as global variable, since it's not full Map implementation. // 2. Must be seen by fuzzysort as-is (e.g. not get renamed as normal // variables in an imported file would be). - return fs.readFileSync( __dirname + "/reporter/es6-map.js", "utf-8" ).toString().trim(); + return fs.readFileSync( + __dirname + "/src/html-reporter/es6-map.js", + "utf-8" + ).toString().trim(); }, globals: { diff --git a/runner/runner.js b/runner/runner.js deleted file mode 100644 index d43faa9d7..000000000 --- a/runner/runner.js +++ /dev/null @@ -1 +0,0 @@ -import "./fixture"; diff --git a/reporter/diff.js b/src/html-reporter/diff.js similarity index 99% rename from reporter/diff.js rename to src/html-reporter/diff.js index 6550d4f93..52101da07 100644 --- a/reporter/diff.js +++ b/src/html-reporter/diff.js @@ -1,4 +1,4 @@ -import QUnit from "../src/core"; +import QUnit from "../core"; import { escapeText } from "./html"; /* diff --git a/reporter/es6-map.js b/src/html-reporter/es6-map.js similarity index 95% rename from reporter/es6-map.js rename to src/html-reporter/es6-map.js index bc1d049cf..b6a41e78f 100644 --- a/reporter/es6-map.js +++ b/src/html-reporter/es6-map.js @@ -1,4 +1,4 @@ -// Support IE 9-10, PhantomJS: Fallback for fuzzysort.js used by /reporter/html.js +// Support IE 9-10, PhantomJS: Fallback for fuzzysort.js used by ./html.js // eslint-disable-next-line no-unused-vars var Map = typeof Map === "function" ? Map : function StringMap() { var store = Object.create( null ); diff --git a/runner/fixture.js b/src/html-reporter/fixture.js similarity index 93% rename from runner/fixture.js rename to src/html-reporter/fixture.js index 9a9b9d328..2ec2e036b 100644 --- a/runner/fixture.js +++ b/src/html-reporter/fixture.js @@ -1,5 +1,5 @@ -import QUnit from "../src/core"; -import { window, document } from "../src/globals"; +import QUnit from "../core"; +import { window, document } from "../globals"; ( function() { diff --git a/reporter/html.js b/src/html-reporter/html.js similarity index 99% rename from reporter/html.js rename to src/html-reporter/html.js index d37f1401e..7b737b5c1 100644 --- a/reporter/html.js +++ b/src/html-reporter/html.js @@ -1,8 +1,8 @@ -import QUnit from "../src/core"; -import Test from "../src/test"; -import { extractStacktrace } from "../src/core/stacktrace"; -import { now, extend } from "../src/core/utilities"; -import { window, document, navigator, console } from "../src/globals"; +import QUnit from "../core"; +import Test from "../test"; +import { extractStacktrace } from "../core/stacktrace"; +import { now, extend } from "../core/utilities"; +import { window, document, navigator, console } from "../globals"; import "./urlparams"; import fuzzysort from "fuzzysort"; diff --git a/reporter/reporter.js b/src/html-reporter/reporter.js similarity index 62% rename from reporter/reporter.js rename to src/html-reporter/reporter.js index fa983be4c..d28704305 100644 --- a/reporter/reporter.js +++ b/src/html-reporter/reporter.js @@ -1,2 +1,3 @@ +import "./fixture"; import "./diff"; import "./html"; diff --git a/reporter/urlparams.js b/src/html-reporter/urlparams.js similarity index 97% rename from reporter/urlparams.js rename to src/html-reporter/urlparams.js index a61da42e9..15e890a9d 100644 --- a/reporter/urlparams.js +++ b/src/html-reporter/urlparams.js @@ -1,5 +1,5 @@ -import QUnit from "../src/core"; -import { window } from "../src/globals"; +import QUnit from "../core"; +import { window } from "../globals"; ( function() { diff --git a/src/qunit.js b/src/qunit.js index 1ef1571e2..f3c960a54 100644 --- a/src/qunit.js +++ b/src/qunit.js @@ -1,3 +1,2 @@ import "./core"; -import "../runner/runner"; -import "../reporter/reporter"; +import "./html-reporter/reporter";