Skip to content

Commit

Permalink
ci fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Feb 22, 2023
1 parent a635863 commit 3da9ffd
Show file tree
Hide file tree
Showing 28 changed files with 60 additions and 89 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ jobs:
'eslint-plugin-internal',
'eslint-plugin-tslint',
'parser',
'repo-tools',
'scope-manager',
'type-utils',
'typescript-estree',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
({ prop: 'string' } satisfies { prop: string });
({ prop: 'string' }) satisfies { prop: string };
Original file line number Diff line number Diff line change
@@ -1 +1 @@
({ prop: 'string' } satisfies { prop: string });
({ prop: 'string' }) satisfies { prop: string };
6 changes: 1 addition & 5 deletions packages/eslint-plugin-tslint/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"rootDir": "."
},
"include": ["src", "tests"],
"exclude": [
"tests/fixture-project",
"tests/test-project",
"tests/test-tslint-rules-directory"
],
"exclude": ["tests/fixtures"],
"references": [{ "path": "../utils/tsconfig.build.json" }]
}
2 changes: 1 addition & 1 deletion packages/eslint-plugin/docs/rules/no-base-to-string.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ value + '';

// Interpolation and manual .toString() calls too:
`Value: ${value}`;
({}.toString());
({}).toString();
```

### ✅ Correct
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"clean": "tsc -b tsconfig.build.json --clean",
"postclean": "rimraf dist && rimraf coverage",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"generate:breaking-changes": "yarn tsx tools/generate-breaking-changes.ts",
"generate:breaking-changes": "yarn tsx tools/generate-breaking-changes.mts",
"generate:configs": "yarn tsx tools/generate-configs.ts",
"lint": "nx lint",
"test": "jest --coverage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const keywordNodeTypesToTsTypes = new Map([
[TSESTree.AST_NODE_TYPES.TSStringKeyword, ts.TypeFlags.String],
]);

type PrimitiveTypeFlag = typeof primitiveTypeFlags[number];
type PrimitiveTypeFlag = (typeof primitiveTypeFlags)[number];

interface TypeFlagsWithName {
typeFlags: ts.TypeFlags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ export default util.createRule<Options, MessageIds>({
function getPaddingType(
prevNode: TSESTree.Node,
nextNode: TSESTree.Node,
): typeof PaddingTypes[keyof typeof PaddingTypes] {
): (typeof PaddingTypes)[keyof typeof PaddingTypes] {
for (let i = configureList.length - 1; i >= 0; --i) {
const configure = configureList[i];
if (
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/tests/configs.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RuleRecommendation } from '@typescript-eslint/utils/src/ts-eslint';
import type { RuleRecommendation } from '@typescript-eslint/utils/ts-eslint';

import plugin from '../src/index';
import rules from '../src/rules';
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/tests/fixtures/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"include": [
"file.ts",
"consistent-type-exports.ts",
"mixed-enums-decl.ts",
"react.tsx"
]
}
18 changes: 9 additions & 9 deletions packages/eslint-plugin/tests/rules/no-mixed-enums.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,19 @@ enum Foo {
}
`,
`
import { AST_NODE_TYPES } from '@typescript-eslint/types';
import { Enum } from './mixed-enums-decl';
declare module '@typescript-eslint/types' {
enum AST_NODE_TYPES {
declare module './mixed-enums-decl' {
enum Enum {
StringLike = 'StringLike',
}
}
`,
`
import { TSESTree } from '@typescript-eslint/types';
import { Enum } from "module-that-does't-exist";
declare module '@typescript-eslint/types' {
enum TSESTree {
declare module "module-that-doesn't-exist" {
enum Enum {
StringLike = 'StringLike',
}
}
Expand Down Expand Up @@ -552,10 +552,10 @@ namespace Different {
},
{
code: `
import { AST_NODE_TYPES } from '@typescript-eslint/types';
import { Enum } from './mixed-enums-decl';
declare module '@typescript-eslint/types' {
enum AST_NODE_TYPES {
declare module './mixed-enums-decl' {
enum Enum {
Numeric = 0,
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import type { TypeScriptESLintRules } from '@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules';
import { fetch } from 'cross-fetch';
// markdown-table is ESM, hence this file needs to be `.mts`
import { markdownTable } from 'markdown-table';

import type RulesFile from '../src/rules';

interface RulesObject {
default: {
default: typeof RulesFile;
};
}

async function main(): Promise<void> {
const {
default: { default: rules },
} =
// @ts-expect-error -- We don't support ESM imports of local code yet.
(await import('../dist/rules/index.js')) as RulesObject;
const rulesImport = await import('../src/rules/index.js');
/*
weird TS resolution which adds an additional default layer in the type like:
{ default: { default: Rules }}
instead of just
{ default: Rules }
@ts-expect-error */
const rules = rulesImport.default as TypeScriptESLintRules;

// Annotate which rules are new since the last version
async function getNewRulesAsOfMajorVersion(
Expand All @@ -33,7 +30,7 @@ async function main(): Promise<void> {
// Normally we wouldn't condone using the 'eval' API...
// But this is an internal-only script and it's the easiest way to convert
// the JS raw text into a runtime object. 🤷
let oldRulesObject!: { rules: typeof RulesFile };
let oldRulesObject!: { rules: TypeScriptESLintRules };
eval('oldRulesObject = ' + oldObjectText);
const oldRuleNames = new Set(Object.keys(oldRulesObject.rules));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var obj = { value: 1 };
var obj2: typeof obj = { value: 2 };
var { value }: typeof obj = { value: 2 };
var [element]: typeof obj[] = [{ value: 2 }];
var [element]: (typeof obj)[] = [{ value: 2 }];
1 change: 1 addition & 0 deletions packages/repo-tools/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
module.exports = {
...require('../../jest.config.base.js'),
coveragePathIgnorePatterns: ['src/index.ts$', 'src/configs/.*.ts$'],
passWithNoTests: true,
};
2 changes: 1 addition & 1 deletion packages/scope-manager/tests/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ALLOWED_OPTIONS: Map<string, ALLOWED_VALUE> = new Map<
]);

function nestDescribe(
fixture: typeof fixtures[number],
fixture: (typeof fixtures)[number],
segments = fixture.segments,
): void {
if (segments.length > 0) {
Expand Down
8 changes: 4 additions & 4 deletions packages/visitor-keys/src/visitor-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ type KeysDefinedInESLintVisitorKeysCore =

// strictly type the arrays of keys provided to make sure we keep this config in sync with the type defs
type AdditionalKeys = {
readonly // require keys for all nodes NOT defined in `eslint-visitor-keys`
[T in Exclude<
// require keys for all nodes NOT defined in `eslint-visitor-keys`
readonly [T in Exclude<
AST_NODE_TYPES,
KeysDefinedInESLintVisitorKeysCore
>]: readonly GetNodeTypeKeys<T>[];
} & {
readonly // optionally allow keys for all nodes defined in `eslint-visitor-keys`
[T in KeysDefinedInESLintVisitorKeysCore]?: readonly GetNodeTypeKeys<T>[];
// optionally allow keys for all nodes defined in `eslint-visitor-keys`
readonly [T in KeysDefinedInESLintVisitorKeysCore]?: readonly GetNodeTypeKeys<T>[];
};

/**
Expand Down
18 changes: 0 additions & 18 deletions packages/website-eslint/jsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/website-eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build": "rollup --config=rollup.config.js",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "nx lint",
"typecheck": "tsc -p jsconfig.json --noEmit"
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@typescript-eslint/types": "5.53.0",
Expand Down
1 change: 0 additions & 1 deletion packages/website-eslint/src/mock/empty.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// eslint-disable-next-line import/no-default-export
export default {};
1 change: 0 additions & 1 deletion packages/website-eslint/src/mock/is-glob.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-default-export
export default function isGlob() {
// the website config is static and doesn't use glob config
return false;
Expand Down
1 change: 0 additions & 1 deletion packages/website-eslint/src/mock/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ export function extname(path) {
return splitPath(path)[3];
}

// eslint-disable-next-line import/no-default-export
export default {
extname: extname,
basename: basename,
Expand Down
1 change: 0 additions & 1 deletion packages/website-eslint/src/mock/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import satisfies from 'semver/functions/satisfies';
// just in case someone adds a import * as semver usage
export { satisfies, major };

// eslint-disable-next-line import/no-default-export
export default { satisfies, major };
1 change: 0 additions & 1 deletion packages/website-eslint/src/mock/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ util.inspect = function (value) {
return value;
};

// eslint-disable-next-line import/no-default-export
export default util;
7 changes: 0 additions & 7 deletions packages/website-eslint/typings/eslint.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/website/plugins/generated-rule-docs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as eslintPlugin from '@typescript-eslint/eslint-plugin';
import pluginRules from '@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules';
import * as tseslintParser from '@typescript-eslint/parser';
import * as fs from 'fs';
import type { JSONSchema7 } from 'json-schema';
Expand Down Expand Up @@ -40,7 +40,7 @@ export const generatedRuleDocs: Plugin = () => {
return;
}

const rule = eslintPlugin.rules[file.stem];
const rule = pluginRules[file.stem];
const meta = rule?.meta;
if (!meta?.docs) {
return;
Expand Down
22 changes: 10 additions & 12 deletions packages/website/rulesMeta.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as eslintPlugin from '@typescript-eslint/eslint-plugin';
import rules from '@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules';

export const rulesMeta = Object.entries(eslintPlugin.rules).map(
([name, content]) => ({
name,
type: content.meta.type,
docs: content.meta.docs,
fixable: content.meta.fixable,
hasSuggestions: content.meta.hasSuggestions,
deprecated: content.meta.deprecated,
replacedBy: content.meta.replacedBy,
}),
);
export const rulesMeta = Object.entries(rules).map(([name, content]) => ({
name,
type: content.meta.type,
docs: content.meta.docs,
fixable: content.meta.fixable,
hasSuggestions: content.meta.hasSuggestions,
deprecated: content.meta.deprecated,
replacedBy: content.meta.replacedBy,
}));

export type RulesMeta = typeof rulesMeta;
2 changes: 1 addition & 1 deletion packages/website/src/components/RulesTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function RuleRow({ rule }: { rule: RulesMeta[number] }): JSX.Element | null {
}

const filterModes = ['neutral', 'include', 'exclude'] as const;
type FilterMode = typeof filterModes[number];
type FilterMode = (typeof filterModes)[number];

function RuleFilterCheckBox({
label,
Expand Down
11 changes: 9 additions & 2 deletions packages/website/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ test.describe('Website', () => {
test('should have no errors', async ({ page }) => {
const errorMessages: string[] = [];
page.on('console', msg => {
if (['error', 'warning'].includes(msg.type())) {
errorMessages.push(`[${msg.type()}] ${msg.text()}`);
const type = msg.type();
if (!['error', 'warning'].includes(type)) {
return;
}
const text = msg.text();
// this log is fine because the ReactDOM usage is controlled by docusaurus, not us
if (text.includes('ReactDOM.render is no longer supported in React 18')) {
return;
}
errorMessages.push(`[${type}] ${text}`);
});
await page.goto('/');
expect(errorMessages).toStrictEqual([]);
Expand Down

0 comments on commit 3da9ffd

Please sign in to comment.