Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint config for libraries/utils #9506

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another one of those things that we can to duplicate for now, but eventually we should move to a top level shared types module

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
Loading