diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e19de7a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,40 @@ +# Contributing + +Please be sure to read the contribution guidelines before making or requesting a change. + +## Code of Conduct + +This project adheres to the [OpenJS Foundation Code of Conduct](https://eslint.org/conduct). We kindly request that you read over our code of conduct before contributing. + +## Commands + +### Building + +[Rollup](https://rollupjs.org) and [TypeScript](https://www.typescriptlang.org) are used to turn source files in `packages/*/src/` into outputs in `packages/*/dist/`. + +```shell +npm run build +``` + +### Linting + +ESLint is linted using ESLint. +[Building](#building) the project must be done before it can lint itself. + +```shell +npm run lint +``` + +### Type Checking + +This project is written in JavaScript and uses [TypeScript](https://www.typescriptlang.org) to validate types declared in JSDoc comments. + +```shell +npm run test:types +``` + +Add `--watch` to run in a "watch" mode: + +```shell +npm run test:types -- --watch +``` diff --git a/package.json b/package.json index d942ab0..3b17f7e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "lint:fix": "eslint --fix .", "fmt": "prettier --write .", "fmt:check": "prettier --check .", - "test:jsr": "npm run test:jsr --workspaces --if-present" + "test:jsr": "npm run test:jsr --workspaces --if-present", + "test:types": "tsc" }, "workspaces": [ "packages/*" @@ -27,6 +28,7 @@ "!(*.{js,ts})": "prettier --write --ignore-unknown" }, "devDependencies": { + "@types/mocha": "^10.0.7", "eslint": "^9.11.1", "eslint-config-eslint": "^11.0.0", "got": "^14.4.1", diff --git a/packages/compat/tsconfig.json b/packages/compat/tsconfig.json index 3fa504c..5d8149a 100644 --- a/packages/compat/tsconfig.json +++ b/packages/compat/tsconfig.json @@ -1,13 +1,7 @@ { + "extends": "../../tsconfig.base.json", "files": ["src/index.js"], "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "allowJs": true, - "checkJs": true, - "outDir": "dist/esm", - "target": "ES2022", - "moduleResolution": "NodeNext", - "module": "NodeNext" + "outDir": "dist/esm" } } diff --git a/packages/config-array/tsconfig.json b/packages/config-array/tsconfig.json index 3fa504c..5d8149a 100644 --- a/packages/config-array/tsconfig.json +++ b/packages/config-array/tsconfig.json @@ -1,13 +1,7 @@ { + "extends": "../../tsconfig.base.json", "files": ["src/index.js"], "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "allowJs": true, - "checkJs": true, - "outDir": "dist/esm", - "target": "ES2022", - "moduleResolution": "NodeNext", - "module": "NodeNext" + "outDir": "dist/esm" } } diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index cbeabd7..67750a2 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,13 +1,7 @@ { + "extends": "../../tsconfig.base.json", "files": ["src/types.ts"], "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "allowJs": true, - "checkJs": true, - "outDir": "dist/esm", - "target": "ES2022", - "moduleResolution": "NodeNext", - "module": "NodeNext" + "outDir": "dist/esm" } } diff --git a/packages/migrate-config/tsconfig.json b/packages/migrate-config/tsconfig.json index 08bc479..4e6f7b3 100644 --- a/packages/migrate-config/tsconfig.json +++ b/packages/migrate-config/tsconfig.json @@ -1,13 +1,7 @@ { + "extends": "../../tsconfig.base.json", "files": ["src/migrate-config-cli.js"], "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "allowJs": true, - "checkJs": true, - "outDir": "dist/esm", - "target": "ES2022", - "moduleResolution": "NodeNext", - "module": "NodeNext" + "outDir": "dist/esm" } } diff --git a/packages/object-schema/tsconfig.json b/packages/object-schema/tsconfig.json index 3fa504c..5d8149a 100644 --- a/packages/object-schema/tsconfig.json +++ b/packages/object-schema/tsconfig.json @@ -1,13 +1,7 @@ { + "extends": "../../tsconfig.base.json", "files": ["src/index.js"], "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "allowJs": true, - "checkJs": true, - "outDir": "dist/esm", - "target": "ES2022", - "moduleResolution": "NodeNext", - "module": "NodeNext" + "outDir": "dist/esm" } } diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json index 155d501..bb29a55 100644 --- a/packages/plugin-kit/package.json +++ b/packages/plugin-kit/package.json @@ -47,6 +47,7 @@ "license": "Apache-2.0", "devDependencies": { "@eslint/core": "^0.9.0", + "@types/levn": "^0.4.0", "c8": "^9.1.0", "mocha": "^10.4.0", "rollup": "^4.16.2", diff --git a/packages/plugin-kit/src/@types/levn.d.ts b/packages/plugin-kit/src/@types/levn.d.ts deleted file mode 100644 index 94414cc..0000000 --- a/packages/plugin-kit/src/@types/levn.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare module "levn" { - interface ParseOptions { - explicit?: boolean; - customTypes: Record; - } - - function parse(type: string, input: string, options?: ParseOptions): object; -} diff --git a/packages/plugin-kit/src/config-comment-parser.js b/packages/plugin-kit/src/config-comment-parser.js index f9a2822..17464d9 100644 --- a/packages/plugin-kit/src/config-comment-parser.js +++ b/packages/plugin-kit/src/config-comment-parser.js @@ -9,7 +9,6 @@ // Imports //------------------------------------------------------------------------------ -// @ts-ignore -- don't feel like fighting with TypeScript right now import levn from "levn"; //----------------------------------------------------------------------------- @@ -125,7 +124,8 @@ export class ConfigCommentParser { parseJSONLikeConfig(string) { // Parses a JSON-like comment by the same way as parsing CLI option. try { - const items = levn.parse("Object", string) || {}; + const items = + /** @type {RulesConfig} */ (levn.parse("Object", string)) || {}; /* * When the configuration has any invalid severities, it should be completely diff --git a/packages/plugin-kit/tsconfig.json b/packages/plugin-kit/tsconfig.json index 960debf..779639c 100644 --- a/packages/plugin-kit/tsconfig.json +++ b/packages/plugin-kit/tsconfig.json @@ -1,15 +1,8 @@ { + "extends": "../../tsconfig.base.json", "files": ["src/index.js"], "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "allowJs": true, - "checkJs": true, "outDir": "dist/esm", - "target": "ES2022", - "moduleResolution": "NodeNext", - "module": "NodeNext", - "strict": true, - "typeRoots": ["node_modules/@types", "src/@types"] + "strict": true } } diff --git a/scripts/build.js b/scripts/build.js index 048b38a..b53ae16 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -73,8 +73,8 @@ async function calculatePackageDependencies(packageDirs) { } /** - * Creates an array of directories to be built in order to sastify dependencies. - * @param {Map}} dependencies The + * Creates an array of directories to be built in order to satisfy dependencies. + * @param {Map}>} dependencies The * dependencies between packages. * @returns {Array} An array of directories to be built in order. */ diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..c5740a8 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "declaration": true, + "emitDeclarationOnly": true, + "module": "NodeNext", + "moduleResolution": "NodeNext", + "target": "ES2022" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f4bf5d8 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.base.json", + "include": ["packages/*/src"], + "compilerOptions": { + "emitDeclarationOnly": false, + "noEmit": true + } +}