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
334 changes: 5 additions & 329 deletions apps/oxlint/conformance/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
| Status | Count | % |
| ----------------- | ----- | ------ |
| Total rules | 277 | 100.0% |
| Fully passing | 218 | 78.7% |
| Fully passing | 219 | 79.1% |
| Partially passing | 58 | 20.9% |
| Fully failing | 1 | 0.4% |
| Fully failing | 0 | 0.0% |
| Load errors | 0 | 0.0% |
| No tests run | 0 | 0.0% |

Expand All @@ -18,8 +18,8 @@
| Status | Count | % |
| ----------- | ----- | ------ |
| Total tests | 29765 | 100.0% |
| Passing | 28673 | 96.3% |
| Failing | 985 | 3.3% |
| Passing | 28684 | 96.4% |
| Failing | 974 | 3.3% |
| Skipped | 107 | 0.4% |

## Fully Passing Rules
Expand Down Expand Up @@ -172,6 +172,7 @@
- `no-sequences` (42 tests)
- `no-spaced-func` (28 tests)
- `no-sparse-arrays` (6 tests)
- `no-tabs` (11 tests)
- `no-template-curly-in-string` (22 tests)
- `no-ternary` (4 tests)
- `no-throw-literal` (41 tests)
Expand Down Expand Up @@ -282,7 +283,6 @@
- `no-shadow-restricted-names` - 43 / 44 (97.7%)
- `no-shadow` - 300 / 308 (97.4%)
- `no-sync` - 8 / 10 (80.0%)
- `no-tabs` - 0 / 11 (0.0%)
- `no-trailing-spaces` - 53 / 54 (98.1%)
- `no-undef` - 54 / 94 (57.4%)
- `no-undefined` - 37 / 53 (69.8%)
Expand Down Expand Up @@ -81432,330 +81432,6 @@ AssertionError [ERR_ASSERTION]: Should have 1 error but had 0: []
at apps/oxlint/dist/index.js


### `no-tabs`

Pass: 0 / 11 (0.0%)
Fail: 11 / 11 (100.0%)
Skip: 0 / 11 (0.0%)

#### no-tabs > valid

```js
function test(){
}
```

```json
{}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > valid

```js
function test(){
// sdfdsf
}
```

```json
{}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > valid

```js
doSomething();
```

```json
{
"options": [
{
"allowIndentationTabs": true
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > valid

```js
// comment
```

```json
{
"options": [
{
"allowIndentationTabs": true
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > invalid

```js
function test(){ }
```

```json
{
"errors": [
{
"messageId": "unexpectedTab",
"line": 1,
"column": 17,
"endLine": 1,
"endColumn": 18
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > invalid

```js
/** comment test */
```

```json
{
"errors": [
{
"messageId": "unexpectedTab",
"line": 1,
"column": 5,
"endLine": 1,
"endColumn": 6
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > invalid

```js
function test(){
// sdfdsf
}
```

```json
{
"errors": [
{
"messageId": "unexpectedTab",
"line": 2,
"column": 5,
"endLine": 2,
"endColumn": 6
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > invalid

```js
function test(){
//sdfdsf
}
```

```json
{
"errors": [
{
"messageId": "unexpectedTab",
"line": 1,
"column": 9,
"endLine": 1,
"endColumn": 10
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > invalid

```js
function test(){
// sdfdsf
}
```

```json
{
"errors": [
{
"messageId": "unexpectedTab",
"line": 2,
"column": 5,
"endLine": 2,
"endColumn": 6
},
{
"messageId": "unexpectedTab",
"line": 3,
"column": 1,
"endLine": 3,
"endColumn": 2
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > invalid

```js
// Comment with leading tab and inline tab
```

```json
{
"options": [
{
"allowIndentationTabs": true
}
],
"errors": [
{
"messageId": "unexpectedTab",
"line": 1,
"column": 30,
"endLine": 1,
"endColumn": 31
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


#### no-tabs > invalid

```js
a = b + c ;
```

```json
{
"errors": [
{
"messageId": "unexpectedTab",
"line": 1,
"column": 1,
"endLine": 1,
"endColumn": 3
},
{
"messageId": "unexpectedTab",
"line": 1,
"column": 6,
"endLine": 1,
"endColumn": 9
},
{
"messageId": "unexpectedTab",
"line": 1,
"column": 12,
"endLine": 1,
"endColumn": 13
},
{
"messageId": "unexpectedTab",
"line": 1,
"column": 14,
"endLine": 1,
"endColumn": 16
},
{
"messageId": "unexpectedTab",
"line": 1,
"column": 17,
"endLine": 1,
"endColumn": 19
}
]
}
```

TypeError: sourceCode.getLines is not a function
at Program (apps/oxlint/conformance/submodules/eslint/lib/rules/no-tabs.js:78:16)
at walkProgram (apps/oxlint/dist/lint.js)
at lintFileImpl (apps/oxlint/dist/lint.js)
at lint (apps/oxlint/dist/index.js)


### `no-trailing-spaces`

Pass: 53 / 54 (98.1%)
Expand Down
8 changes: 8 additions & 0 deletions apps/oxlint/src-js/plugins/source_code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ export const SOURCE_CODE = Object.freeze({
return ancestors.reverse();
},

/**
* Get source text as array of lines, split according to specification's definition of line breaks.
*/
getLines(): string[] {
if (lines.length === 0) initLines();
return lines;
},

// Location methods
getNodeByRangeIndex,
getLocFromIndex: getLineColumnFromOffset,
Expand Down
1 change: 1 addition & 0 deletions apps/oxlint/test/fixtures/sourceCode/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const createRule: Rule = {
const { ast, text } = sourceCode;

assert(context.getSourceCode() === sourceCode);
assert(sourceCode.getLines() === lines);

let locs = "";
for (let offset = 0; offset <= text.length; offset++) {
Expand Down
Loading