Skip to content

chore: modernize lint and tsconfig setup#34

Open
zhannurkhan04 wants to merge 1 commit into
microsoft:mainfrom
zhannurkhan04:update-legacy-configs
Open

chore: modernize lint and tsconfig setup#34
zhannurkhan04 wants to merge 1 commit into
microsoft:mainfrom
zhannurkhan04:update-legacy-configs

Conversation

@zhannurkhan04
Copy link
Copy Markdown

No description provided.

Comment thread eslint.config.mjs
Comment on lines +5 to +14
ignores: [
"node_modules/**",
"dist/**",
"coverage/**",
"test/**",
"karma.conf.ts",
"webpack.config.js",
"lib/**",
".tmp/**",
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ignores list contains paths that don't exist in this repository

The list looks copy-pasted from a Power BI visual template. This repo is a utility library with only src/, lib/, and node_modules/ as code-bearing directories — dist/, coverage/, test/, karma.conf.ts, webpack.config.js, .tmp/ are not present.

Suggested trim:

ignores: [
    "node_modules/**",
    "lib/**",
],

If the boilerplate entries are kept intentionally (e.g. anticipating a future test runner), a short comment would help future maintainers.

Comment thread package.json
Comment on lines +20 to +23
"@typescript-eslint/eslint-plugin": "^8.59.4",
"@typescript-eslint/parser": "^8.59.4",
"eslint": "^10.4.0",
"eslint-plugin-powerbi-visuals": "^1.1.1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typescript is not declared as a devDependency

npm run build calls tsc directly, but typescript is not listed in devDependencies. It currently resolves only because it's pulled in transitively by @typescript-eslint/* (today typescript@6.0.3). That makes the build:

  • Non-reproducible — any transitive change can swap the compiler under us.
  • Implicit — readers can't tell which TS version the library targets.

Since this PR explicitly modernizes to TS 6 (mentioned in the CHANGELOG), it's the right time to pin it. Suggested addition:

"devDependencies": {
  ...
  "typescript": "^6.0.0"
}

(Pre-existing on main, but worth fixing as part of the toolchain modernization.)

Comment thread tsconfig.json
Comment on lines +26 to +28
"include": [
"src/**/*.ts"
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: inconsistent indentation around include

   "include": [
      "src/**/*.ts"
    ]

The compilerOptions block uses 6-space indentation while this new include block uses 3 spaces before the key and 4 before the closing ]. Valid JSON, but visually broken. Suggested normalization to match the rest of the file:

  "include": [
      "src/**/*.ts"
  ]

Also worth ending the file with a trailing newline (the previous version was missing one and the new one is too).

Comment thread package.json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lint script uses the removed --ext flag

The "lint" script still passes --ext .js,.jsx,.ts,.tsx:

"lint": "npx eslint . --ext .js,.jsx,.ts,.tsx"

ESLint 9 removed the --ext CLI flag together with .eslintrc support; ESLint 10 (pinned in this PR) has no use for it either. The script still appears to work only because eslint-plugin-powerbi-visuals@1.1.1's recommended preset already declares files: ["**/*.{js,jsx,ts,tsx}"], so the flag is silently ignored. It will start failing on a future minor bump or if the preset's files glob changes.

Could you simplify to:

"lint": "eslint ."

(npx is also unnecessary in npm scripts — node_modules/.bin is already on PATH.)

Comment thread CHANGELOG.md

### Changed
* Migrated ESLint config to flat-config ESM `eslint.config.mjs`.
* Removed legacy `.eslintrc.js` and `.eslintignore` in favor of flat-config equivalents.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This bullet doesn't match the actual tsconfig changes

Two inaccuracies vs. the tsconfig.json shipped in this PR:

  1. ignoreDeprecations is not set anywhere in the new tsconfig.json. Either drop it from this bullet or add it to the config (TS 6 reports several deprecations from the previous setup — ignoreDeprecations: "6.0" is what this line implies).
  2. strict: true is effectively disabled. Right next to it the PR sets strictNullChecks: false, strictPropertyInitialization: false, noImplicitAny: false, which turns off the three biggest strict-mode checks. Advertising "strict" here is misleading — consumers won't get strict-mode guarantees. Either remove the claim or actually enable the sub-flags.

Comment thread tsconfig.json
Comment on lines +8 to +9
"module": "ES2020",
"moduleResolution": "bundler",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mismatched module / moduleResolution pair

Per the TypeScript Modules Reference:

--moduleResolution bundler must be paired with --module esnext or --module preserve.

The current "module": "ES2020" + "moduleResolution": "bundler" combination is technically accepted by tsc today but is not an officially supported pair — a future TS minor may emit TS5095.

Since the utils are moving to Vite (also a bundler), bundler resolution is the right choice. Suggested fix:

"module": "preserve",
"moduleResolution": "bundler",
"target": "es2022"

"preserve" (TS 5.4+) is preferred over "esnext" because it lets a file mix import and import x = require(...) if ever needed, and it matches what modern bundlers (Vite/Rollup/esbuild) actually do. Bumping target to es2022 aligns with what nodenext/modern Node already supports and avoids unnecessary downleveling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants