-
Notifications
You must be signed in to change notification settings - Fork 11
[Draft] Upgrade to eslint v9 #2709
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
Closed
gokulprasanth-ni
wants to merge
6
commits into
main
from
users/gokulprasanthRavi/feat/update-to-flat-eslint-config
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d31bf3f
update to eslint v9 flat config
gokulprasanth-ni 1c0e80f
update versions
gokulprasanth-ni 3acc903
update lock file
gokulprasanth-ni 076f88b
fix: linting issue
gokulprasanth-ni f1435a6
update lock file
gokulprasanth-ni 2c8f519
update config files
gokulprasanth-ni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| import { javascriptNimbleConfig } from '@ni-private/eslint-config-nimble/javascript'; | ||
| import { typescriptNimbleConfig } from '@ni-private/eslint-config-nimble/typescript'; | ||
| import { | ||
| angularConfig, | ||
| angularTemplateConfig, | ||
| ignoreAttributes, | ||
| } from '@ni/eslint-config-angular'; | ||
| import { defineConfig } from 'eslint/config'; | ||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const packageDir = path.dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| export const configurations = defineConfig([ | ||
| { | ||
| ignores: ['!**/*', '**/node_modules', '**/dist'], | ||
| }, | ||
| { | ||
| files: ['**/*.js'], | ||
| extends: [...javascriptNimbleConfig], | ||
| rules: { | ||
| // Use package.json from angular-workspace root | ||
| 'import/no-extraneous-dependencies': ['error', { packageDir }], | ||
| }, | ||
| }, | ||
| { | ||
| files: ['**/*.ts'], | ||
| extends: [...angularConfig, ...typescriptNimbleConfig], | ||
| rules: { | ||
| // Use package.json from angular-workspace root | ||
| 'import/no-extraneous-dependencies': ['error', { packageDir }], | ||
| 'no-restricted-imports': [ | ||
| 'error', | ||
| { | ||
| patterns: [ | ||
| { | ||
| group: ['@ni/fast-*'], | ||
| message: | ||
| 'Do not directly use underlying libraries of nimble. Instead rely on or add to exports of nimble packages.', | ||
| }, | ||
| { | ||
| group: [ | ||
| '@ni/*-components/**/tests', | ||
| '@ni/*-components/**/testing', | ||
| ], | ||
| message: 'Do not use test code/utilities in production code.', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
|
|
||
| // Nimble Angular Components follow web component naming conventions | ||
| // where the attribute and property names are different formats | ||
| '@angular-eslint/no-input-rename': 'off', | ||
| }, | ||
| }, | ||
| { | ||
| // Don't require class docs on modules (they're trivial) | ||
| files: ['**/*.module.ts'], | ||
| rules: { | ||
| 'jsdoc/require-jsdoc': 'off', | ||
| 'jsdoc/require-description': 'off', | ||
| }, | ||
| }, | ||
| { | ||
| files: ['**/*.spec.ts'], | ||
| rules: { | ||
| 'no-restricted-imports': [ | ||
| 'error', | ||
| { | ||
| patterns: [ | ||
| { | ||
| group: ['@ni/fast-*'], | ||
| message: | ||
| 'Do not directly use underlying libraries of nimble. Instead rely on or add to exports of nimble packages.', | ||
| }, | ||
| { | ||
| group: ['@ni/nimble-components', '@ni/spright-components'], | ||
| message: | ||
| 'Angular tests should not directly depend on web component packages.', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
|
|
||
| // Jasmine createSpyObj rely on accessing unbound methods | ||
| '@typescript-eslint/unbound-method': 'off', | ||
| }, | ||
| }, | ||
| { | ||
| files: ['**/testing/**'], | ||
| rules: { | ||
| 'no-restricted-imports': [ | ||
| 'error', | ||
| { | ||
| patterns: [ | ||
| { | ||
| group: ['@ni/fast-*'], | ||
| message: | ||
| 'Do not directly use underlying libraries of nimble. Instead rely on or add to exports of nimble packages.', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| { | ||
| files: ['**/*.html'], | ||
| extends: [...angularTemplateConfig], | ||
| rules: { | ||
| // Enable i18n template checking for the purpose of making sure to capture updates for the lint rules | ||
| '@angular-eslint/template/i18n': [ | ||
| 'error', | ||
| { | ||
| checkText: false, | ||
| checkId: false, | ||
| ignoreAttributes: [ | ||
| // Attributes that SHOULD NOT ever be localized need to be added to ignoreAttributeSets | ||
| // See: https://github.com/ni/javascript-styleguide/blob/main/packages/eslint-config-angular/template/options.js | ||
| ...ignoreAttributes.all, | ||
|
|
||
| // Attributes that SHOULD be localized in production, but we don't want to | ||
| // for tests / examples apps should be added to the following list: | ||
| 'action-menu-label', | ||
| 'aria-label', | ||
| 'button-label', | ||
| 'label', | ||
| 'placeholder', | ||
| 'text', | ||
| 'title', | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import configurations from './configurations.js'; | ||
| import { defineConfig } from 'eslint/config'; | ||
|
|
||
| export default defineConfig([ | ||
| configurations, | ||
| ]); |
35 changes: 0 additions & 35 deletions
35
packages/angular-workspace/example-client-app/.eslintrc.js
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
packages/angular-workspace/example-client-app/eslint.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { fileURLToPath } from 'url'; | ||
| import path from 'path'; | ||
| import { defineConfig } from 'eslint/config'; | ||
| // eslint-disable-next-line import/extensions | ||
| import { configurations } from '../configurations.js'; | ||
|
|
||
| const tsConfigRootDir = path.dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| export default defineConfig([ | ||
| configurations, | ||
| { | ||
| ignores: ['example-client-app/src/environments/**'], | ||
| }, | ||
| { | ||
| files: ['example-client-app/**/*.ts'], | ||
| languageOptions: { | ||
| parserOptions: { | ||
| project: ['example-client-app/tsconfig.app.json', 'example-client-app/tsconfig.spec.json'], | ||
| tsConfigRootDir, | ||
| }, | ||
| }, | ||
| rules: { | ||
| 'no-restricted-imports': [ | ||
| 'error', | ||
| { | ||
| patterns: [ | ||
| { | ||
| group: ['@ni/fast-*'], | ||
| message: | ||
| 'Do not directly use underlying libraries of nimble. Instead rely on or add to exports of nimble packages.', | ||
| }, | ||
| { | ||
| group: ['@ni/*-components'], | ||
| message: | ||
| 'Client Angular applications should not directly depend on web component packages.', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| '@angular-eslint/component-selector': [ | ||
| 'error', | ||
| { type: 'element', prefix: 'example', style: 'kebab-case' }, | ||
| ], | ||
| 'jsdoc/require-jsdoc': 'off', | ||
| 'jsdoc/require-description': 'off', | ||
| }, | ||
| }, | ||
| ]); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are too many changes in one shot. One thing to note is that packages do not need to migrate to
"type": "module"in order to adopt eslint v9. Those can be decoupled, see the discussion here: ni/javascript-styleguide#170 (comment)If the changes are minor outside the nimble repo then it may be fine but we should not switch the packages in nimble.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gokulprasanth-ni
the nimble repo is sufficiently unusual that we'll handle the upgrade, but thanks for the initial draftUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After sleeping on it, I think a plan to do the update in smaller parts would be:
lintandlint-concurrentscripts inpackage.jsonto not call prettier temporarily and only call eslint. Hopefully that minimizes the number of changes needed in the first PR.The goal being to not force nimble to switch to type module yet and to split prettier formatting changes to a separate standalone PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also incase it is a consideration, we should be updating the AzDo pipelines first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah thanks for the suggestion Milan. I will plan to create PRs as suggested.