From 197f0a61bb12cc4af5f11a755106df9673614a83 Mon Sep 17 00:00:00 2001 From: Patrick Taylor Date: Thu, 20 Jun 2024 20:53:15 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Configured=20eslint-plugin-inclusive-langua?= =?UTF-8?q?ge=20=F0=9F=8C=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/eslint/rules/inclusive-language.ts | 7 +++++++ package.json | 1 + yarn.lock | 12 ++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 config/eslint/rules/inclusive-language.ts diff --git a/config/eslint/rules/inclusive-language.ts b/config/eslint/rules/inclusive-language.ts new file mode 100644 index 0000000..4a2c561 --- /dev/null +++ b/config/eslint/rules/inclusive-language.ts @@ -0,0 +1,7 @@ +// https://github.com/muenzpraeger/eslint-plugin-inclusive-language + +export default { + 'inclusive-language/use-inclusive-words': [2, { + lintStrings: true, + }], +} diff --git a/package.json b/package.json index 7fdade9..08bc6a7 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "chokidar": "3.6.0", "commander": "12.1.0", "eslint": "9.4.0", + "eslint-plugin-inclusive-language": "2.2.1", "glob": "10.4.1", "markdownlint": "0.34.0", "node-notifier": "10.0.1", diff --git a/yarn.lock b/yarn.lock index 0609401..d624c11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2373,6 +2373,13 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +eslint-plugin-inclusive-language@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-inclusive-language/-/eslint-plugin-inclusive-language-2.2.1.tgz#6cc0f70b10236e2709818f26140a2cbf2c82c041" + integrity sha512-RL6avDWXCS0Dcp9axhvHRUp65qG07qjOrh6J4BNNahPvRY3PuYGnAd0H1strZ9cob79JiEW4Bq0j3gEuzbv0/A== + dependencies: + humps "^2.0.1" + eslint-scope@^8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.0.1.tgz#a9601e4b81a0b9171657c343fb13111688963cfc" @@ -2780,6 +2787,11 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +humps@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/humps/-/humps-2.0.1.tgz#dd02ea6081bd0568dc5d073184463957ba9ef9aa" + integrity sha512-E0eIbrFWUhwfXJmsbdjRQFQPrl5pTEoKlz163j1mTqqUnU9PgR4AgB8AIITzuB3vLBdxZXyZ9TDIrwB2OASz4g== + ignore@^5.2.0, ignore@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef" From fe1b3219cbe9a5bc1a4bcfc5d7e69f98dee8ee29 Mon Sep 17 00:00:00 2001 From: Patrick Taylor Date: Thu, 20 Jun 2024 22:22:26 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Compile=20the=20configuration=20files=20?= =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/all.ts | 3 ++ config/eslint/build-config.ts | 12 +++++ package.json | 10 ++--- scripts/build-config.ts | 82 +++++++++++++++++++++++++++++++++++ tsconfig.json | 3 +- 5 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 config/all.ts create mode 100644 config/eslint/build-config.ts create mode 100644 scripts/build-config.ts diff --git a/config/all.ts b/config/all.ts new file mode 100644 index 0000000..930301a --- /dev/null +++ b/config/all.ts @@ -0,0 +1,3 @@ +import buildConfig from './eslint/build-config' + +export default buildConfig() diff --git a/config/eslint/build-config.ts b/config/eslint/build-config.ts new file mode 100644 index 0000000..c646102 --- /dev/null +++ b/config/eslint/build-config.ts @@ -0,0 +1,12 @@ +import InclusiveLanguageRules from './rules/inclusive-language' + +const buildConfig = () => ({ + plugins: [ + 'inclusive-language', + ], + rules: { + ...InclusiveLanguageRules, + }, +}) + +export default buildConfig diff --git a/package.json b/package.json index 08bc6a7..073b12c 100644 --- a/package.json +++ b/package.json @@ -11,15 +11,13 @@ "node": ">=18.18.0" }, "bin": { - "lint-pilot": "lib/index.min.js" + "lint-pilot": "index.min.js" }, - "files": [ - "lib" - ], "scripts": { - "build": "rimraf lib && mkdir lib && rollup -c", + "build": "rimraf lib && mkdir lib && rollup -c && yarn buildConfig", + "buildConfig": "tsx ./scripts/build-config.ts", "lint": "tsx src/index.js", - "prepublishOnly": "yarn test --coverage && yarn build", + "publishLib": "yarn test --coverage && yarn build && cd lib && npm publish", "test": "jest" }, "dependencies": { diff --git a/scripts/build-config.ts b/scripts/build-config.ts new file mode 100644 index 0000000..59ed9e9 --- /dev/null +++ b/scripts/build-config.ts @@ -0,0 +1,82 @@ +import fs from 'fs' +import path from 'path' +import util from 'util' + +const configFolder = './config' +const outputFolder = './lib' + +/* + * Utilities + */ + +const writeFile = async (filename: string, contents: Record): Promise => { + const contentsString = util.inspect(contents, { + depth: Infinity, + maxArrayLength: Infinity, + maxStringLength: Infinity, + }) + + await fs.promises.writeFile(filename, `module.exports = ${contentsString}\n`) +} + +/* + * Compile Lint Configuration + */ + +const compileLintConfiguration = async (): Promise => { + try { + const files = await fs.promises.readdir(configFolder) + + for (const file of files) { + const filePath = path.join(configFolder, file) + + if ((await fs.promises.stat(filePath)).isFile()) { + const filename = path.parse(file).name + + console.log(`Building config from "${file}"`) + + const module = await import(filePath) + await writeFile(path.join(outputFolder, `${filename}.js`), module.default) + + console.log(`Successfully built "${filename}.js"!\n`) + } + } + } catch (error) { + console.error(`Error: ${error.message}`) + } +} + +/* + * Copy Additional Files + */ + +const copyFiles = async () => { + try { + const files = [ + 'package.json', + 'README.md', + ] + + for (const file of files) { + const sourcePath = path.resolve(`./${file}`) + const destinationPath = path.join(outputFolder, file) + + await fs.promises.copyFile(sourcePath, destinationPath) + console.log(`Successfully copied "${file}" to output folder`) + } + } catch (error) { + console.error('An error occurred while copying files:', error) + process.exit(1) + } +} + +/* + * Run + */ + +const init = async () => { + await compileLintConfiguration() + await copyFiles() +} + +init() diff --git a/tsconfig.json b/tsconfig.json index c02275b..91f4dc4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,11 +9,12 @@ "@Types": ["./src/types/index.ts"], "@Utils/*": ["./src/utils/*"], }, - "rootDir": "./src", + "rootDir": "./", "strict": true, "target": "ESNext" }, "include": [ + "config/**/*.ts", "src/**/*.ts", "src/types/global.d.ts" ], From 3947cd2745d478e42c224539001f4045b1ec384d Mon Sep 17 00:00:00 2001 From: Patrick Taylor Date: Thu, 20 Jun 2024 22:32:46 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Updated=20depcheckrc=20=F0=9F=AB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .depcheckrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.depcheckrc b/.depcheckrc index a4833e6..7400529 100644 --- a/.depcheckrc +++ b/.depcheckrc @@ -1,4 +1,5 @@ ignores: [ + "eslint-plugin-inclusive-language", "rimraf", "@types/jest" ]