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

Add prettier to format js and ts files #346

Merged
merged 1 commit into from
Aug 26, 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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ module.exports = {
"no-console": "off",
"no-invalid-this": "off",
"no-shadow": "warn",
"brace-style": "off",
"wrap-iife": "off",
"space-before-function-paren": "off",
"indent": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/member-delimiter-style": "off",
},
"globals": {
"$": false,
Expand Down
6 changes: 5 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Auto detect text files and perform LF normalization
* text=auto
* text=auto
*.js text eol=lf
*.jsx text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
83 changes: 46 additions & 37 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,66 @@ const gulp = require("gulp");
"./tasks/download-default-extensions",
"./tasks/nls-check",
"./tasks/eslint",
"./tasks/format",
"./tasks/npm-install",
"./tasks/test",
"./tasks/watch",
"./tasks/webpack",
"./tasks/write-config"
"./tasks/write-config",
].forEach((taskfile) => {
require(taskfile);
});

gulp.task(
"install",
gulp.series(
"write-config:dist",
"npm-download-default-extensions",
"npm-install-source",
"webpack-browser-dependencies"
)
);

gulp.task("install", gulp.series(
"write-config:dist",
"npm-download-default-extensions",
"npm-install-source",
"webpack-browser-dependencies"
));

gulp.task("build", gulp.series(
"npm-install-dist",
"npm-install-extensions-dist"
));
gulp.task("build", gulp.series("npm-install-dist", "npm-install-extensions-dist"));

// task: optimize - optimize contents of dist folder
gulp.task("optimize-common", gulp.series(
// "eslint:src",
// "clean",
// "targethtml",
// "useminPrepare",
// "htmlmin",
// "requirejs",
// "concat",
// "cssmin",
// "uglify",
// "copy:dist",
// "cleanempty",
// "usemin",
"build-config"
// "clean:node_modules_test_dir"
));
gulp.task(
"optimize-common",
gulp.series(
// "eslint:src",
// "clean",
// "targethtml",
// "useminPrepare",
// "htmlmin",
// "requirejs",
// "concat",
// "cssmin",
// "uglify",
// "copy:dist",
// "cleanempty",
// "usemin",
"build-config"
// "clean:node_modules_test_dir"
)
);

// task: optimize
gulp.task("optimize", gulp.series(
// "write-config:dist",
"optimize-common"
));
gulp.task(
"optimize",
gulp.series(
// "write-config:dist",
"optimize-common"
)
);

// task: optimize-prerelease
gulp.task("optimize-prerelease", gulp.series(
// "write-config:prerelease",
"optimize-common"
));
gulp.task(
"optimize-prerelease",
gulp.series(
// "write-config:prerelease",
"optimize-common"
)
);

gulp.task("test", gulp.parallel("eslint", "nls-check"));
gulp.task("test", gulp.parallel("eslint", "nls-check", "format-check"));
gulp.task("default", gulp.series("test"));
96 changes: 96 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
"tslint:app": "tslint -c tslint.json --project app/tsconfig.json -t stylish",
"tslint:src": "tslint -c src/tslint.json --project src/tsconfig.json -t stylish",
"tslint": "npm run tslint:app && npm run tslint:src",
"lint": "npm run tslint && gulp eslint",
"format": "gulp format",
"dev": "concurrently --kill-others \"gulp watch\" \"tsc --watch --project src\" \"npm run webpack -- --watch\"",
"start": "electron .",
"pack": "npm run build-optimized && electron-builder --dir",
Expand Down Expand Up @@ -175,6 +177,7 @@
"glob": "^7.1.4",
"gulp": "^4.0.2",
"gulp-eslint-new": "^2.3.0",
"gulp-prettier": "^5.0.0",
"gulp-rename": "^2.0.0",
"gulp-watch": "^5.0.1",
"iconv-lite": "^0.6.3",
Expand Down
3 changes: 3 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
"tslint:app": "tslint -c tslint.json --project app/tsconfig.json -t stylish",
"tslint:src": "tslint -c src/tslint.json --project src/tsconfig.json -t stylish",
"tslint": "npm run tslint:app && npm run tslint:src",
"lint": "npm run tslint && gulp eslint",
"format": "gulp format",
"dev": "concurrently --kill-others \"gulp watch\" \"tsc --watch --project src\" \"npm run webpack -- --watch\"",
"start": "electron .",
"pack": "npm run build-optimized && electron-builder --dir",
Expand Down Expand Up @@ -203,6 +205,7 @@
"glob": "^7.1.4",
"gulp": "^4.0.2",
"gulp-eslint-new": "^2.3.0",
"gulp-prettier": "^5.0.0",
"gulp-rename": "^2.0.0",
"gulp-watch": "^5.0.1",
"iconv-lite": "^0.6.3",
Expand Down
1 change: 1 addition & 0 deletions tasks/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const meta = {
"tasks/**/*.ts"
]
};
exports.meta = meta;

function eslintTask(files) {
// To automatically fix issues add `fix: true` to the eslint options and
Expand Down
48 changes: 48 additions & 0 deletions tasks/format.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024 - present The quadre code authors. All rights reserved.
* @license MIT
*
*/

"use strict";

const gulp = require("gulp");
const prettier = require("gulp-prettier");
// const { meta } = require("./eslint");

const options = {
printWidth: 100,
tabWidth: 4,
semi: true,
trailingComma: "es5",
};

function getGlobs() {
const globs = [
"gulpfile.js",
// ...meta.app,
// ...meta.src,
// ...meta.test,
// ...meta.build,
];
return globs;
}

function format() {
return gulp
.src(getGlobs())
.pipe(prettier(options))
.pipe(gulp.dest((file) => file.base));
}

format.description = "Format the source code";

gulp.task("format", format);

function validate() {
return gulp.src(getGlobs()).pipe(prettier.check(options));
}

format.description = "Format the source code";

gulp.task("format-check", validate);
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"variable-name": false,
"no-implicit-dependencies": [true, "dev"],
"no-console": false,
"max-classes-per-file": false
"max-classes-per-file": false,
"one-line": false
}
}
6 changes: 6 additions & 0 deletions webpack.dev.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright (c) 2024 - present The quadre code authors. All rights reserved.
* @license MIT
*
*/

import path from "node:path";
import { Configuration } from "webpack";
import TranspilePlugin from "transpile-webpack-plugin";
Expand Down
Loading