Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade parser #148

Merged
merged 5 commits into from May 18, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/NodeCI.yml
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16
- name: Install Packages
run: npm install
- name: Lint
Expand All @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x]
node-version: [14.x, 16.x, 17.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -39,19 +39,19 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16
- name: Install Target Packages
run: |+
npm i -D eslint@6
npm i -D eslint@6 --legacy-peer-deps
npx rimraf node_modules
npm install
npm install --legacy-peer-deps
- name: Test
run: npm test
test-with-eslint7:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -54,7 +54,7 @@ npm install --save-dev eslint eslint-plugin-yml
> **Requirements**
>
> - ESLint v6.0.0 and above
> - Node.js v12.22.x, v14.17.x, v16.x and above
> - Node.js v14.17.x, v16.x and above

<!--DOCS_IGNORE_END-->

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/README.md
Expand Up @@ -9,7 +9,7 @@ npm install --save-dev eslint eslint-plugin-yml
::: tip Requirements

- ESLint v6.0.0 and above
- Node.js v12.22.x, v14.17.x, v16.x and above
- Node.js v14.17.x, v16.x and above

:::

Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -7,7 +7,7 @@
"lib"
],
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
"node": "^14.17.0 || >=16.0.0"
},
"scripts": {
"prebuild": "npm run -s clean",
Expand Down Expand Up @@ -52,7 +52,7 @@
"debug": "^4.3.2",
"lodash": "^4.17.21",
"natural-compare": "^1.4.0",
"yaml-eslint-parser": "^0.5.0"
"yaml-eslint-parser": "^1.0.0"
},
"peerDependencies": {
"eslint": ">=6.0.0"
Expand Down
@@ -0,0 +1 @@
{ "skipOutputTest": true }
@@ -0,0 +1 @@
{ "skipOutputTest": true }
@@ -0,0 +1 @@
{ "skipOutputTest": true }
@@ -1,7 +1,7 @@
[
{
"message": "Expected flow map to end with }",
"line": 3,
"column": 6
"message": "Flow map must end with a }",
"line": 4,
"column": 1
}
]
27 changes: 16 additions & 11 deletions tests/utils/utils.ts
Expand Up @@ -140,8 +140,9 @@ export function loadTestCases(
}
if (invalid.some((test) => test.output) && !options?.skipOutputTest) {
describe(`Output test for ${ruleName}`, () => {
for (const test of invalid.filter(({ filename }) =>
isYaml(filename),
for (const test of invalid.filter(
({ filename, skipOutputTest }) =>
isYaml(filename) && !skipOutputTest,
)) {
it(test.filename || test.code, () => {
const input = yamlESLintParser.parseForESLint(test.code)
Expand All @@ -154,6 +155,10 @@ export function loadTestCases(
}
})
}
for (const test of invalid) {
delete test.skipOutputTest
}

return {
valid,
invalid,
Expand Down Expand Up @@ -184,15 +189,7 @@ function* itrListupInput(rootDir: string): IterableIterator<string> {
}

function exists(f: string) {
try {
fs.statSync(f)
return true
} catch (error: any) {
if (error.code === "ENOENT") {
return false
}
throw error
}
return fs.existsSync(f)
}

export function makeSuiteTests(
Expand Down Expand Up @@ -372,6 +369,13 @@ function getLinter(ruleName: string) {
function getConfig(ruleName: string, inputFile: string) {
const filename = inputFile.slice(inputFile.indexOf(ruleName))
const code0 = fs.readFileSync(inputFile, "utf8")
const overrideConfigFile: string = inputFile.replace(
/input\.(?:ya?ml|vue)$/u,
"override-config.json",
)
const overrideConfig = exists(overrideConfigFile)
? JSON.parse(fs.readFileSync(overrideConfigFile, "utf8"))
: {}
let code, config
let configFile: string = inputFile.replace(
/input\.(?:ya?ml|vue)$/u,
Expand All @@ -392,6 +396,7 @@ function getConfig(ruleName: string, inputFile: string) {
? { parser: require.resolve("vue-eslint-parser") }
: {},
config,
overrideConfig,
{ code, filename },
)
}
Expand Down