From 848e951ac68f485588055b2712b3a92d67e0cd3b Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Wed, 22 Feb 2023 13:07:21 +0200 Subject: [PATCH] add .pre-commit-config.yaml & run prettify --- .pre-commit-config.yaml | 26 ++++++++++++++++++++++++++ README.md | 16 ++++++++-------- nodejs/myip.js | 28 +++++++++++++--------------- 3 files changed, 47 insertions(+), 23 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7924e6c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +# Remember to run `pre-commit install` at least once! +# Manual test run: `pre-commit run --all-files` +# Update? `pre-commit autoupdate` +# +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: destroyed-symlinks + - id: detect-private-key + - id: end-of-file-fixer + - id: fix-byte-order-marker + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v3.0.0-alpha.4" + hooks: + - id: prettier + - repo: https://github.com/editorconfig-checker/editorconfig-checker.python + rev: "2.7.1" + hooks: + - id: editorconfig-checker + alias: ec diff --git a/README.md b/README.md index 0713a68..3e527e8 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ through curl/wget. ### Directories -* *bash* has just normal bash scripts -* *nodejs* **MIGHT** get some nodejs scripts -* *WeeChat* is a placeholder and unlikely to get anything. -* *ZNC* is another placeholder which is unlikely to get anything. - * note that they are *modules* with ZNC, but I don't see why I - couldn't put them here. +- _bash_ has just normal bash scripts +- _nodejs_ **MIGHT** get some nodejs scripts +- _WeeChat_ is a placeholder and unlikely to get anything. +- _ZNC_ is another placeholder which is unlikely to get anything. + - note that they are _modules_ with ZNC, but I don't see why I + couldn't put them here. -*I doubt I am going to write many WeeChat scripts or ZNC modules, so I - won't be making subdirectories for different languages.* +_I doubt I am going to write many WeeChat scripts or ZNC modules, so I +won't be making subdirectories for different languages._ diff --git a/nodejs/myip.js b/nodejs/myip.js index eff6da4..9fab229 100755 --- a/nodejs/myip.js +++ b/nodejs/myip.js @@ -1,26 +1,24 @@ #!/usr/bin/env node // Require the dns module -var dns = require('dns'); +var dns = require("dns"); // Function for IPv4 var myip4 = function () { - // Set DNS servers to OpenDNS IPv4 - var servers4 = dns.setServers(["208.67.222.222", "208.67.220.220"]) + // Set DNS servers to OpenDNS IPv4 + var servers4 = dns.setServers(["208.67.222.222", "208.67.220.220"]); - // Check where myip.opendns.com resolves to and I think this is a - // function that takes arguments err and addresses. - dns.resolve4('myip.opendns.com', function (err, addresses) { - - // if err contains a truthy value, an error has occurred - if (err) throw err; + // Check where myip.opendns.com resolves to and I think this is a + // function that takes arguments err and addresses. + dns.resolve4("myip.opendns.com", function (err, addresses) { + // if err contains a truthy value, an error has occurred + if (err) throw err; - // Print the first thing in array addresses as it has our IPv4 - // address. - console.log(addresses[0]); - - }); -} + // Print the first thing in array addresses as it has our IPv4 + // address. + console.log(addresses[0]); + }); +}; // IPv6 part is broken because of node bug. // https://github.com/nodejs/node/issues/894