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

#1164 - migrate to eslint 9 #1241

Merged
merged 1 commit into from
Aug 29, 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
137 changes: 0 additions & 137 deletions .eslintrc.json

This file was deleted.

37 changes: 37 additions & 0 deletions .eslntrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"root": true,
"plugins": [
"@typescript-eslint",
"vitest",
"prettier"
],
"extends": [
"plugin:github/recommended",
"plugin:vitest/legacy-recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.eslint.json"
},
"rules": {
"eslint-comments/no-use": "off",
"github/no-then": "off",
"import/no-namespace": "off",
"import/no-commonjs": "off",
"import/named": "off",
"import/no-unresolved": "off",
},
"ignorePatterns": [
"packages/glob/__tests__/_temp/**/",
"gitversion/**/",
"gitreleasemanager/**/",
"dist/"
],
"env": {
"node": true,
"es6": true
}
}
2 changes: 1 addition & 1 deletion dist/azure/updateTasks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const updateJsonFields = async (filePath, versionStr, mode) => {

// Update the fields
for (let key in updates) {
if (data.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
data[key] = updates[key]
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/tools/azure/agent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Command {
if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += " ";
for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(this.properties, key)) {
const val = this.properties[key];
if (val) {
cmdStr += `${key}=${escapeProperty(`${val || ""}`)};`;
Expand Down
129 changes: 129 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// @ts-check

import eslint from '@eslint/js'
import eslintTs from 'typescript-eslint'
import stylistic from '@stylistic/eslint-plugin'
import vitest from '@vitest/eslint-plugin'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginPrettier from 'eslint-plugin-prettier/recommended'

export default eslintTs.config(
eslint.configs.recommended,
...eslintTs.configs.recommendedTypeChecked,
{
files: ['src/**/*.ts']
},
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
project: ['./tsconfig.json', './tsconfig.eslint.json'],
tsconfigRootDir: import.meta.dirname
}
},
plugins: {
'@stylistic': stylistic,
vitest
}
},
{
rules: {
...vitest.configs.recommended.rules,
'no-constant-condition': [
'error',
{
checkLoops: false
}
],

'no-shadow': 'off',
'no-console': 'off',
'no-sequences': 'off',
'no-undef': 'off',

'@stylistic/semi': ['error', 'never'],
'@stylistic/type-annotation-spacing': 'error',
'@stylistic/function-call-spacing': ['error', 'never'],

'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'no-public'
}
],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true
}
],
'@typescript-eslint/naming-convention': [
'error',
{
format: null,
filter: {
// you can expand this regex as you find more cases that require quoting that you want to allow
regex: '^[A-Z][A-Za-z]*$',
match: true
},
selector: 'memberLike'
}
],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/unbound-method': 'error',

'vitest/expect-expect': [
'error',
{
assertFunctionNames: ['expect', 'expectValidSettings']
}
]
}
},
eslintPluginPrettier,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
eslintConfigPrettier,
{
rules: {
'prettier/prettier': [
'error',
{
endOfLine: 'auto'
}
]
}
}
)
Loading