Skip to content

Commit

Permalink
Configured eslint-plugin-inclusive-language 🌈 (#3)
Browse files Browse the repository at this point in the history
* Configured eslint-plugin-inclusive-language 🌈

* Compile the configuration files πŸ—οΈ

* Updated depcheckrc 🫀
  • Loading branch information
01taylop authored Jun 20, 2024
1 parent 0e9ef59 commit 8cdcefa
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 7 deletions.
1 change: 1 addition & 0 deletions .depcheckrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ignores: [
"eslint-plugin-inclusive-language",
"rimraf",
"@types/jest"
]
Expand Down
3 changes: 3 additions & 0 deletions config/all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import buildConfig from './eslint/build-config'

export default buildConfig()
12 changes: 12 additions & 0 deletions config/eslint/build-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import InclusiveLanguageRules from './rules/inclusive-language'

const buildConfig = () => ({
plugins: [
'inclusive-language',
],
rules: {
...InclusiveLanguageRules,
},
})

export default buildConfig
7 changes: 7 additions & 0 deletions config/eslint/rules/inclusive-language.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// https://github.com/muenzpraeger/eslint-plugin-inclusive-language

export default {
'inclusive-language/use-inclusive-words': [2, {
lintStrings: true,
}],
}
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@
"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": {
"chalk": "5.3.0",
"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",
Expand Down
82 changes: 82 additions & 0 deletions scripts/build-config.ts
Original file line number Diff line number Diff line change
@@ -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<string, unknown>): Promise<void> => {
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<void> => {
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()
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==

[email protected]:
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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8cdcefa

Please sign in to comment.