Skip to content
Open
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
117 changes: 0 additions & 117 deletions .eslintrc

This file was deleted.

File renamed without changes.
3 changes: 3 additions & 0 deletions docs/reference/asyncapi-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ info:
title: Descriptive API
description: >+
Some description about the general point of this API, and why it exists when another similar but different API also exists.

```

### asyncapi-info-license-url
Expand Down Expand Up @@ -580,6 +581,7 @@ tags:
- name: Invoice Items
description: |+
Giant long explanation about what this business concept is, because other people _might_ not have a clue!

```

**Recommended:** No
Expand Down Expand Up @@ -792,6 +794,7 @@ info:
- name: Invoice Items
description: |+
Giant long explanation about what this business concept is, because other people _might_ not have a clue!

```

**Recommended:** No
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/openapi-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ info:
title: Descriptive API
description: >+
Some description about the general point of this API, and why it exists when another similar but different API also exists.## AuthenticationThis API uses OAuth2 and tokens can be requested from [Dev Portal: Tokens](https://example.org/developers/tokens).

```

### info-license
Expand Down Expand Up @@ -406,6 +407,7 @@ tags:
- name: Invoice Items
description: |+
Giant long explanation about what this business concept is, because other people _might_ not have a clue!

```

**Recommended:** No
Expand Down
114 changes: 114 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-plugin-prettier/recommended';
import importPlugin from 'eslint-plugin-import-x';
import globals from 'globals';
import { fileURLToPath } from 'node:url';

export default tseslint.config(
// Global ignores (replaces .eslintignore)
{
ignores: [
'**/__fixtures__/**',
'test-harness/tests/**',
'packages/*/dist/**',
'packages/rulesets/src/oas/schemas/validators.ts',
'packages/rulesets/src/arazzo/schemas/validators.ts',
'packages/*/CHANGELOG.md',
'packages/formatters/src/html/templates.ts',
],
},

// Base for all linted files
{
files: ['packages/**/*.{js,mjs,ts}', 'test-harness/**/*.{js,mjs,ts}'],
extends: [tseslint.configs.recommended, prettierConfig],
languageOptions: {
globals: { ...globals.es2015, ...globals.browser, ...globals.node },
},
rules: {
'no-console': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
args: 'after-used',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/explicit-function-return-type': 'warn',
},
},

// TypeScript source files with type-checking
{
files: ['packages/*/src/**/*.ts'],
extends: [tseslint.configs.eslintRecommended, tseslint.configs.recommendedTypeChecked],
plugins: { import: importPlugin },
languageOptions: {
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: fileURLToPath(new URL('.', import.meta.url)),
},
},
rules: {
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
'@typescript-eslint/strict-boolean-expressions': 'warn',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/no-unsafe-argument': 'warn',
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: ['**/*.{test,spec}.ts', '**/__tests__/__helpers__/*.ts'] },
],
},
},

// CLI package: downgrade no-console to warn
{
files: ['packages/cli/src/**/*.ts'],
rules: { 'no-console': 'warn' },
},

// Test files: relax strict rules
{
files: ['packages/*/src/**/__tests__/**/*.ts', 'test-harness/**/*.{ts,js}'],
rules: {
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
},
},

// Jest test files: jest + node globals
{
files: ['**/__tests__/**/*.jest.test.{ts,js}', '__mocks__/**/*.{ts,js}'],
languageOptions: { globals: { ...globals.jest, ...globals.node } },
},

// Karma test files: browser + jasmine globals
{
files: ['**/__tests__/**/*.karma.test.{ts,js}'],
languageOptions: { globals: { ...globals.browser, ...globals.jasmine } },
},

// Scripts and test-harness: node globals
{
files: ['scripts/**/*.{mjs,ts}', 'test-harness/**/*.{ts,js}'],
languageOptions: { globals: { ...globals.node } },
},
);
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"prelint": "yarn workspaces foreach run prelint",
"lint": "yarn prelint && yarn lint.prettier && yarn lint.eslint",
"lint.fix": "yarn lint.prettier --write && yarn lint.eslint --fix",
"lint.eslint": "eslint --cache --cache-location .cache/.eslintcache --ext=.js,.mjs,.ts packages test-harness",
"lint.prettier": "prettier --ignore-path .eslintignore --ignore-unknown --check packages/core/src/ruleset/meta/*.json packages/rulesets/src/{asyncapi,oas,arazzo}/schemas/**/*.json docs/**/*.md README.md",
"lint.eslint": "eslint --cache --cache-location .cache/.eslintcache packages test-harness",
"lint.prettier": "prettier --ignore-path .prettierignore --ignore-unknown --check packages/core/src/ruleset/meta/*.json packages/rulesets/src/{asyncapi,oas,arazzo}/schemas/**/*.json docs/**/*.md README.md",
"pretest": "yarn workspaces foreach run pretest",
"test": "yarn pretest && yarn test.karma && yarn test.jest",
"pretest.harness": "ts-node -T test-harness/scripts/generate-tests.ts",
Expand Down Expand Up @@ -108,16 +108,17 @@
"@types/node-fetch": "^2.5.12",
"@types/node-powershell": "^3.1.1",
"@types/text-table": "^0.2.2",
"@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.34.0",
"eslint": "^8.22.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^10.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import-x": "^4.0.0",
"eslint-plugin-prettier": "^5.0.0",
"expect": "^27.5.1",
"fast-glob": "^3.3.3",
"fetch-mock": "^12.6.0",
"file-entry-cache": "^6.0.1",
"globals": "^16.0.0",
"husky": "^7.0.4",
"jest": "^29.7.0",
"jest-mock": "^29.7.0",
Expand All @@ -131,27 +132,28 @@
"multi-semantic-release": "^3.1.0",
"node-powershell": "^4.0.0",
"patch-package": "^8.0.0",
"prettier": "^2.4.1",
"prettier": "^3.0.0",
"semantic-release": "^25.0.3",
"ts-jest": "^29.2.5",
"ts-node": "^10.8.2",
"typescript": "4.7.4"
"typescript": "4.7.4",
"typescript-eslint": "^8.0.0"
},
"lint-staged": {
"*.{ts,js}": [
"eslint --fix --cache --cache-location .cache/.eslintcache"
],
"docs/**/*.md": [
"prettier --ignore-path .eslintignore --write"
"prettier --ignore-path .prettierignore --write"
],
"README.md": [
"prettier --write"
],
"packages/core/src/ruleset/meta/*.json": [
"prettier --ignore-path .eslintignore --write"
"prettier --ignore-path .prettierignore --write"
],
"packages/rulesets/src/{asyncapi,oas,arazzo}/schemas/**/*.json": [
"prettier --ignore-path .eslintignore --write"
"prettier --ignore-path .prettierignore --write"
]
},
"packageManager": "yarn@3.5.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DiagnosticSeverity, Dictionary } from '@stoplight/types';
import { isPlainObject } from '@stoplight/json';
import { getDiagnosticSeverity, IRuleResult } from '@stoplight/spectral-core';
import { difference, isError, pick } from 'lodash';
import type { ReadStream } from 'tty';
import type { CommandModule } from 'yargs';
import * as process from 'process';
import chalk from 'chalk';
Expand Down Expand Up @@ -38,7 +37,7 @@ const lintCommand: CommandModule = {
return [];
}

return [(process.stdin as ReadStream & { fd: 0 }).fd];
return [process.stdin.fd];
},
})
.middleware((argv: Dictionary<unknown>) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DEFAULT_REQUEST_OPTIONS } from '@stoplight/spectral-runtime';
import lintCommand from './commands/lint';

if (typeof process.env.PROXY === 'string') {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent') as typeof import('hpagent');
const httpAgent = new HttpProxyAgent({ proxy: process.env.PROXY });
const httpsAgent = new HttpsProxyAgent({ proxy: process.env.PROXY });
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/services/linter/utils/getResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CLIError } from '../../../errors';
export const getResolver = (resolver: Optional<string>): Resolver => {
if (resolver !== void 0) {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-return
return require(isAbsolute(resolver) ? resolver : join(process.cwd(), resolver));
} catch (ex) {
throw new CLIError(isError(ex) ? formatMessage(ex.message) : String(ex));
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/services/linter/utils/getRuleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function load(source: string, uri: string): RulesetDefinition {

const _require = (id: string): unknown => req(req.resolve(id, { paths }));

// eslint-disable-next-line @typescript-eslint/no-implied-eval
// eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-call
Function('module, require', source)(m, _require);

if (!isObject(m.exports)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export async function readFileDescriptor(fd: number, opts: IFileReadOptions): Pr
stream.setEncoding(opts.encoding);

stream.on('readable', () => {
let chunk: unknown;
let chunk: string;

while ((chunk = stream.read()) !== null) {
while ((chunk = stream.read() as string) !== null) {
result += chunk;
}
});
Expand Down
Loading
Loading