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
180 changes: 5 additions & 175 deletions apps/oxlint/conformance/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
| Status | Count | % |
| ----------- | ----- | ------ |
| Total tests | 33090 | 100.0% |
| Passing | 32699 | 98.8% |
| Failing | 284 | 0.9% |
| Passing | 32703 | 98.8% |
| Failing | 280 | 0.8% |
| Skipped | 107 | 0.3% |

## Fully Passing Rules
Expand Down Expand Up @@ -317,7 +317,7 @@
- `prefer-regex-literals` - 249 / 251 (99.2%)
- `radix` - 53 / 54 (98.1%)
- `semi` - 307 / 308 (99.7%)
- `strict` - 106 / 126 (84.1%)
- `strict` - 110 / 126 (87.3%)
- `unicode-bom` - 4 / 7 (57.1%)

## Rules with Failures Detail
Expand Down Expand Up @@ -14073,8 +14073,8 @@ AssertionError [ERR_ASSERTION]: Should have 2 errors but had 1: [

### `strict`

Pass: 106 / 126 (84.1%)
Fail: 20 / 126 (15.9%)
Pass: 110 / 126 (87.3%)
Fail: 16 / 126 (12.7%)
Skip: 0 / 126 (0.0%)

#### strict > valid
Expand Down Expand Up @@ -14359,107 +14359,6 @@ AssertionError [ERR_ASSERTION]: Should have no errors but had 1: [
at apps/oxlint/dist/index.js


#### strict > valid

```js
'use strict'; module.exports = function identity (value) { return value; }
```

```json
{
"languageOptions": {
"sourceType": "commonjs"
}
}
```

AssertionError [ERR_ASSERTION]: Should have no errors but had 2: [
{
ruleId: 'rule-to-test/strict',
message: "Use the function form of 'use strict'.",
messageId: 'function',
severity: 1,
nodeType: 'Literal',
line: 1,
column: 0,
endLine: 1,
endColumn: 13,
suggestions: null
},
{
ruleId: 'rule-to-test/strict',
message: "Use the function form of 'use strict'.",
messageId: 'function',
severity: 1,
nodeType: 'FunctionExpression',
line: 1,
column: 31,
endLine: 1,
endColumn: 74,
suggestions: null
}
]

2 !== 0

at assertErrorCountIsCorrect (apps/oxlint/dist/index.js)
at assertValidTestCasePasses (apps/oxlint/dist/index.js)
at runValidTestCase (apps/oxlint/dist/index.js)
at apps/oxlint/dist/index.js


#### strict > valid

```js
'use strict'; module.exports = function identity (value) { return value; }
```

```json
{
"options": [
"safe"
],
"languageOptions": {
"sourceType": "commonjs"
}
}
```

AssertionError [ERR_ASSERTION]: Should have no errors but had 2: [
{
ruleId: 'rule-to-test/strict',
message: "Use the function form of 'use strict'.",
messageId: 'function',
severity: 1,
nodeType: 'Literal',
line: 1,
column: 0,
endLine: 1,
endColumn: 13,
suggestions: null
},
{
ruleId: 'rule-to-test/strict',
message: "Use the function form of 'use strict'.",
messageId: 'function',
severity: 1,
nodeType: 'FunctionExpression',
line: 1,
column: 31,
endLine: 1,
endColumn: 74,
suggestions: null
}
]

2 !== 0

at assertErrorCountIsCorrect (apps/oxlint/dist/index.js)
at assertValidTestCasePasses (apps/oxlint/dist/index.js)
at runValidTestCase (apps/oxlint/dist/index.js)
at apps/oxlint/dist/index.js


#### strict > invalid

```js
Expand Down Expand Up @@ -14939,75 +14838,6 @@ AssertionError [ERR_ASSERTION]: messageId 'unnecessaryInClasses' does not match
at apps/oxlint/dist/index.js


#### strict > invalid

```js
module.exports = function identity (value) { return value; }
```

```json
{
"output": null,
"options": [
"safe"
],
"languageOptions": {
"sourceType": "commonjs"
},
"errors": [
{
"messageId": "global",
"line": 1
}
]
}
```

AssertionError [ERR_ASSERTION]: messageId 'function' does not match expected messageId 'global'
+ actual - expected

+ 'function'
- 'global'

at assertInvalidTestCaseMessageIsCorrect (apps/oxlint/dist/index.js)
at assertInvalidTestCasePasses (apps/oxlint/dist/index.js)
at runInvalidTestCase (apps/oxlint/dist/index.js)
at apps/oxlint/dist/index.js


#### strict > invalid

```js
module.exports = function identity (value) { return value; }
```

```json
{
"output": null,
"languageOptions": {
"sourceType": "commonjs"
},
"errors": [
{
"messageId": "global",
"line": 1
}
]
}
```

AssertionError [ERR_ASSERTION]: messageId 'function' does not match expected messageId 'global'
+ actual - expected

+ 'function'
- 'global'

at assertInvalidTestCaseMessageIsCorrect (apps/oxlint/dist/index.js)
at assertInvalidTestCasePasses (apps/oxlint/dist/index.js)
at runInvalidTestCase (apps/oxlint/dist/index.js)
at apps/oxlint/dist/index.js


### `unicode-bom`

Pass: 4 / 7 (57.1%)
Expand Down
3 changes: 1 addition & 2 deletions apps/oxlint/conformance/src/rule_tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ class RuleTesterShim extends RuleTester {

function modifyTestCase(test: TestCase): void {
// Enable ESLint compat mode.
// This makes `RuleTester` adjust column indexes in diagnostics to match ESLint's behavior,
// and enables `sourceType: "commonjs"`.
// This makes `RuleTester` adjust column indexes in diagnostics to match ESLint's behavior.
test.eslintCompat = true;

// Ignore parsing errors. ESLint's test cases include invalid code.
Expand Down
33 changes: 9 additions & 24 deletions apps/oxlint/src-js/package/rule_tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ interface LanguageOptionsInternal extends LanguageOptions {
/**
* Source type.
*
* - `'unambiguous'` is not supported in ESLint compatibility mode.
* - `'commonjs'` is only supported in ESLint compatibility mode.
* `'unambiguous'` is not supported in ESLint compatibility mode.
*/
type SourceType = "script" | "module" | "unambiguous" | "commonjs";
type SourceType = "script" | "module" | "commonjs" | "unambiguous";

/**
* Value of a property in `globals` object.
Expand Down Expand Up @@ -1037,28 +1036,14 @@ function getParseOptions(test: TestCase): ParseOptions {
if (languageOptions.parser != null) throw new Error("Custom parsers are not supported");

// Handle `languageOptions.sourceType`
let { sourceType } = languageOptions;
const { sourceType } = languageOptions;
if (sourceType != null) {
if (test.eslintCompat === true) {
// ESLint compatibility mode.
// `unambiguous` is disallowed. Treat `commonjs` as `script`.
if (sourceType === "commonjs") {
sourceType = "script";
} else if (sourceType === "unambiguous") {
throw new Error(
"'unambiguous' source type is not supported in ESLint compatibility mode.\n" +
"Disable ESLint compatibility mode by setting `eslintCompat` to `false` in the config / test case.",
);
}
} else {
// Not ESLint compatibility mode.
// `commonjs` is disallowed.
if (sourceType === "commonjs") {
throw new Error(
"'commonjs' source type is only supported in ESLint compatibility mode.\n" +
"Enable ESLint compatibility mode by setting `eslintCompat` to `true` in the config / test case.",
);
}
// `unambiguous` is disallowed in ESLint compatibility mode
if (test.eslintCompat === true && sourceType === "unambiguous") {
throw new Error(
"'unambiguous' source type is not supported in ESLint compatibility mode.\n" +
"Disable ESLint compatibility mode by setting `eslintCompat` to `false` in the config / test case.",
);
}

parseOptions.sourceType = sourceType;
Expand Down
Loading
Loading