Skip to content

Commit

Permalink
Adds pre-commit hooks via update project
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn committed Jun 12, 2024
1 parent 605b4cd commit 2ff1908
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 197 deletions.
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
repos:

- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: [--quiet]
exclude: node_modules

- repo: local
hooks:
- id: prettier
name: prettier
entry: npm run prettier:fix
language: system
files: arches_lingo/src
- id: eslint
name: eslint
entry: npm run eslint:fix
language: system
files: arches_lingo/src
- id: typescript
name: typescript
entry: npm run ts:check
language: system
types: [
"ts",
"vue",
]
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleAttributePerLine": true
}
Empty file.
5 changes: 3 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import js from "@eslint/js";
import pluginVue from 'eslint-plugin-vue';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from "eslint-config-prettier";

import vueESLintParser from 'vue-eslint-parser';

export default [
js.configs.recommended,
...pluginVue.configs['flat/recommended'],
...tseslint.configs.recommended,
eslintConfigPrettier,
{
"languageOptions": {
"globals": {
Expand Down Expand Up @@ -36,7 +38,6 @@ export default [
},
"rules": {
"semi": ["error", "always"],
"vue/html-indent": ["error", 4]
},
},
]
];
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"eslint:watch": "nodemon --watch . --ext ts,vue --exec npm run --silent eslint:check",
"gettext:extract": "vue-gettext-extract",
"gettext:compile": "vue-gettext-compile",
"prettier:check": "prettier arches_lingo/src --check",
"prettier:fix": "prettier arches_lingo/src --write",
"ts:check": "vue-tsc --noEmit",
"ts:watch": "vue-tsc --watch --noEmit",
"start": "cross-env NODE_OPTIONS=--max-old-space-size=2048 webpack serve --config ./webpack/webpack.config.dev.js",
Expand Down
43 changes: 0 additions & 43 deletions webpack/webpack-utils/build-css-filepath-lookup.js

This file was deleted.

46 changes: 46 additions & 0 deletions webpack/webpack-utils/build-filepath-lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* eslint-disable */

const Path = require('path');
const fs = require('fs');

function buildFilepathLookup(path, staticUrlPrefix) {
if (!fs.existsSync(path)) {
return;
}

const prefix = path.match(/[^/]+$/);
const staticUrl = staticUrlPrefix ? staticUrlPrefix : "";

const getFileList = function (dirPath) {
return fs.readdirSync(dirPath, { withFileTypes: true }).reduce((fileList,entries) => {
const childPath = Path.join(dirPath, entries.name);

if (entries.isDirectory()) {
fileList.push(...getFileList(childPath, fileList));
} else
{
fileList.push(childPath);
}
return fileList;
}, []);
};

return getFileList(path).reduce((lookup, file) => {
const extension = file.match(/[^.]+$/).toString();
const extensionReplacementRegex = new RegExp(`\\.${extension}$`);

if (extension === 'js') {
lookup[file.replace(path,'').replace(/\\/g, '/').replace(extensionReplacementRegex,'').replace(/^\//,'')] = {"import": file, "filename": `${prefix}/[name].${extension}`};
}
else if (extension === 'css' || extension === 'scss') {
lookup[Path.join('css', file.replace(path,'').replace(/\\/g, '/')).replace(extensionReplacementRegex,'').replace(/^\//,'')] = { 'import': file };
}
else {
// staticUrl used for images
lookup[`${staticUrl}${prefix}/${file.replace(path,'').replace(/\\/g, '/').replace(/^\//,'')}`] = file;
}
return lookup;
}, {});
}

module.exports = { buildFilepathLookup };
35 changes: 0 additions & 35 deletions webpack/webpack-utils/build-image-filepath-lookup.js

This file was deleted.

43 changes: 0 additions & 43 deletions webpack/webpack-utils/build-javascript-filepath-lookup.js

This file was deleted.

39 changes: 0 additions & 39 deletions webpack/webpack-utils/build-template-filepath-lookup.js

This file was deleted.

8 changes: 6 additions & 2 deletions webpack/webpack-utils/find-file.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const fs = require('fs');
const Path = require('path');

function findFile(path, target) {
function findFile(path, target, excludedDirectories) {
if (!excludedDirectories) {
excludedDirectories = [];
}

for (const name of fs.readdirSync(path)) {
const filePath = Path.join(path, name);
const stat = fs.lstatSync(filePath);

if (stat.isDirectory() && name !== 'node_modules') {
if (stat.isDirectory() && !excludedDirectories.includes(name)) {
const result = findFile(filePath, target);
if (result) {
return result;
Expand Down
Loading

0 comments on commit 2ff1908

Please sign in to comment.