Skip to content

Commit

Permalink
fix: correct build configuration for ESLint plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Sep 25, 2023
1 parent 9b9f43f commit 16ff20c
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"node": ">= 18"
},
"scripts": {
"build": "tsc -b tsconfig.json --pretty",
"build": "tsc -b tsconfig.build.json --pretty",
"clean": "del-cli build/ \"*.tsbuildinfo\"",
"lint:ts": "eslint --cache --ext .ts \"src/**/*.ts\"",
"lint:ts:fix": "yarn run lint:ts --fix"
Expand Down
8 changes: 6 additions & 2 deletions packages/eslint-plugin/src/rules/ccapi-validate-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import {
AST_TOKEN_TYPES,
ESLintUtils,
} from "@typescript-eslint/utils";
import { findDecoratorContainingCCId, getCCNameFromDecorator } from "../utils";
import {
type Rule,
findDecoratorContainingCCId,
getCCNameFromDecorator,
} from "../utils";

const isFixMode = process.argv.some((arg) => arg.startsWith("--fix"));

export const ccAPIValidateArgs = ESLintUtils.RuleCreator.withoutDocs({
export const ccAPIValidateArgs: Rule = ESLintUtils.RuleCreator.withoutDocs({
create(context) {
let currentAPIClassCCName: string | undefined;
let validateArgsImport: string | undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/no-debug-in-tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
import path from "node:path";
import { repoRoot } from "../utils.js";
import { type Rule, repoRoot } from "../utils.js";

const isFixMode = process.argv.some((arg) => arg.startsWith("--fix"));

Expand All @@ -20,7 +20,7 @@ const integrationTestExportNames = new Set([
"integrationTest",
]);

export const noDebugInTests = ESLintUtils.RuleCreator.withoutDocs({
export const noDebugInTests: Rule = ESLintUtils.RuleCreator.withoutDocs({
create(context) {
const integrationTestMethodNames = new Set<string>();

Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin/src/rules/no-forbidden-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ESLintUtils, type TSESTree } from "@typescript-eslint/utils";
import fs from "node:fs";
import path from "node:path";
import ts from "typescript";
import { type Rule } from "../utils";

// Whitelist some imports that are known not to import forbidden modules
const whitelistedImports = [
Expand Down Expand Up @@ -185,7 +186,7 @@ function resolveSourceFileFromDefinition(

const forbiddenImportsRegex = /^@forbiddenImports (?<forbidden>.*?)$/;

export const noForbiddenImports = ESLintUtils.RuleCreator.withoutDocs({
export const noForbiddenImports: Rule = ESLintUtils.RuleCreator.withoutDocs({
create(context) {
// And only those with at least one /* @forbiddenImports ... */ comment
const comments = context.sourceCode.getAllComments()
Expand Down
8 changes: 7 additions & 1 deletion packages/eslint-plugin/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { AST_NODE_TYPES, type TSESTree } from "@typescript-eslint/utils";
import {
AST_NODE_TYPES,
type TSESLint,
type TSESTree,
} from "@typescript-eslint/utils";
import { CommandClasses } from "@zwave-js/core";
import path from "node:path";

Expand Down Expand Up @@ -88,3 +92,5 @@ export function getCCIdFromDecorator(
): CommandClasses {
return (CommandClasses as any)[getCCNameFromDecorator(decorator)];
}

export type Rule = TSESLint.RuleModule<any, never[], TSESLint.RuleListener>;
19 changes: 19 additions & 0 deletions packages/eslint-plugin/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// tsconfig for building - only applies to the src directory
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
},
"references": [
{
"path": "../core/tsconfig.build.json"
}
],
"include": [
"src/**/*.ts"
],
"exclude": [
"src/**/*.test.ts"
]
}
18 changes: 10 additions & 8 deletions packages/eslint-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// tsconfig for IntelliSense - active in all files in the current package
{
"extends": "@tsconfig/node18/tsconfig.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build",
"incremental": true,
"sourceMap": true
"types": ["node", "@typescript-eslint/utils"]
},
"include": [
"src/**/*.ts"
],
"references": [
{
"path": "../core"
}
],
"include": [
"src/**/*.ts"
],
"exclude": [
"build/**",
"node_modules/**"
]
}

0 comments on commit 16ff20c

Please sign in to comment.