diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c26501f --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.DS_Store +node_modules +/dist + +# package lockfile +# (if you run into package version conflicts later, unignore this) +yarn.lock + +# log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +dist diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..203cf4e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "endOfLine": "auto", + "printWidth": 100, + "trailingComma": "es5" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index e56f1b6..3e7163b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- +- Linting and formatting via ESLint and Prettier ### Fixed diff --git a/bin/index.js b/bin/index.js index ee14e60..03c0104 100755 --- a/bin/index.js +++ b/bin/index.js @@ -1,6 +1,5 @@ #!/usr/bin/env node - -const word = require('../index') +import word from "../index.js"; function writeToConsole(output) { process.stdout.clearLine(); @@ -11,11 +10,11 @@ function writeToConsole(output) { console.log("Choosing a word for you..."); (async function demo() { - for (let i = 0; i < 500; i++) { - await new Promise(resolve => setTimeout(resolve, 5)); - let spinner = ["/ ", "—", "\\ ", "| "] - output = spinner[i % 4] + word() + for (let i = 0; i < 500; i += 1) { + // eslint-disable-next-line no-await-in-loop + await new Promise((resolve) => setTimeout(resolve, 5)); + const spinner = ["/ ", "—", "\\ ", "| "]; + const output = spinner[i % 4] + word(); writeToConsole(output); } -})().then( () => writeToConsole("=> " + word() + "\n") ); - +})().then(() => writeToConsole(`=> ${word()}\n`)); diff --git a/index.js b/index.js index 8641bd0..361ffce 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,62 @@ -const WORDS = ["psychotic", "pneumatic", "phonetic", "Pacific", "prosthetic", "pandemic", "pathetic", "pleonastic", "pedantic", "prognostic", "pleuritic", "piratic", "plethoric", "polemic", "phlegmatic", "pancreatic", "presbyopic", "pyknotic", "priapic", "phonemic", "pelagic", "puristic", "pragmatic", "pyretic", "plutonic", "pneumonic", "paretic", "pharisaic", "politic", "pantheistic", "Pharaonic", "Paleozoic", "pyloric", "platonic", "polaric", "plasmic", "prophetic", "prolific", "Potomac", "panoptic", "Puranic", "prodromic", "planktonic", "phyletic", "phenolic", "prostatic", "pilgarlic", "phrenetic", "podagric", "pulmonic", "panini", "Panera", "Pandora", "pandemonium"] +const WORDS = [ + "psychotic", + "pneumatic", + "phonetic", + "Pacific", + "prosthetic", + "pandemic", + "pathetic", + "pleonastic", + "pedantic", + "prognostic", + "pleuritic", + "piratic", + "plethoric", + "polemic", + "phlegmatic", + "pancreatic", + "presbyopic", + "pyknotic", + "priapic", + "phonemic", + "pelagic", + "puristic", + "pragmatic", + "pyretic", + "plutonic", + "pneumonic", + "paretic", + "pharisaic", + "politic", + "pantheistic", + "Pharaonic", + "Paleozoic", + "pyloric", + "platonic", + "polaric", + "plasmic", + "prophetic", + "prolific", + "Potomac", + "panoptic", + "Puranic", + "prodromic", + "planktonic", + "phyletic", + "phenolic", + "prostatic", + "pilgarlic", + "phrenetic", + "podagric", + "pulmonic", + "panini", + "Panera", + "Pandora", + "pandemonium", +]; function word() { - return WORDS[Math.floor(Math.random() * WORDS.length)] + return WORDS[Math.floor(Math.random() * WORDS.length)]; } -module.exports = word +export default word; diff --git a/package.json b/package.json index ff46d59..239ec7a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "repository": { "url": "https://github.com/thecodepixi/pandera" }, + "type": "module", "contributors": [ "Emily Harber", "Yechiel Kalmenson" @@ -17,5 +18,31 @@ }, "bin": { "pandera": "bin/index.js" + }, + "eslintConfig": { + "root": true, + "env": { + "node": true + }, + "extends": [ + "airbnb-base", + "plugin:prettier/recommended" + ], + "ignorePatterns": "node_modules/*.js", + "rules": { + "no-unused-vars": "warn", + "import/extensions": "disable" + }, + "settings": { + "usePrettierrc": true + } + }, + "devDependencies": { + "eslint": "^7.25.0", + "eslint-config-airbnb-base": "^14.2.1", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-prettier": "^3.4.0", + "prettier": "^2.2.1" } }