Skip to content
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
33 changes: 6 additions & 27 deletions .github/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
// Keep in sync with .github/shared/eslint.config.js
import { defineBaseConfig } from "./shared/eslint.base.config.js";

import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
// we only run in node, not browser
globals: globals.node,
// required to use tseslint.configs.recommendedTypeChecked
parserOptions: {
projectService: true,
// ensures the tsconfig path resolves relative to this file
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: ["coverage/**", "shared/coverage/**"],
},
);
export default defineBaseConfig({
// ensures the tsconfig path resolves relative to this file (so cannot be defined in base file)
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
});
39 changes: 39 additions & 0 deletions .github/shared/eslint.base.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";

/**
* @param {object} options
* @param {boolean|object} [options.projectService]
* @param {string} options.tsconfigRootDir
* @returns {import('eslint').Linter.Config[]}
*/
export function defineBaseConfig(options) {
const { projectService = true, tsconfigRootDir } = options;

return defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
// we only run in node, not browser
globals: globals.node,
// required to use tseslint.configs.recommendedTypeChecked
parserOptions: {
// Defaults to "true", which is the minimum required to use tseslint.configs.recommendedTypeChecked
// Can be overridden by caller, by setting to a config object
projectService,
// Must be set by caller, since this should point to the root directory of the project being analyzed
tsconfigRootDir,
},
},
},
{
ignores: [
// generated by `vitest --coverage`
"coverage/**",
],
},
);
}
33 changes: 6 additions & 27 deletions .github/shared/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,7 @@
// Keep in sync with .github/eslint.config.js
import { defineBaseConfig } from "./eslint.base.config.js";

import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
// we only run in node, not browser
globals: globals.node,
// required to use tseslint.configs.recommendedTypeChecked
parserOptions: {
projectService: true,
// ensures the tsconfig path resolves relative to this file
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: ["coverage/**"],
},
);
export default defineBaseConfig({
// ensures the tsconfig path resolves relative to this file (so cannot be defined in base file)
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
});
1 change: 1 addition & 0 deletions .github/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "@azure-tools/specs-shared",
"private": "true",
Expand All @@ -7,6 +7,7 @@
"./breaking-change": "./src/breaking-change.js",
"./changed-files": "./src/changed-files.js",
"./error-reporting": "./src/error-reporting.js",
"./eslint-base-config": "./eslint.base.config.js",
"./exec": "./src/exec.js",
"./git": "./src/git.js",
"./github": "./src/github.js",
Expand Down
25 changes: 25 additions & 0 deletions eng/tools/eslint.base.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineBaseConfig as defineSharedBaseConfig } from "@azure-tools/specs-shared/eslint-base-config";
import { defineConfig } from "eslint/config";

/**
* @param {object} options
* @param {string} options.tsconfigRootDir
* @returns {import('eslint').Linter.Config[]}
*/
export function defineBaseConfig(options) {
return defineConfig(
defineSharedBaseConfig({
...options,
projectService: {
// include hand-written JS files (excluded from TS project)
allowDefaultProject: ["*.js", "cmd/*.js"],
},
}),
{
ignores: [
// generated by `tsc compile`
"dist/**",
],
},
);
}
35 changes: 6 additions & 29 deletions eng/tools/lint-diff/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
// Keep in sync with .github/shared/eslint.config.js
import { defineBaseConfig } from "../eslint.base.config.js";

import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
// we only run in node, not browser
globals: globals.node,
// required to use tseslint.configs.recommendedTypeChecked
parserOptions: {
projectService: {
allowDefaultProject: ["*.js", "cmd/*.js"],
},
// ensures the tsconfig path resolves relative to this file
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: ["coverage/**", "dist/**"],
},
);
export default defineBaseConfig({
// ensures the tsconfig path resolves relative to this file (so cannot be defined in base file)
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
});
35 changes: 6 additions & 29 deletions eng/tools/oav-runner/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
// Keep in sync with .github/shared/eslint.config.js
import { defineBaseConfig } from "../eslint.base.config.js";

import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
// we only run in node, not browser
globals: globals.node,
// required to use tseslint.configs.recommendedTypeChecked
parserOptions: {
projectService: {
allowDefaultProject: ["*.js", "cmd/*.js"],
},
// ensures the tsconfig path resolves relative to this file
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: ["coverage/**", "dist/**"],
},
);
export default defineBaseConfig({
// ensures the tsconfig path resolves relative to this file (so cannot be defined in base file)
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
});
5 changes: 3 additions & 2 deletions eng/tools/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "azure-rest-api-specs-eng-tools",
"private": true,
"type": "module",
"devDependencies": {
"@azure-tools/lint-diff": "file:lint-diff",
"@azure-tools/oav-runner": "file:oav-runner",
Expand All @@ -16,6 +18,5 @@
"scripts": {
"build": "tsc --build",
"postinstall": "npm run build"
},
"private": true
}
}
35 changes: 6 additions & 29 deletions eng/tools/suppressions/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
// Keep in sync with .github/shared/eslint.config.js
import { defineBaseConfig } from "../eslint.base.config.js";

import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
// we only run in node, not browser
globals: globals.node,
// required to use tseslint.configs.recommendedTypeChecked
parserOptions: {
projectService: {
allowDefaultProject: ["*.js", "cmd/*.js"],
},
// ensures the tsconfig path resolves relative to this file
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: ["coverage/**", "dist/**"],
},
);
export default defineBaseConfig({
// ensures the tsconfig path resolves relative to this file (so cannot be defined in base file)
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
});
1 change: 1 addition & 0 deletions eng/tools/suppressions/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "@azure-tools/suppressions",
"private": true,
Expand Down Expand Up @@ -25,6 +25,7 @@
"zod": "^4.1.11"
},
"devDependencies": {
"@azure-tools/specs-shared": "file:../../../.github/shared",
"@eslint/js": "^9.22.0",
"@types/node": "^20.0.0",
"@vitest/coverage-v8": "^3.1.2",
Expand Down
35 changes: 6 additions & 29 deletions eng/tools/typespec-validation/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
// Keep in sync with .github/shared/eslint.config.js
import { defineBaseConfig } from "../eslint.base.config.js";

import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default defineConfig(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
// we only run in node, not browser
globals: globals.node,
// required to use tseslint.configs.recommendedTypeChecked
parserOptions: {
projectService: {
allowDefaultProject: ["*.js", "cmd/*.js"],
},
// ensures the tsconfig path resolves relative to this file
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: ["coverage/**", "dist/**"],
},
);
export default defineBaseConfig({
// ensures the tsconfig path resolves relative to this file (so cannot be defined in base file)
// default is process.cwd() when running eslint, which may be incorrect
tsconfigRootDir: import.meta.dirname,
});
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading