Skip to content

Commit

Permalink
fix: eslint column is 0-indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Jul 1, 2021
1 parent 807690e commit c8ff9fe
Show file tree
Hide file tree
Showing 10 changed files with 1,327 additions and 677 deletions.
6 changes: 6 additions & 0 deletions .changeset/plenty-hats-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'eslint-plugin-htm': patch
'eslint-plugin-markup': patch
---

fix: eslint column is 0-indexed
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
yarn --frozen-lockfile
rm -rf .git/hooks/commit-msg
- name: Build
run: yarn build

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"clean": "rimraf packages/*/{lib,*.tsbuildinfo}",
"lint": "run-p lint:*",
"lint:es": "eslint . --cache -f friendly --max-warnings 10",
"lint:ts": "tsc -p tsconfig.base.json --noEmit",
"postinstall": "simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
"prerelease": "yarn build",
"release": "changeset publish",
"test": "jest",
"typecov": "type-coverage"
Expand All @@ -26,18 +26,18 @@
"@1stg/lib-config": "^3.0.0",
"@changesets/changelog-github": "^0.4.0",
"@changesets/cli": "^2.16.0",
"@markuplint/rule-textlint": "^0.1.1-alpha.6",
"@markuplint/rule-textlint": "^0.2.0-alpha.0",
"@types/eslint": "^7.2.13",
"@types/htmlhint": "^0.9.2",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.4",
"@types/node": "^15.12.5",
"eslint-plugin-mdx": "1.13.0",
"rimraf": "^3.0.2",
"textlint-rule-max-comma": "^2.0.2",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",
"type-coverage": "^2.18.0",
"typescript": "^4.3.4"
"typescript": "^4.3.5"
},
"commitlint": {
"extends": "@1stg"
Expand Down
3 changes: 2 additions & 1 deletion packages/htm/src/rules/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const html: Rule.RuleModule = {
message: JSON.stringify({ evidence, message, rule }),
loc: {
line,
column: col,
// ! eslint ast column is 0-indexed, but htmlhint is 1-indexed
column: col - 1,
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/htm/test/__snapshots__/fixtures.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`fixtures: basic.html 1`] = `
Array [
Object {
"column": 2,
"column": 1,
"line": 1,
"message": "Doctype must be declared first.
evidence: <!--comment--><!DOCTYPE html>
Expand Down
4 changes: 2 additions & 2 deletions packages/markup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"dependencies": {
"cosmiconfig": "^7.0.0",
"eslint-plugin-utils": "^0.1.0",
"markuplint": "^1.9.1",
"markuplint-sync": "^0.3.1",
"markuplint": "^1.10.0",
"markuplint-sync": "^0.3.2",
"synckit": "^0.1.5",
"tslib": "^2.3.0"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/markup/src/rules/markup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export const markup: Rule.RuleModule = {
message: JSON.stringify({ severity, message, ruleId }),
loc: {
line,
column: col,
// ! eslint ast column is 0-indexed, but markuplint is 1-indexed
column: col - 1,
},
fix() {
if (fixed++) {
Expand Down
22 changes: 11 additions & 11 deletions packages/markup/test/__snapshots__/fixtures.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`fixtures: attr-equal-space-after.html 1`] = `
Array [
Object {
"column": 10,
"column": 9,
"fix": Object {
"range": Array [
0,
Expand All @@ -25,23 +25,23 @@ Array [
"severity": 1,
},
Object {
"column": 10,
"column": 9,
"line": 2,
"message": "Never insert space after equal sign of attribute",
"nodeType": null,
"ruleId": "markup/attr-equal-space-after",
"severity": 1,
},
Object {
"column": 9,
"column": 8,
"line": 4,
"message": "Never insert space after equal sign of attribute",
"nodeType": null,
"ruleId": "markup/attr-equal-space-after",
"severity": 1,
},
Object {
"column": 9,
"column": 8,
"line": 7,
"message": "Never insert space after equal sign of attribute",
"nodeType": null,
Expand All @@ -54,7 +54,7 @@ Array [
exports[`fixtures: attr-spacing.html 1`] = `
Array [
Object {
"column": 20,
"column": 19,
"fix": Object {
"range": Array [
0,
Expand All @@ -75,7 +75,7 @@ Array [
exports[`fixtures: combine.html 1`] = `
Array [
Object {
"column": 10,
"column": 9,
"fix": Object {
"range": Array [
0,
Expand All @@ -99,31 +99,31 @@ Array [
"severity": 1,
},
Object {
"column": 10,
"column": 9,
"line": 2,
"message": "Never insert space after equal sign of attribute",
"nodeType": null,
"ruleId": "markup/attr-equal-space-after",
"severity": 1,
},
Object {
"column": 9,
"column": 8,
"line": 4,
"message": "Never insert space after equal sign of attribute",
"nodeType": null,
"ruleId": "markup/attr-equal-space-after",
"severity": 1,
},
Object {
"column": 9,
"column": 8,
"line": 7,
"message": "Never insert space after equal sign of attribute",
"nodeType": null,
"ruleId": "markup/attr-equal-space-after",
"severity": 1,
},
Object {
"column": 20,
"column": 19,
"line": 11,
"message": "Required space",
"nodeType": null,
Expand All @@ -136,7 +136,7 @@ Array [
exports[`fixtures: doctype.html 1`] = `
Array [
Object {
"column": 2,
"column": 1,
"line": 1,
"message": "Required doctype",
"nodeType": null,
Expand Down
4 changes: 2 additions & 2 deletions packages/markup/test/rules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ tester.run('markup', markup, {
ruleId: 'doctype',
}),
line: 1,
column: 2,
column: 1,
},
],
},
Expand All @@ -88,7 +88,7 @@ tester.run('markup', markup, {
ruleId: 'textlint',
}),
line: 1,
column: 11,
column: 10,
},
],
},
Expand Down
Loading

0 comments on commit c8ff9fe

Please sign in to comment.