Skip to content

Commit

Permalink
Add type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Nov 13, 2024
1 parent 60c28f9 commit e05e75f
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 15 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ jobs:
- name: ⬆️ Upload coverage report
uses: codecov/codecov-action@v4

are-the-types-wrong:
name: 🤔 Are the types wrong?
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup Node
uses: actions/setup-node@v4
with:
node-version: 18

- name: 📥 Install dependencies
run: npm install --legacy-peer-deps

- name: ▶️ Run test:types script
run: npm run test:types -- --format=table

release:
name: 🚀 Release
needs: [ lint, test ]
Expand Down
16 changes: 9 additions & 7 deletions configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ const plugin = {
rules,
}

const recommended = {
name: "@eslint-community/eslint-comments/recommended",
plugins: {
"@eslint-community/eslint-comments": plugin,
},
rules: rulesRecommended,
}

module.exports = {
recommended: {
name: '@eslint-community/eslint-comments/recommended',
plugins: {
"@eslint-community/eslint-comments": plugin,
},
rules: rulesRecommended,
},
recommended,
}

module.exports.default = module.exports
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/** DON'T EDIT THIS FILE WHICH WAS CREATED BY 'scripts/generate-index.js'. */
"use strict"

const rules = require("./lib/rules")
const utils = require("./lib/utils")
const configs = require("./lib/configs")

module.exports = {
configs: require("./lib/configs"),
rules: require("./lib/rules"),
utils: require("./lib/utils"),
configs,
rules,
utils,
}
28 changes: 24 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,29 @@
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"main": "index.js",
"types": "./types/index.d.ts",
"files": [
"configs.js",
"lib"
"lib",
"types"
],
"exports": {
"./configs": "./configs.js",
".": "./index.js"
"exports": {
"./package.json": "./package.json",
"./configs": {
"types": "./types/configs.d.ts",
"default": "./configs.js"
},
".": {
"types": "./types/index.d.ts",
"default": "./index.js"
}
},
"typesVersions": {
"*": {
"configs": [
"./types/configs.d.ts"
]
}
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
Expand All @@ -22,9 +38,11 @@
"ignore": "^5.2.4"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.0",
"@babel/core": "^7.22.9",
"@babel/eslint-parser": "^7.22.9",
"@eslint-community/eslint-plugin-mysticatea": "^15.5.1",
"@types/eslint": "^8",
"@types/node": "^14.18.54",
"@vuepress/plugin-pwa": "^1.9.9",
"cross-spawn": "^7.0.3",
Expand All @@ -37,6 +55,7 @@
"opener": "^1.5.2",
"rimraf": "^3.0.2",
"semver": "^7.5.4",
"typescript": "^5.6.3",
"vite-plugin-eslint4b": "^0.2.1",
"vitepress": "^1.0.0-rc.15"
},
Expand All @@ -49,6 +68,7 @@
"docs:watch": "vitepress dev docs",
"lint": "eslint lib scripts tests",
"test": "nyc mocha \"tests/lib/**/*.js\" --reporter dot --timeout 8000",
"test:types": "attw --pack",
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
"watch": "npm run -s test -- --watch --growl"
},
Expand Down
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": false,
"esModuleInterop": false,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"lib": ["ESNext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": false,
"strict": true,
"target": "ESNext",
"useDefineForClassFields": true,
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": true
},
"include": ["."]
}
11 changes: 11 additions & 0 deletions types/configs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Linter } from "eslint"

declare namespace Configs {
import defaultExports = Configs

export const recommended: Linter.Config

export { defaultExports as default }
}

export = Configs
7 changes: 7 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ESLint, Linter } from "eslint"

export declare const configs: { recommended: Linter.Config }

export declare const rules: NonNullable<ESLint.Plugin["rules"]>

export declare const utils: { patch: (ruleId?: string) => void }

0 comments on commit e05e75f

Please sign in to comment.