Skip to content

Commit

Permalink
Add eslint config for libraries/utils (#9506)
Browse files Browse the repository at this point in the history
  • Loading branch information
twschiller authored Nov 12, 2024
1 parent 971d00b commit daaff22
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: applications/browser-extension/package.json
node-version-file: package.json
cache: npm
- run: npm ci
- run: npm run lint:full --workspace=applications/browser-extension
- run: npm run lint:full

dead-code:
runs-on: ubuntu-latest
Expand Down
18 changes: 18 additions & 0 deletions libraries/utils/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
extends: [
// Full config: https://github.com/pixiebrix/eslint-config-pixiebrix/blob/main/index.js
// XXX: use exact configuration for now because applications/browser-extension has a lot of local configuration.
// When we bring eslint-config-pixiebrix into the monorepo, we can iterate on code sharing across configs.
"pixiebrix",
],
};

// `npm run lint:fast` will skip the (slow) import/* rules
// Useful if you're trying to iterate fixes over other rules
if (process.env.ESLINT_NO_IMPORTS) {
const importRules = Object.keys(require("eslint-plugin-import").rules);
for (const ruleName of importRules) {
module.exports.rules[`import/${ruleName}`] = "off";
}
}
1 change: 1 addition & 0 deletions libraries/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@swc/core": "^1.9.2",
"@swc/jest": "^0.2.37",
"eslint": "^8.57.0",
"eslint-config-pixiebrix": "^0.41.1",
"jest": "^29.7.0",
"typescript": "^5.6.3"
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/utils/src/debugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type InvalidPathInformation = {
* @param path period separated path
*/
export function getInvalidPath(
value: Record<string, unknown>,
value: UnknownObject,
path: string,
): InvalidPathInformation {
const parts = path.split(".");
Expand Down
21 changes: 21 additions & 0 deletions libraries/utils/src/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2024 PixieBrix, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* eslint-disable-next-line no-restricted-syntax --
* Type to be preferred over a plain `object`
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md */
type UnknownObject = Record<string, unknown>;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"test": "npm run test --workspaces",
"lint": "npm run lint --workspaces",
"lint:full": "npm run lint:full --workspaces",
"build": "npm run build --workspaces",
"build:typecheck": "npm run build:typecheck --workspaces",
"dead-code": "npm run dead-code:base -- --include files,duplicates,dependencies,classMembers,binaries,enumMembers,nsTypes,exports,nsExports",
Expand Down

0 comments on commit daaff22

Please sign in to comment.