Skip to content

Commit

Permalink
Create parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Jul 30, 2020
1 parent 8b20f0a commit 034ef19
Show file tree
Hide file tree
Showing 847 changed files with 100,876 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use strict"

// const version = require("./package.json").version

module.exports = {
parserOptions: {
sourceType: "script",
ecmaVersion: 2020,
},
extends: ["plugin:@mysticatea/es2015", "plugin:@mysticatea/+node"],
rules: {
"require-jsdoc": "error",
"no-warning-comments": "warn",
"no-lonely-if": "off",
"@mysticatea/ts/ban-ts-ignore": "off",
},
overrides: [
{
files: ["*.ts"],
rules: {
"@mysticatea/node/no-missing-import": "off",
"no-implicit-globals": "off",
"@mysticatea/node/no-extraneous-import": "off",
},
parserOptions: {
sourceType: "module",
project: "./tsconfig.json",
},
},
{
files: ["scripts/**/*.ts", "tests/**/*.ts"],
rules: {
"require-jsdoc": "off",
"no-console": "off",
},
},
],
}
48 changes: 48 additions & 0 deletions .github/workflows/NodeCI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- name: Install Packages
run: npm install
- name: Lint
run: npm run lint
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.13.x, 12.x, 13.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Packages
run: npm install
- name: Test
run: npm test
test-and-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: Install Packages
run: npm install
- name: Test
run: npm run cover
- name: Coveralls GitHub Action
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/NpmPublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: publish
on:
push:
tags:
- "*"
jobs:
release:
name: check version, and release
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup Node
uses: actions/setup-node@v1
with:
registry-url: 'https://registry.npmjs.org'
- name: Install Packages
run: npm install
- name: test
run: npm run test
- name: check can npm-publish
run: npx can-npm-publish
- name: release
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ dist

# TernJS port file
.tern-port

# Build
/lib
Empty file added .gitmodules
Empty file.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"eslint.validate": [
"javascript",
"javascriptreact",
"vue",
"typescript"
],
"typescript.validate.enable": true,
"javascript.validate.enable": false,
"typescript.tsdk": "node_modules/typescript/lib",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
}
}
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,71 @@
# yaml-eslint-parser
A YAML parser that produces output compatible with ESLint

A YAML parser that produces output [compatible with ESLint](https://eslint.org/docs/developer-guide/working-with-custom-parsers#all-nodes).

This parser is backed by excellent [yaml](https://github.com/eemeli/yaml) and [yaml-unist-parser](https://github.com/ikatyang/yaml-unist-parser) packages.

[![NPM license](https://img.shields.io/npm/l/yaml-eslint-parser.svg)](https://www.npmjs.com/package/yaml-eslint-parser)
[![NPM version](https://img.shields.io/npm/v/yaml-eslint-parser.svg)](https://www.npmjs.com/package/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/yaml-eslint-parser&maxAge=3600)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dw/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dm/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dy/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dt/yaml-eslint-parser.svg)](http://www.npmtrends.com/yaml-eslint-parser)
[![Build Status](https://github.com/ota-meshi/yaml-eslint-parser/workflows/CI/badge.svg?branch=master)](https://github.com/ota-meshi/yaml-eslint-parser/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/ota-meshi/yaml-eslint-parser/badge.svg?branch=master)](https://coveralls.io/github/ota-meshi/yaml-eslint-parser?branch=master)

## Installation

```bash
npm install --save-dev yaml-eslint-parser
```

## Usage

### Configuration

Use `.eslintrc.*` file to configure parser. See also: [https://eslint.org/docs/user-guide/configuring](https://eslint.org/docs/user-guide/configuring).

Example **.eslintrc.js**:

```js
module.exports = {
"overrides": [
{
"files": ["*.yaml", "*.yml"],
"parser": "yaml-eslint-parser"
}
]
}
```

### Running ESLint from the command line

If you want to run `eslint` from the command line, make sure you include the `.yaml` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern, because ESLint targets only `.js` files by default.

Examples:

```bash
eslint --ext .js,.yaml,.yml src
eslint "src/**/*.{js,yaml,yml}"
```

## Editor Integrations

### Visual Studio Code

Use the [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension that Microsoft provides officially.

You have to configure the `eslint.validate` option of the extension to check `.yaml` files, because the extension targets only `*.js` or `*.jsx` files by default.

Example **.vscode/settings.json**:

```json
{
"eslint.validate": [
"javascript",
"javascriptreact",
"yaml"
]
}
```
52 changes: 52 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "yaml-eslint-parser",
"version": "0.0.0",
"description": "A YAML parser that produces output compatible with ESLint",
"main": "lib/index.js",
"files": [
"lib"
],
"scripts": {
"prebuild": "npm run -s clean",
"build": "tsc --project ./tsconfig.build.json",
"clean": "rimraf .nyc_output lib coverage",
"lint": "eslint \"tests\" \"src\" --ext .js,.ts",
"eslint-fix": "npm run lint -- --fix",
"test": "mocha --require ts-node/register \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
"cover": "nyc --reporter=lcov npm run test",
"debug": "mocha --require ts-node/register --inspect \"tests/src/**/*.ts\" --reporter dot",
"update-fixtures": "ts-node ./tools/update-fixtures.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ota-meshi/yaml-eslint-parser.git"
},
"keywords": [
"yaml",
"eslint",
"parser"
],
"author": "Yosuke Ota",
"license": "MIT",
"bugs": {
"url": "https://github.com/ota-meshi/yaml-eslint-parser/issues"
},
"homepage": "https://github.com/ota-meshi/yaml-eslint-parser#readme",
"dependencies": {
"eslint-visitor-keys": "^1.3.0",
"yaml": "^1.10.0",
"yaml-unist-parser": "^1.2.1"
},
"devDependencies": {
"@mysticatea/eslint-plugin": "^13.0.0",
"@types/eslint": "^7.2.0",
"@types/mocha": "^7.0.2",
"@types/node": "^14.0.13",
"eslint": "^7.5.0",
"mocha": "^7.0.0",
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
}
}
Loading

0 comments on commit 034ef19

Please sign in to comment.