├── .all-contributorsrc
├── .czrc
├── .dependabot
└── config.yml
├── .eslintignore
├── .eslintrc.js
├── .github
├── ISSUE_TEMPLATE
│ ├── Improve_Rule.md
│ ├── Others.md
│ ├── Rule_proposal.md
│ └── bug_report.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── check-update.yml
│ ├── release.yml
│ └── test.yml
├── .gitignore
├── .hygen.js
├── .prettierignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── _hygen
└── generate
│ ├── development
│ ├── eslint.ejs.t
│ └── test.ejs.t
│ ├── log
│ ├── eslint.ejs.t
│ ├── log.ejs.t
│ └── test.ejs.t
│ └── rule
│ ├── doc.ejs.t
│ ├── prompt.js
│ ├── rule.ejs.t
│ └── test.ejs.t
├── assets
└── logo
│ ├── eslint-plugin-gridsome.png
│ └── eslint-plugin-gridsome.svg
├── docs
├── .vuepress
│ ├── config.js
│ └── public
│ │ ├── eslint-plugin-gridsome.svg
│ │ └── favicon.png
├── README.md
├── developer-guide
│ └── README.md
├── introduction
│ └── README.md
├── rules
│ ├── README.md
│ ├── format-query-block.md
│ ├── require-g-image-src.md
│ ├── require-g-link-to.md
│ └── use-env-prefix.md
└── user-guide
│ └── README.md
├── lib
├── configs.ts
├── configs
│ ├── base.ts
│ └── recommended.ts
├── index.ts
├── rules.ts
├── rules
│ ├── format-query-block.ts
│ ├── require-g-image-src.ts
│ ├── require-g-link-to.ts
│ └── use-env-prefix.ts
└── utils
│ ├── attribute.ts
│ ├── create-rule.ts
│ ├── directive.ts
│ ├── env.ts
│ ├── get-code-wrap-indent-info.ts
│ ├── get-prettier-option.ts
│ ├── index.ts
│ ├── parser-services.ts
│ ├── path.ts
│ ├── rule-creator.ts
│ └── types
│ ├── Node.ts
│ ├── Parser.ts
│ ├── Prettier.ts
│ ├── Rule.ts
│ └── index.ts
├── package-lock.json
├── package.json
├── tests
├── lib
│ ├── rules
│ │ ├── fixtures
│ │ │ ├── format-query-block
│ │ │ │ ├── invalid
│ │ │ │ │ ├── 01
│ │ │ │ │ │ ├── code.vue
│ │ │ │ │ │ └── output.vue
│ │ │ │ │ ├── 02
│ │ │ │ │ │ ├── code.vue
│ │ │ │ │ │ └── output.vue
│ │ │ │ │ ├── 03
│ │ │ │ │ │ ├── code.vue
│ │ │ │ │ │ └── output.vue
│ │ │ │ │ └── 04
│ │ │ │ │ │ ├── code.vue
│ │ │ │ │ │ └── output.vue
│ │ │ │ └── valid
│ │ │ │ │ ├── 01
│ │ │ │ │ └── code.vue
│ │ │ │ │ ├── 02
│ │ │ │ │ └── code.vue
│ │ │ │ │ └── 03
│ │ │ │ │ └── code.vue
│ │ │ └── use-env-prefix
│ │ │ │ ├── invalid
│ │ │ │ ├── 01
│ │ │ │ │ ├── .env
│ │ │ │ │ └── code.vue
│ │ │ │ └── 02
│ │ │ │ │ ├── .env
│ │ │ │ │ └── client.js
│ │ │ │ └── valid
│ │ │ │ ├── 01
│ │ │ │ ├── .env
│ │ │ │ └── code.vue
│ │ │ │ ├── 02
│ │ │ │ ├── .env
│ │ │ │ └── client.js
│ │ │ │ └── 03
│ │ │ │ └── client.js
│ │ ├── format-query-block.spec.ts
│ │ ├── require-g-image-src.spec.ts
│ │ ├── require-g-link-to.spec.ts
│ │ └── use-env-prefix.spec.ts
│ └── utils
│ │ ├── env.spec.ts
│ │ ├── fixtures
│ │ ├── get-code-wrap-indent-info
│ │ │ ├── not-use-prettierrc
│ │ │ │ └── file.vue
│ │ │ ├── override-prettier-option
│ │ │ │ ├── not-use-prettierrc
│ │ │ │ │ └── file.vue
│ │ │ │ └── use-prettierrc
│ │ │ │ │ ├── .prettierrc
│ │ │ │ │ └── file.vue
│ │ │ └── use-prettierrc
│ │ │ │ ├── set-other-option
│ │ │ │ ├── .prettierrc
│ │ │ │ └── file.vue
│ │ │ │ ├── set-tab-width
│ │ │ │ ├── .prettierrc
│ │ │ │ └── file.vue
│ │ │ │ └── set-use-tabs
│ │ │ │ ├── .prettierrc
│ │ │ │ └── file.vue
│ │ └── get-prettier-option
│ │ │ ├── not-use-prettierrc
│ │ │ └── file.vue
│ │ │ └── use-prettierrc
│ │ │ ├── .prettierrc
│ │ │ └── file.vue
│ │ ├── get-code-wrap-indent-info.spec.ts
│ │ ├── get-prettier-option.spec.ts
│ │ └── path.spec.ts
└── util
│ ├── index.ts
│ ├── load-fixture-creator.ts
│ └── rule-tester.ts
├── tools
├── update-rules-docs.ts
├── update-rules-list.ts
├── update.ts
└── util
│ ├── const.ts
│ ├── create-rules-docs.ts
│ ├── create-rules-list.ts
│ ├── format-markdown.ts
│ ├── format-typescript.ts
│ ├── get-rules-meta-data.ts
│ ├── index.ts
│ └── types.ts
├── tsconfig.build.json
└── tsconfig.json
/.all-contributorsrc:
--------------------------------------------------------------------------------
1 | {
2 | "projectName": "eslint-plugin-gridsome",
3 | "projectOwner": "gridsome",
4 | "repoType": "github",
5 | "repoHost": "https://github.com",
6 | "files": [
7 | "README.md"
8 | ],
9 | "imageSize": 100,
10 | "commit": true,
11 | "commitConvention": "angular",
12 | "badgeTemplate": "
-orange.svg\">",
13 | "contributors": [
14 | {
15 | "login": "tyankatsu0105",
16 | "name": "tyankatsu",
17 | "avatar_url": "https://avatars0.githubusercontent.com/u/28397593?v=4",
18 | "profile": "https://tyankatsu.netlify.com/",
19 | "contributions": [
20 | "code",
21 | "doc",
22 | "maintenance",
23 | "test"
24 | ]
25 | },
26 | {
27 | "login": "hacknug",
28 | "name": "Nestor Vera",
29 | "avatar_url": "https://avatars0.githubusercontent.com/u/1107521?v=4",
30 | "profile": "https://www.nestor.rip",
31 | "contributions": [
32 | "bug",
33 | "ideas"
34 | ]
35 | }
36 | ],
37 | "contributorsPerLine": 7
38 | }
39 |
--------------------------------------------------------------------------------
/.czrc:
--------------------------------------------------------------------------------
1 | {
2 | "path": "cz-conventional-changelog"
3 | }
4 |
--------------------------------------------------------------------------------
/.dependabot/config.yml:
--------------------------------------------------------------------------------
1 | version: 1
2 |
3 | update_configs:
4 | - package_manager: 'javascript'
5 | directory: '/'
6 | update_schedule: 'weekly'
7 | target_branch: 'master'
8 | default_reviewers:
9 | - 'tyankatsu0105'
10 | default_assignees:
11 | - 'tyankatsu0105'
12 | default_labels:
13 | - '🤖dependencies'
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/**/*
2 | log/**/*
3 | tools/update-readme/_readme/*
4 | fixtures
5 | lib/**/*.js
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | /** @type import('eslint').Linter.BaseConfig */
2 | module.exports = {
3 | parserOptions: {
4 | ecmaVersion: 2017,
5 | sourceType: "module",
6 | },
7 | parser: "@typescript-eslint/parser",
8 | env: {
9 | node: true,
10 | },
11 |
12 | extends: [
13 | "eslint:recommended",
14 | "plugin:@typescript-eslint/recommended",
15 | "prettier",
16 | ],
17 | plugins: ["prettier"],
18 | rules: {
19 | "prettier/prettier": "error",
20 | "func-style": ["error", "expression"],
21 | "@typescript-eslint/explicit-module-boundary-types": "off",
22 | "@typescript-eslint/ban-types": "off",
23 | "@typescript-eslint/no-explicit-any": "off",
24 | "no-irregular-whitespace": ["error", {
25 | "skipRegExps": true
26 | }]
27 | },
28 | };
29 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Improve_Rule.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Improve Rule
3 | about: Suggest an idea for a exist rule
4 | ---
5 |
6 | **Please write rule name what you want to improve:**
7 |
8 |
9 |
10 | **How are the rules improved?:**
11 |
12 | **Provide 2-3 code examples that this rule should warn about:**
13 |
14 | ```vue
15 |
16 | ```
17 |
18 | **Additional context**
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Others.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Others
3 | about: Others
4 | ---
5 |
6 |
9 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Rule_proposal.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Rule Proposal
3 | about: Suggest an idea for a new rule
4 | ---
5 |
6 |
11 |
12 | **Please describe what the rule should do:**
13 |
14 |
15 |
16 | **What category should the rule belong to?**
17 |
18 |
19 |
20 | - [ ] Enforces code style
21 | - [ ] Warns about a potential error
22 | - [ ] Suggests an alternate way of doing something
23 | - [ ] Other (please specify:)
24 |
25 | **Provide 2-3 code examples that this rule should warn about:**
26 |
27 | ```vue
28 |
29 | ```
30 |
31 | **Additional context**
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | ---
5 |
6 |
11 |
12 | **Tell us about your environment**
13 |
14 | - **ESLint version:**
15 | - **eslint-plugin-gridsome version:**
16 | - **Node version:**
17 |
18 | **Please show your full configuration:**
19 |
20 |
21 |
22 | ```json
23 |
24 | ```
25 |
26 | **What did you do?**
27 |
28 |
29 |
30 | ```vue
31 |
32 | ```
33 |
34 | **What did you expect to happen?**
35 |
36 | **What actually happened?**
37 |
38 |
39 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Check
4 |
5 | - [ ] Pass the rule's test. : `npm run test`
6 | - [ ] Fill the rule's docs.
7 | - [ ] Create files by Hygen. : `npm run gen:rule`
8 |
9 |
10 |
11 | # What
12 |
13 | # Related issue
14 |
--------------------------------------------------------------------------------
/.github/workflows/check-update.yml:
--------------------------------------------------------------------------------
1 | name: Check Update
2 |
3 | on: push
4 |
5 | jobs:
6 | checkDocs:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - uses: actions/checkout@v2
11 |
12 | - uses: actions/cache@v1
13 | id: cache
14 | with:
15 | path: node_modules
16 | key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
17 | restore-keys: |
18 | ${{ runner.os }}-npm-
19 | - name: Use Node.js 12
20 | uses: actions/setup-node@v1
21 | with:
22 | registry-url: "https://registry.npmjs.org"
23 | node-version: '12.x'
24 |
25 | - name: Install dependencies
26 | if: steps.cache.outputs.cache-hit != 'true'
27 | run: npm ci
28 |
29 | - name: Update Rules Docs
30 | run: npm run update
31 |
32 | - name: Check diff
33 | id: check-diff
34 | run: |
35 | echo ::set-output name=diff-files::$(git diff --diff-filter=AM --name-only)
36 |
37 | - name: Report
38 | if: steps.check-diff.outputs.diff-files
39 | uses: mshick/add-pr-comment@v1
40 | with:
41 | message: |
42 | Please run `npm run update`
43 | repo-token: ${{ secrets.GITHUB_TOKEN }}
44 | allow-repeats: 'true'
45 |
46 | - name: Exit
47 | if: steps.check-diff.outputs.diff-files
48 | run: exit 1
49 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 | on:
3 | pull_request:
4 | types:
5 | - closed
6 | jobs:
7 | release:
8 | name: Release
9 | runs-on: ubuntu-latest
10 | if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/v')
11 | steps:
12 | - uses: actions/checkout@v2
13 | with:
14 | ref: master
15 | fetch-depth: 0
16 |
17 | - uses: actions/cache@v2
18 | id: cache
19 | with:
20 | path: node_modules
21 | key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
22 | restore-keys: |
23 | ${{ runner.os }}-npm-
24 | - name: Use Node.js 12
25 | uses: actions/setup-node@v1
26 | with:
27 | registry-url: 'https://registry.npmjs.org'
28 | node-version: '12.x'
29 |
30 | - name: Install dependencies
31 | if: steps.cache.outputs.cache-hit != 'true'
32 | run: npm ci
33 |
34 | - run: npx shipjs trigger
35 | env:
36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 | NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Rules Test
2 |
3 | on: push
4 |
5 | jobs:
6 | test:
7 | runs-on: ubuntu-latest
8 |
9 | strategy:
10 | matrix:
11 | # Test with Node.js v10 (LTS), v12 (LTS), v13, and v14 (latest)
12 | node-version: [10.x, 12.x, 13.x, 14.x]
13 |
14 | steps:
15 | - uses: actions/checkout@v2
16 |
17 | - uses: actions/cache@v1
18 | id: cache
19 | with:
20 | path: node_modules
21 | key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
22 | restore-keys: |
23 | ${{ runner.os }}-npm-
24 |
25 | - name: Use Node.js ${{ matrix.node-version }}
26 | uses: actions/setup-node@v1
27 | with:
28 | node-version: ${{ matrix.node-version }}
29 |
30 | - name: Install dependencies
31 | if: steps.cache.outputs.cache-hit != 'true'
32 | run: npm ci
33 |
34 | - name: Test
35 | run: npm run test
36 |
37 | - name: Typecheck
38 | run: npm run typecheck
39 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
2 |
3 | # Created by https://www.gitignore.io/api/macos,visualstudiocode,node
4 | # Edit at https://www.gitignore.io/?templates=macos,visualstudiocode,node
5 |
6 | ### macOS ###
7 | # General
8 | .DS_Store
9 | .AppleDouble
10 | .LSOverride
11 |
12 | # Icon must end with two \r
13 | Icon
14 |
15 | # Thumbnails
16 | ._*
17 |
18 | # Files that might appear in the root of a volume
19 | .DocumentRevisions-V100
20 | .fseventsd
21 | .Spotlight-V100
22 | .TemporaryItems
23 | .Trashes
24 | .VolumeIcon.icns
25 | .com.apple.timemachine.donotpresent
26 |
27 | # Directories potentially created on remote AFP share
28 | .AppleDB
29 | .AppleDesktop
30 | Network Trash Folder
31 | Temporary Items
32 | .apdisk
33 |
34 | ### Node ###
35 | # Logs
36 | logs
37 | *.log
38 | npm-debug.log*
39 | yarn-debug.log*
40 | yarn-error.log*
41 |
42 | # Runtime data
43 | pids
44 | *.pid
45 | *.seed
46 | *.pid.lock
47 |
48 | # Directory for instrumented libs generated by jscoverage/JSCover
49 | lib-cov
50 |
51 | # Coverage directory used by tools like istanbul
52 | coverage
53 |
54 | # nyc test coverage
55 | .nyc_output
56 |
57 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
58 | .grunt
59 |
60 | # Bower dependency directory (https://bower.io/)
61 | bower_components
62 |
63 | # node-waf configuration
64 | .lock-wscript
65 |
66 | # Compiled binary addons (https://nodejs.org/api/addons.html)
67 | build/Release
68 |
69 | # Dependency directories
70 | node_modules/
71 | jspm_packages/
72 |
73 | # TypeScript v1 declaration files
74 | typings/
75 |
76 | # Optional npm cache directory
77 | .npm
78 |
79 | # Optional eslint cache
80 | .eslintcache
81 |
82 | # Optional REPL history
83 | .node_repl_history
84 |
85 | # Output of 'npm pack'
86 | *.tgz
87 |
88 | # Yarn Integrity file
89 | .yarn-integrity
90 |
91 | # dotenv environment variables file
92 | /.env
93 |
94 | # parcel-bundler cache (https://parceljs.org/)
95 | .cache
96 |
97 | # next.js build output
98 | .next
99 |
100 | # nuxt.js build output
101 | .nuxt
102 |
103 | # vuepress build output
104 | .vuepress/dist
105 |
106 | # Serverless directories
107 | .serverless
108 |
109 | # FuseBox cache
110 | .fusebox/
111 |
112 | ### VisualStudioCode ###
113 | .vscode/*
114 | !.vscode/settings.json
115 | !.vscode/tasks.json
116 | !.vscode/launch.json
117 | !.vscode/extensions.json
118 |
119 | ### VisualStudioCode Patch ###
120 | # Ignore all local history of files
121 | .history
122 |
123 | # End of https://www.gitignore.io/api/macos,visualstudiocode,node
124 |
125 | # Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
126 |
127 | .node-version
128 | /log
129 | .vscode
130 | .tool-versions
131 | /development
132 | !/development/.gitkeep
133 | dist
--------------------------------------------------------------------------------
/.hygen.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | templates: `${__dirname}/_hygen`,
3 | };
4 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | tools/update-readme/_*
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [1.6.2](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.6.1...v1.6.2) (2021-02-13)
2 |
3 |
4 | ### Bug Fixes
5 |
6 | * **use-env-prefix:** consider that env file does not exist ([#119](https://github.com/gridsome/eslint-plugin-gridsome/issues/119)) ([6cd3b45](https://github.com/gridsome/eslint-plugin-gridsome/commit/6cd3b4586593a1e6e1abbed93d4cf52cf6eb0f33))
7 |
8 |
9 |
10 | ## [1.6.1](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.6.0...v1.6.1) (2021-01-17)
11 |
12 |
13 | ### Bug Fixes
14 |
15 | * **use-env-prefix:** fix around treating filename ([#117](https://github.com/gridsome/eslint-plugin-gridsome/issues/117)) ([d25d1ae](https://github.com/gridsome/eslint-plugin-gridsome/commit/d25d1aea2e5c11e56ef871a1fd2b89ddbe849e7e)), closes [#116](https://github.com/gridsome/eslint-plugin-gridsome/issues/116)
16 |
17 |
18 |
19 | # [1.6.0](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.5.2...v1.6.0) (2021-01-17)
20 |
21 |
22 | ### Features
23 |
24 | * add `use-env-prefix` rules ([#113](https://github.com/gridsome/eslint-plugin-gridsome/issues/113)) ([134ab7e](https://github.com/gridsome/eslint-plugin-gridsome/commit/134ab7ea87031af349f829a906fa4541f88d1af4))
25 |
26 |
27 |
28 | ## [1.5.2](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.5.1...v1.5.2) (2020-12-22)
29 |
30 |
31 |
32 | ## [1.5.1](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.5.0...v1.5.1) (2020-12-22)
33 |
34 |
35 |
36 | # [1.5.0](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.13...v1.5.0) (2020-07-05)
37 |
38 |
39 | ### Features
40 |
41 | * **format-query-block:** add option overridePrettierOption ([#104](https://github.com/gridsome/eslint-plugin-gridsome/issues/104)) ([1110fa7](https://github.com/gridsome/eslint-plugin-gridsome/commit/1110fa796d1d934b00c91b37037960f70df252eb)), closes [#60](https://github.com/gridsome/eslint-plugin-gridsome/issues/60)
42 |
43 |
44 |
45 | ## [1.4.13](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.12...v1.4.13) (2020-06-23)
46 |
47 |
48 | ### Features
49 |
50 | * follow ESLint v7 ([59eb4fa](https://github.com/gridsome/eslint-plugin-gridsome/commit/59eb4fada38fea400201051f3551593ce0eac757))
51 |
52 |
53 |
54 | ## [1.4.12](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.11...v1.4.12) (2020-05-22)
55 |
56 |
57 |
58 | ## [1.4.11](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.9...v1.4.11) (2020-05-13)
59 |
60 |
61 |
62 | ## [1.4.10](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.9...v1.4.10) (2020-05-08)
63 |
64 |
65 |
66 | ## [1.4.9](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.1...v1.4.9) (2020-04-26)
67 |
68 |
69 |
70 | ## [1.4.8](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.1...v1.4.8) (2020-04-25)
71 |
72 |
73 |
74 | ## [1.4.7](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.1...v1.4.7) (2020-04-25)
75 |
76 |
77 |
78 | ## [1.4.6](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.1...v1.4.6) (2020-04-25)
79 |
80 |
81 |
82 | ## [1.4.5](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.1...v1.4.5) (2020-04-25)
83 |
84 |
85 |
86 | ## [1.4.4](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.1...v1.4.4) (2020-04-25)
87 |
88 |
89 |
90 | ## [1.4.3](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.1...v1.4.3) (2020-04-25)
91 |
92 |
93 |
94 | ## [1.4.2](https://github.com/gridsome/eslint-plugin-gridsome/compare/v1.4.1...v1.4.2) (2020-04-25)
95 |
96 |
97 |
98 | #### 1.4.1 (2020-03-08)
99 |
100 | ##### Build System / Dependencies
101 |
102 | * **node engine:** update node engine to v10.13.0 ([#50](https://github.com/gridsome/eslint-plugin-gridsome/pull/50)) ([45395586](https://github.com/gridsome/eslint-plugin-gridsome/commit/45395586e812167f1c1eb7e9c02d4e4a86b2b9ff))
103 | * Upgrade ESLint v6 ([#47](https://github.com/gridsome/eslint-plugin-gridsome/pull/47)) ([0a0e3900](https://github.com/gridsome/eslint-plugin-gridsome/commit/0a0e3900a655e93f7a4fd2422ed104c1ca5ebe86))
104 |
105 | ##### Chores
106 |
107 | * add all-contributors-cli ([#52](https://github.com/gridsome/eslint-plugin-gridsome/pull/52)) ([5db85f02](https://github.com/gridsome/eslint-plugin-gridsome/commit/5db85f02e95240d2e3d133e9a36138242e3637f1))
108 |
109 | ##### Documentation Changes
110 |
111 | * add @hacknug as a contributor ([#54](https://github.com/gridsome/eslint-plugin-gridsome/pull/54)) ([cd9c8ced](https://github.com/gridsome/eslint-plugin-gridsome/commit/cd9c8ced8422da0e3014108b663dc87a287328d0))
112 |
113 | ##### New Features
114 |
115 | * Support break line ([#58](https://github.com/gridsome/eslint-plugin-gridsome/pull/58)) ([b2ea54c0](https://github.com/gridsome/eslint-plugin-gridsome/commit/b2ea54c091d0fa46d41a38f9f5d1f2625ddec3df))
116 | * **website:** Add docs site with vuepress ([#51](https://github.com/gridsome/eslint-plugin-gridsome/pull/51)) ([c50b84c6](https://github.com/gridsome/eslint-plugin-gridsome/commit/c50b84c6a47383ed7083827d2beee1124f24fdce))
117 |
118 | ### 1.4.0 (2019-11-03)
119 |
120 | ##### Chores
121 |
122 | * add development directory ([#41](https://github.com/gridsome/eslint-plugin-gridsome/pull/41)) ([6d558f98](https://github.com/gridsome/eslint-plugin-gridsome/commit/6d558f985d745a2356e1662afeb73fc90b28d966))
123 |
124 | ##### Other Changes
125 |
126 | * **format-query-block:** add baseIndent option ([#42](https://github.com/gridsome/eslint-plugin-gridsome/pull/42)) ([d053d75f](https://github.com/gridsome/eslint-plugin-gridsome/commit/d053d75ffb438791dd9faab3b48de2b6f83bee5a))
127 |
128 | #### 1.3.2 (2019-09-29)
129 |
130 | ##### Build System / Dependencies
131 |
132 | * remove yarn ([#37](https://github.com/gridsome/eslint-plugin-gridsome/pull/37)) ([354c0cfb](https://github.com/gridsome/eslint-plugin-gridsome/commit/354c0cfb86cd24863f422f33e85cbf424e36d483))
133 |
134 | ##### Documentation Changes
135 |
136 | * **CHANGELOG.md:**
137 | * :bookmark: updated CHANGELOG.md ([30434a06](https://github.com/gridsome/eslint-plugin-gridsome/commit/30434a06de235ecd1d04cef44ee6de4c72710172))
138 | * :bookmark: updated CHANGELOG.md ([7a726e71](https://github.com/gridsome/eslint-plugin-gridsome/commit/7a726e71eff88392e0748f17148d950cff33be51))
139 |
140 | ##### Other Changes
141 |
142 | * gridsome/eslint-plugin-gridsome ([9d6b0960](https://github.com/gridsome/eslint-plugin-gridsome/commit/9d6b096057b11f2919972c96dcbf3d58e89da88b))
143 | * updated version ([4216aecb](https://github.com/gridsome/eslint-plugin-gridsome/commit/4216aecbd843f68383fdba009a46191a13071f46))
144 |
145 | #### 1.3.1 (2019-09-29)
146 |
147 | ##### Build System / Dependencies
148 |
149 | * remove yarn ([#37](https://github.com/gridsome/eslint-plugin-gridsome/pull/37)) ([354c0cfb](https://github.com/gridsome/eslint-plugin-gridsome/commit/354c0cfb86cd24863f422f33e85cbf424e36d483))
150 |
151 | ##### Documentation Changes
152 |
153 | * **CHANGELOG.md:** :bookmark: updated CHANGELOG.md ([7a726e71](https://github.com/gridsome/eslint-plugin-gridsome/commit/7a726e71eff88392e0748f17148d950cff33be51))
154 |
155 | ##### Other Changes
156 |
157 | * updated version ([4216aecb](https://github.com/gridsome/eslint-plugin-gridsome/commit/4216aecbd843f68383fdba009a46191a13071f46))
158 |
159 | ### 1.3.0 (2019-09-15)
160 |
161 | ##### Refactors
162 |
163 | - refactor g-link consider href ([#35](https://github.com/gridsome/eslint-plugin-gridsome/pull/35)) ([2eec64b5](https://github.com/gridsome/eslint-plugin-gridsome/commit/2eec64b59ac6315a0ba9e09c42d00986b37e0360))
164 |
165 | #### 1.2.9 (2019-09-15)
166 |
167 | ##### Build System / Dependencies
168 |
169 | - **deps:**
170 | - bump js-yaml from 3.12.1 to 3.13.1 ([#17](https://github.com/gridsome/eslint-plugin-gridsome/pull/17)) ([c4c95ea9](https://github.com/gridsome/eslint-plugin-gridsome/commit/c4c95ea997816d83d1359f46a7c766feed3510fd))
171 | - bump mixin-deep from 1.3.1 to 1.3.2 ([#23](https://github.com/gridsome/eslint-plugin-gridsome/pull/23)) ([9b324cc9](https://github.com/gridsome/eslint-plugin-gridsome/commit/9b324cc9bf2400b803c1d6f201ef2a3eb6a1faf2))
172 | - bump eslint-utils from 1.3.1 to 1.4.2 ([#22](https://github.com/gridsome/eslint-plugin-gridsome/pull/22)) ([4aa96f6c](https://github.com/gridsome/eslint-plugin-gridsome/commit/4aa96f6c64e4f8b9c328276fdc8588df6257b2d7))
173 | - upgrade packages version ([#32](https://github.com/gridsome/eslint-plugin-gridsome/pull/32)) ([a8420ff7](https://github.com/gridsome/eslint-plugin-gridsome/commit/a8420ff75802bd3c05ac70258750d8b3c35857d0))
174 |
175 | ##### Chores
176 |
177 | - remove fixture ([#30](https://github.com/gridsome/eslint-plugin-gridsome/pull/30)) ([a151708a](https://github.com/gridsome/eslint-plugin-gridsome/commit/a151708af977e74528cd52e3f60f2bb344bc5f20))
178 |
179 | ##### Continuous Integration
180 |
181 | - refacotr travis.yml ([#29](https://github.com/gridsome/eslint-plugin-gridsome/pull/29)) ([1bee3712](https://github.com/gridsome/eslint-plugin-gridsome/commit/1bee3712d28ca2f12dcfe9174824ed3c41b3e839))
182 |
183 | ##### Documentation Changes
184 |
185 | - reverse correct and incorrect example ([#33](https://github.com/gridsome/eslint-plugin-gridsome/pull/33)) ([37736527](https://github.com/gridsome/eslint-plugin-gridsome/commit/37736527b3fb7d8d12e49d15fe8bbba4adb8331d))
186 | - fix others issue template ([cdd16edf](https://github.com/gridsome/eslint-plugin-gridsome/commit/cdd16edf1fc6c6c590137ed66bee71b6151088f0))
187 | - Add issue template ([#25](https://github.com/gridsome/eslint-plugin-gridsome/pull/25)) ([01d48038](https://github.com/gridsome/eslint-plugin-gridsome/commit/01d48038bad09c838fb08f72e7f7a7add11c11fe))
188 |
189 | #### 1.2.8 (2019-08-06)
190 |
191 | ##### Build System / Dependencies
192 |
193 | - downgrade eslint from ^6.1.0 ([b80a0988](https://github.com/gridsome/eslint-plugin-gridsome/commit/b80a0988e4f466157f084498e31e6f7c2ebb2c8f))
194 | - **deps:** bump lodash from 4.17.11 to 4.17.14 ([#20](https://github.com/gridsome/eslint-plugin-gridsome/pull/20)) ([e2d4098a](https://github.com/gridsome/eslint-plugin-gridsome/commit/e2d4098a13bed8ad2624b0a267076eff20eca548))
195 |
196 | #### 1.2.7 (2019-08-04)
197 |
198 | ##### Build System / Dependencies
199 |
200 | - upgrade dependence packages ([80eb3ada](https://github.com/gridsome/eslint-plugin-gridsome/commit/80eb3ada73b6409c24557d50ad8c9cccb01009c1))
201 |
202 | ##### Documentation Changes
203 |
204 | - Add tips about vue-eslint-parser version ([#19](https://github.com/gridsome/eslint-plugin-gridsome/pull/19)) ([a77762c6](https://github.com/gridsome/eslint-plugin-gridsome/commit/a77762c657ffdeb73448baf479867ea771b6dd76))
205 |
206 | #### 1.2.6 (2019-06-10)
207 |
208 | ##### Build System / Dependencies
209 |
210 | - Upgrade packages ([#18](https://github.com/gridsome/eslint-plugin-gridsome/pull/18)) ([c2f24932](https://github.com/gridsome/eslint-plugin-gridsome/commit/c2f249320704ae5aadce31de7fb8fa91866744c7))
211 |
212 | #### 1.2.5 (2019-05-11)
213 |
214 | ##### Chores
215 |
216 | - Update logo ([4c92d208](https://github.com/gridsome/eslint-plugin-gridsome/commit/4c92d208e7081012f68db6c448593a0fe46df497))
217 |
218 | ##### Refactors
219 |
220 | - Add parserOptions item and change env node to browser ([61b5eb63](https://github.com/gridsome/eslint-plugin-gridsome/commit/61b5eb63618d3b05e176729e002728010be4a2ff))
221 | - **configs:** Added parser option ([#14](https://github.com/gridsome/eslint-plugin-gridsome/pull/14)) ([987c200e](https://github.com/gridsome/eslint-plugin-gridsome/commit/987c200e190c5efe3188f9bb52c7ae00eccdb45a))
222 |
223 | #### 1.2.4 (2019-05-03)
224 |
225 | ##### Chores
226 |
227 | - Update logo png and change format readme ([65b0690e](https://github.com/gridsome/eslint-plugin-gridsome/commit/65b0690e756f02d0be844318b1d5a87d4aa25c62))
228 |
229 | #### 1.2.3 (2019-05-02)
230 |
231 | ##### New Features
232 |
233 | - Add logo for eslint-plugin-gridsome ([#13](https://github.com/gridsome/eslint-plugin-gridsome/pull/13)) ([916f6d2f](https://github.com/gridsome/eslint-plugin-gridsome/commit/916f6d2fbd4a6d8903e5920f8a36f1254527de54))
234 |
235 | #### 1.2.2 (2019-05-01)
236 |
237 | ##### Documentation Changes
238 |
239 | - Add explain configs ([8d74bede](https://github.com/gridsome/eslint-plugin-gridsome/commit/8d74bede9329a41b1bc789b49372bb59531c259f))
240 |
241 | ##### Refactors
242 |
243 | - Check prettier config in query-block-format ([#5](https://github.com/gridsome/eslint-plugin-gridsome/pull/5)) ([d659e273](https://github.com/gridsome/eslint-plugin-gridsome/commit/d659e273439bf243dc3343375f7f397280ee7d90))
244 |
245 | #### 1.2.1 (2019-05-01)
246 |
247 | ##### Documentation Changes
248 |
249 | - Fix special characters ([#9](https://github.com/gridsome/eslint-plugin-gridsome/pull/9)) ([6ed5b982](https://github.com/gridsome/eslint-plugin-gridsome/commit/6ed5b982de2b4d87fcfa6ba449c0043102334fc6))
250 |
251 | ##### New Features
252 |
253 | - Add configs ([#11](https://github.com/gridsome/eslint-plugin-gridsome/pull/11)) ([0445ee15](https://github.com/gridsome/eslint-plugin-gridsome/commit/0445ee153b32b49401de3de6c88f5068957f8a5e))
254 |
255 | ### 1.2.0 (2019-05-01)
256 |
257 | ##### Build System / Dependencies
258 |
259 | - Upgrade package version ([5ab35312](https://github.com/gridsome/eslint-plugin-gridsome/commit/5ab353125f3fd52b99bb436192fc431d866cbdfc))
260 |
261 | ##### Chores
262 |
263 | - remove fixpack to fix security warning ([ba57fe00](https://github.com/gridsome/eslint-plugin-gridsome/commit/ba57fe004b3ae00be972674ad1fd4c28f6cd99a0))
264 |
265 | ##### Other Changes
266 |
267 | - Add rule require-g-link-to ([#7](https://github.com/gridsome/eslint-plugin-gridsome/pull/7)) ([bd80a026](https://github.com/gridsome/eslint-plugin-gridsome/commit/bd80a0265b83aaad4fcce0c51cfa7e48838ce058))
268 | - Add new rule `require-g-image-src` ([#6](https://github.com/gridsome/eslint-plugin-gridsome/pull/6)) ([fa05552b](https://github.com/gridsome/eslint-plugin-gridsome/commit/fa05552b97c638754b179e636df265fa4d9cef1a))
269 |
270 | ##### Performance Improvements
271 |
272 | - Rename npm scripts ([97048ef3](https://github.com/gridsome/eslint-plugin-gridsome/commit/97048ef370e3f1c284953663b006cf7393b319fb))
273 |
274 | #### 1.1.1 (2019-03-03)
275 |
276 | ##### Chores
277 |
278 | - **package.json:** don’t watch default test command ([089b0f14](https://github.com/gridsome/eslint-plugin-gridsome/commit/089b0f1410b4ed1d844359d4aea2b1d81d3fb6d5))
279 |
280 | ### 1.1.0 (2019-02-21)
281 |
282 | ##### Chores
283 |
284 | - **package.json:** Change author homepage ([085578eb](https://github.com/gridsome/eslint-plugin-gridsome/commit/085578eb5dcbeea752ebd72fff94ce1a74331de3))
285 |
286 | ##### Documentation Changes
287 |
288 | - Update rule description format-query ([244bbd1b](https://github.com/gridsome/eslint-plugin-gridsome/commit/244bbd1b0520d8a58b5482a2139797890b8974d8))
289 |
290 | ##### Refactors
291 |
292 | - Clean code ([8c2d5b4e](https://github.com/gridsome/eslint-plugin-gridsome/commit/8c2d5b4e6c0339a1f6d1e6b5efb9ec9182972192))
293 |
294 | #### 1.0.1 (2018-12-11)
295 |
296 | ##### Documentation Changes
297 |
298 | - fix add ([69845049](https://github.com/gridsome/eslint-plugin-gridsome/commit/69845049bfd139992e1daf4a149bcc56eba639b4))
299 |
300 | ## 1.0.0 (2018-12-06)
301 |
302 | ##### Documentation Changes
303 |
304 | - refactor README ([f372e6fc](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/f372e6fc6bc24c3d79a86663e348ec43e16d7c8c))
305 | - refactor rule doc ([06d51b67](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/06d51b679e8b4baee124bc886c1ac3e37b85a372))
306 | - roadmap status change ([5e826898](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/5e8268989bc1a69d1e5f6f7e5be026332e25737b))
307 | - roadmap status change ([430e7377](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/430e7377607379161d3684b8f02363568baf79b1))
308 |
309 | ##### New Features
310 |
311 | - create rule's document ([b33fe51e](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/b33fe51ea885b22a07e1bfb251b1d9a2c3202ac8))
312 |
313 | ##### Refactors
314 |
315 | - change lint error message ([f3ad7b92](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/f3ad7b92c3437f31b896c59632010162d79c8608))
316 |
317 | ### 0.1.0 (2018-12-02)
318 |
319 | ##### Documentation Changes
320 |
321 | - change eslint sample ([817154b8](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/817154b835fca464810c4c7231b7ead7bdb87e5c))
322 | - add rodemap in README ([b57fd8e6](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/b57fd8e6ad334e6a2ddc15d8d41e9bcf644526d7))
323 | - add github ISSUE_TEMPLATE ([b23aa9e5](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/b23aa9e5994cf69f526aaa7ce38f5e5d6546eee9))
324 |
325 | ##### New Features
326 |
327 | - add fix target static-query ([a625d05a](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/a625d05a66030af4bd8388a70117b1f0af829d9a))
328 |
329 | #### 0.0.7 (2018-12-01)
330 |
331 | ##### Documentation Changes
332 |
333 | - add status badge ([bbf1b320](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/bbf1b320874c7b1d19034f2c445c8523fe0bf7ce))
334 | - add how to commit ([bcfca529](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/bcfca5297e76d5a2a71370018068f9a4c2684691))
335 |
336 | ##### Refactors
337 |
338 | - update yarn.lock ([fc10e8f1](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/fc10e8f1bb4fc33e5ca5a7ddc45ca28f851e1d96))
339 | - remove unused package ([59fc8594](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/59fc85947035a99ceaafab4c23ad73e7361b4dcc))
340 |
341 | #### 0.0.6 (2018-12-01)
342 |
343 | ##### Refactors
344 |
345 | - add keywords ([0f77b502](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/0f77b5029370685d19eaaf0db77bea0745f90862))
346 |
347 | #### 0.0.5 (2018-11-30)
348 |
349 | ##### Documentation Changes
350 |
351 | - refactor README.md ([3994d35d](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/3994d35d844a6358d389ff43d18a5e0dd7963976))
352 |
353 | #### 0.0.4 (2018-11-30)
354 |
355 | ##### Bug Fixes
356 |
357 | - fix main field in package.json ([ecfece73](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/ecfece73a308eaadc7f9c5e88b2fa4e40aa1f1a0))
358 |
359 | #### 0.0.3 (2018-11-30)
360 |
361 | ##### Documentation Changes
362 |
363 | - fix example code in README.md ([09d4beb5](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/09d4beb55913fb634ddab70e1576282fa46c143e))
364 |
365 | #### 0.0.2 (2018-11-30)
366 |
367 | ##### Continuous Integration
368 |
369 | - fix script on travis ([bc306993](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/bc3069938fa7f805f8dcc290a67cbf41e9248597))
370 |
371 | ##### Documentation Changes
372 |
373 | - **CHANGELOG.md:** :bookmark: updated CHANGELOG.md ([7394b001](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/7394b0011522b97633c04f30e2491b707e877b59))
374 |
375 | ##### Code Style Changes
376 |
377 | - style package.json ([1ac6e456](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/1ac6e4561b798617f287fad1c26b11db22b514b2))
378 |
379 | #### 0.0.2 (2018-11-30)
380 |
381 | ##### Continuous Integration
382 |
383 | - fix script on travis ([bc306993](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/bc3069938fa7f805f8dcc290a67cbf41e9248597))
384 |
385 | #### 0.0.1 (2018-11-30)
386 |
387 | ##### Documentation Changes
388 |
389 | - add CONTRIBUTING, refactor README ([7330862b](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/7330862b2efc3c96a743e4ee1668271b3a81a978))
390 | - add README ([9bedce05](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/9bedce05051a2478910e458f7e6bfe286c937b66))
391 |
392 | ##### New Features
393 |
394 | - add rule page-query ([4462d0d6](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/4462d0d69187f7991cafa69099522079203a6605))
395 | - first commit ([5986a6ef](https://github.com/tyankatsu0105/eslint-plugin-gridsome/commit/5986a6efe04cf7dc84b9b3f93d700c42b9a229c5))
396 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Setup
2 |
3 | ## Generate files
4 |
5 | if you want to create a new rule, use this command.
6 | This command use [Hygen](https://www.hygen.io/).
7 |
8 | ```bash
9 | $ npm run gen:rule
10 | ```
11 |
12 | ## Development new rule
13 |
14 | Development your awesome rule! :wrench:
15 |
16 | ### Create log file(optional)
17 |
18 | If you want to check AST, use this command.
19 | `log` folder is created by Hygen.
20 | This folder is already added that gitignore.
21 | AST is outputed to `log/log.json`.
22 |
23 | ```bash
24 | $ npm run gen:log
25 | $ npm run log
26 | ```
27 |
28 | ## test
29 |
30 | When write your rule's test, use this command.
31 | This command watch `tests/lib/rules`.
32 |
33 | ```bash
34 | $ npm run test
35 | ```
36 |
37 | ## commit
38 |
39 | If you want to use git commit, use this command.
40 | This command use [Commitizen](http://commitizen.github.io/cz-cli/).
41 | Commitizen's commit template is `cz-conventional-changelog`
42 |
43 | ```bash
44 | $ npm run commit
45 | ```
46 |
47 | # development directory
48 |
49 | If you confirm rules in `lib/rules`, generate `development` directory with `npm run gen:development`.
50 | And then `npm run confirm`.
51 |
52 | # Did you contribute to eslint-plugin-gridsome❓
53 |
54 | Great!!
55 | You can add contributors list with [allcontributors](https://allcontributors.org/).
56 | Example:
57 |
58 | ```bash
59 | npx all-contributors add tyankatsu0105 code,doc,maintenance,test
60 | ```
61 |
62 | Then, send PR.
63 |
64 | Also check [this](https://allcontributors.org/docs/en/emoji-key).
65 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018-present, tyankatsu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |

2 |
3 | eslint-plugin-gridsome
4 |
5 | This is ESlint plugin for Gridsome.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | ## 📖Documentation
25 |
26 | See [the our documentation site](https://eslint.gridsome.org/).
27 |
28 | ## 💻Contributing
29 |
30 | Create GitHub issue/PR.
31 | You can see [how to contribute](https://github.com/gridsome/eslint-plugin-gridsome/blob/master/CONTRIBUTING.md).
32 |
33 | ## ✨Contributors
34 |
35 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
36 |
37 |
38 |
39 |
40 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
53 |
54 | ## 🔒License
55 |
56 | See the [LICENSE](https://github.com/gridsome/eslint-plugin-gridsome/blob/master/LICENSE) file.(MIT)
57 |
--------------------------------------------------------------------------------
/_hygen/generate/development/eslint.ejs.t:
--------------------------------------------------------------------------------
1 | ---
2 | to: development/.eslintrc.js
3 | ---
4 | module.exports = {
5 | root: true,
6 | env: {
7 | node: true,
8 | es6: true
9 | },
10 | parser: "vue-eslint-parser",
11 | rules: {
12 | "format-query-block": 2,
13 | "require-g-image-src": 2,
14 | "require-g-link-to": 2
15 | }
16 | };
--------------------------------------------------------------------------------
/_hygen/generate/development/test.ejs.t:
--------------------------------------------------------------------------------
1 | ---
2 | to: development/test.vue
3 | ---
4 |
5 |
6 | link
7 |
8 |
9 |
10 |
11 |
12 |
13 | query Blog {
14 | allWordPressPost(limit: 5) {
15 | edges {
16 | node {
17 | id
18 | title
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/_hygen/generate/log/eslint.ejs.t:
--------------------------------------------------------------------------------
1 | ---
2 | to: log/.eslintrc.js
3 | ---
4 | module.exports = {
5 | root: true,
6 | env: {
7 | node: true,
8 | es6: true
9 | },
10 | parser: "vue-eslint-parser",
11 | parserOptions: {
12 | "sourceType": "module",
13 | },
14 | rules: {
15 | log: 2
16 | }
17 | };
18 |
--------------------------------------------------------------------------------
/_hygen/generate/log/log.ejs.t:
--------------------------------------------------------------------------------
1 | ---
2 | to: log/rules/log.js
3 | ---
4 | "use strict";
5 |
6 | /**
7 | * Remove `parent` proeprties from the given AST.
8 | * @param {string} key The key.
9 | * @param {any} value The value of the key.
10 | * @returns {any} The value of the key to output.
11 | */
12 | function replacer(key, value) {
13 | if (key === "parent") {
14 | return undefined;
15 | }
16 | if (key === "errors" && Array.isArray(value)) {
17 | return value.map(e => ({
18 | message: e.message,
19 | index: e.index,
20 | lineNumber: e.lineNumber,
21 | column: e.column
22 | }));
23 | }
24 | return value;
25 | }
26 |
27 | module.exports = {
28 | create(context) {
29 | return {
30 | Program(node) {
31 | console.log(JSON.stringify(node, replacer, 2));
32 | }
33 | };
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/_hygen/generate/log/test.ejs.t:
--------------------------------------------------------------------------------
1 | ---
2 | to: log/tests/log.vue
3 | ---
4 |
5 |
6 |
this is text
7 |
{{ text }}
8 |
9 |
10 |
19 |
20 |
21 | query Blog {
22 | allWordPressPost (limit: 5) {
23 | edges {
24 | node {
25 | id
26 |
27 | title
28 | }
29 | }
30 | }
31 | }
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/_hygen/generate/rule/doc.ejs.t:
--------------------------------------------------------------------------------
1 | ---
2 | to: docs/rules/<%= name %>.md
3 | ---
4 | ---
5 | title: <%= name %>
6 | sidebarDepth: 0
7 | description: <%= description %>
8 | ---
9 | ## Rule's description is here (gridsome/<%= name %>)
10 |
11 | ## :book: Rule Details
12 |
13 | :-1: Examples of **incorrect** code for this rule:
14 |
15 | ```html
16 | Bad example
17 | ```
18 |
19 | :+1: Examples of **correct** code for this rule:
20 |
21 | ```html
22 | Good example
23 | ```
24 |
25 | ## :wrench: Options
26 |
27 | If this rule has option, write here.
28 |
--------------------------------------------------------------------------------
/_hygen/generate/rule/prompt.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | type: "input",
4 | name: "name",
5 | message: "New rule's name is ..."
6 | },
7 | {
8 | type: "input",
9 | name: "author",
10 | message: "This rule's author is ..."
11 | },
12 | {
13 | type: "input",
14 | name: "description",
15 | message: "This rule's brief description is ..."
16 | }
17 | ];
18 |
--------------------------------------------------------------------------------
/_hygen/generate/rule/rule.ejs.t:
--------------------------------------------------------------------------------
1 | ---
2 | to: lib/rules/<%= name %>.ts
3 | ---
4 | /**
5 | * @author <%= author %>
6 | * @copyright <%= new Date().getFullYear() %> <%= author %>. All rights reserved.
7 | * See LICENSE file in root directory for full license.
8 | */
9 |
10 | import { AST } from "vue-eslint-parser";
11 | import { createRule, defineTemplateBodyVisitor } from "../utils";
12 |
13 | type Options = {};
14 |
15 | const defaultOptions: [Options] = [{}];
16 |
17 | type MessageIds = "<%= h.changeCase.camel(name) %>";
18 | export = createRule<[Options], MessageIds>({
19 | name: "<%= name %>",
20 | meta: {
21 | docs: {
22 | description: "<%= description %>",
23 | category: "",
24 | recommended: false,
25 | },
26 | type: "",
27 | messages: {
28 | <%= h.changeCase.camel(name) %>:
29 | "",
30 | },
31 | schema: [],
32 | },
33 | defaultOptions,
34 | create(context) {
35 | return defineTemplateBodyVisitor(context, {
36 |
37 | });
38 | },
39 | });
40 |
--------------------------------------------------------------------------------
/_hygen/generate/rule/test.ejs.t:
--------------------------------------------------------------------------------
1 | ---
2 | to: tests/lib/rules/<%= name %>.spec.ts
3 | ---
4 | import { RuleTester } from "../../util";
5 |
6 | import rule from "../../../lib/rules/<%= name %>";
7 |
8 | const tester = new RuleTester({
9 | parser: "vue-eslint-parser",
10 | parserOptions: {
11 | ecmaVersion: 2017,
12 | },
13 | });
14 |
15 | tester.run("<%= name %>", rule, {
16 | valid: [
17 | ``,
18 | ],
19 | invalid: [
20 | {
21 | code: ``,
22 | errors: [
23 | {
24 | messageId: "<%= h.changeCase.camel(name) %>",
25 | },
26 | ],
27 | },
28 | ],
29 | });
30 |
--------------------------------------------------------------------------------
/assets/logo/eslint-plugin-gridsome.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsome/eslint-plugin-gridsome/9a33d8aa9e7124888a7cfd8bde62aba1dd1c723c/assets/logo/eslint-plugin-gridsome.png
--------------------------------------------------------------------------------
/assets/logo/eslint-plugin-gridsome.svg:
--------------------------------------------------------------------------------
1 |
29 |
--------------------------------------------------------------------------------
/docs/.vuepress/config.js:
--------------------------------------------------------------------------------
1 | const { rules } = require("../../dist/lib");
2 |
3 | module.exports = {
4 | title: "eslint-plugin-gridsome",
5 | description: "ESLint plugin for Gridsome",
6 | evergreen: true,
7 | head: [["link", { rel: "icon", href: "/favicon.png" }]],
8 |
9 | themeConfig: {
10 | repo: "gridsome/eslint-plugin-gridsome",
11 | docsRepo: "gridsome/eslint-plugin-gridsome",
12 | docsDir: "docs",
13 | docsBranch: "master",
14 | editLinks: true,
15 | nav: [
16 | { text: "User Guide", link: "/user-guide/" },
17 | { text: "Developer Guide", link: "/developer-guide/" },
18 | { text: "Rules", link: "/rules/" },
19 | { text: "Gridsome", link: "https://gridsome.org/" },
20 | ],
21 | sidebar: {
22 | "/rules/": ["/rules/", ...Object.keys(rules)],
23 | "/": ["/introduction/", "/user-guide/", "/developer-guide/", "/rules/"],
24 | },
25 | },
26 | };
27 |
--------------------------------------------------------------------------------
/docs/.vuepress/public/eslint-plugin-gridsome.svg:
--------------------------------------------------------------------------------
1 |
29 |
--------------------------------------------------------------------------------
/docs/.vuepress/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gridsome/eslint-plugin-gridsome/9a33d8aa9e7124888a7cfd8bde62aba1dd1c723c/docs/.vuepress/public/favicon.png
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | home: true
3 | heroImage: /eslint-plugin-gridsome.svg
4 | heroText: ESLint plugin Gridsome
5 | tagline: ESLint plugin for Gridsome
6 | actionText: Get Started →
7 | actionLink: /introduction/
8 | footer: MIT Licensed | Copyright © 2018-present Gridsome
9 | ---
10 |
--------------------------------------------------------------------------------
/docs/developer-guide/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Developer Guide
3 | ---
4 |
5 | # Developer Guide
6 |
7 | Are you interested in developing this plugin?
8 | **Great!!**
9 | We are always welcome to your help!!
10 |
11 | Please check [CONTRIBUTING.md](https://github.com/gridsome/eslint-plugin-gridsome/blob/master/CONTRIBUTING.md)
12 |
--------------------------------------------------------------------------------
/docs/introduction/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Introduction
3 | ---
4 |
5 | # Introduction
6 |
7 | Official ESLint plugin for Gridsome.
8 | This plugin helps you to check the ``, `` and `` of `.vue` files with ESLint.
9 |
10 | ## 🎁What supply eslint-plugin-gridsome does?
11 |
12 | eslint-plugin-gridsome helps you to create app with [Gridsome](https://gridsome.org/).
13 |
14 | - finds the wrong format
15 | - finds the wrong property of Gridsome's component
16 |
17 | ## 📝Changelog
18 |
19 | You can check [CHANGELOG.md](https://github.com/gridsome/eslint-plugin-gridsome/blob/master/CHANGELOG.md)
20 |
21 | ## 📜License
22 |
23 | See the [LICENSE](https://github.com/gridsome/eslint-plugin-gridsome/blob/master/LICENSE) file for license rights and limitations (MIT).
24 |
--------------------------------------------------------------------------------
/docs/rules/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Rules
3 | ---
4 |
5 |
6 |
7 | # Rules
8 |
9 | ## 🛠Available rules
10 |
11 | | Rule ID | Description | Fixable |
12 | | :--------------------------------------------------------- | :----------------------------------------------------------------------------- | :------: |
13 | | [gridsome/format-query-block](/rules/format-query-block) | Format fix for `` and `` in .vue. Using Prettier API | :wrench: |
14 | | [gridsome/require-g-image-src](/rules/require-g-image-src) | Require v-bind:src or src of `` elements | |
15 | | [gridsome/require-g-link-to](/rules/require-g-link-to) | Require v-bind:to or to of `` elements | |
16 | | [gridsome/use-env-prefix](/rules/use-env-prefix) | Use prefix `GRIDSOME_` when using process.env in browser | |
17 |
--------------------------------------------------------------------------------
/docs/rules/format-query-block.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: format-query-block
3 | sidebarDepth: 0
4 | description: Enforce consistent format style in query block ex) ``,``
5 | ---
6 |
7 | ## Enforce consistent format style in query block ex) ``,``(gridsome/format-query-block)
8 |
9 | - :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
10 |
11 | - This rule checks the consistency of a code in `` and `` tags.
12 | - This rule's formatter is [Prettier](https://prettier.io). [Parser is `graphql`](https://prettier.io/docs/en/options.html#parser)
13 | - If you use `.prettierrc`, this rule follow Prettier's option at `.prettierrc`. This rule checks the option `useTabs`, `tabWidth`, and `vueIndentScriptAndStyle`.
14 |
15 | ## :book: Rule Details
16 |
17 | :-1: Examples of **incorrect** code for this rule:
18 |
19 | ```html
20 |
21 | query Blog { allWordPressPost (limit: 5) { edges { node { id title } }} }
22 |
23 | ```
24 |
25 | ```html
26 |
27 | query Example { example: examplePage(path: "/docs/example") { content }}
28 |
29 | ```
30 |
31 | :+1: Examples of **correct** code for this rule:
32 |
33 | ```html
34 |
35 | query Blog { allWordPressPost(limit: 5) { edges { node { id title } } } }
36 |
37 | ```
38 |
39 | ```html
40 |
41 | query Example { example: examplePage(path: "/docs/example") { content } }
42 |
43 | ```
44 |
45 | ## :wrench: Options
46 |
47 | ```json
48 | {
49 | "gridsome/format-query-block": [
50 | "warn",
51 | {
52 | "overridePrettierOption": {
53 | "tabWidth": 4,
54 | "vueIndentScriptAndStyle": true
55 | }
56 | }
57 | ]
58 | }
59 | ```
60 |
61 | - `overridePrettierOption` (`{ tabWidth: number; useTabs: boolean; vueIndentScriptAndStyle: boolean; }`) ... This option can override Prettier's option. Default is `{}`
62 | - [tabWidth](https://prettier.io/docs/en/options.html#tab-width)
63 | - [useTabs](https://prettier.io/docs/en/options.html#tabs)
64 | - [vueIndentScriptAndStyle](https://prettier.io/docs/en/options.html#vue-files-script-and-style-tags-indentation)
65 |
--------------------------------------------------------------------------------
/docs/rules/require-g-image-src.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: require-g-image-src
3 | sidebarDepth: 0
4 | description: Require v-bind:src or src of `` elements
5 | ---
6 |
7 | ## Require v-bind:src or src of `` elements (gridsome/require-g-image-src)
8 |
9 | ## :book: Rule Details
10 |
11 | - This rule reports the `` elements which do not have `v-bind:src` or `src`.
12 |
13 | :-1: Examples of **incorrect** code for this rule:
14 |
15 | ```html
16 |
17 |
18 |
19 |
20 |
21 |
22 | ```
23 |
24 | :+1: Examples of **correct** code for this rule:
25 |
26 | ```html
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | ```
35 |
36 | ## :wrench: Options
37 |
38 | Nothing.
39 |
--------------------------------------------------------------------------------
/docs/rules/require-g-link-to.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: require-g-link-to
3 | sidebarDepth: 0
4 | description: Require v-bind:to or to of `` elements
5 | ---
6 |
7 | ## Require v-bind:to or to of `` elements (gridsome/require-g-link-to)
8 |
9 | ## :book: Rule Details
10 |
11 | - This rule reports the `` elements which do not have `v-bind:to`, `to` or `v-bind:href`, `href`.
12 |
13 | :-1: Examples of **incorrect** code for this rule:
14 |
15 | ```html
16 |
17 |
18 | link is here
19 |
20 |
21 | ```
22 |
23 | :+1: Examples of **correct** code for this rule:
24 |
25 | ```html
26 |
27 |
28 | link is here
29 | link is here
30 | link is here
31 | link is here
32 | link is here
33 | link is here
34 |
35 |
36 | ```
37 |
38 | ## :wrench: Options
39 |
40 | Nothing.
41 |
--------------------------------------------------------------------------------
/docs/rules/use-env-prefix.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: use-env-prefix
3 | sidebarDepth: 0
4 | description: Use prefix `GRIDSOME_` when using process.env in browser
5 | ---
6 |
7 | ## Use prefix `GRIDSOME_` when using process.env in browser (gridsome/use-env-prefix)
8 |
9 | ## :book: Rule Details
10 |
11 | - This rule reports the `process.env` expression which do not include prefix `GRIDSOME_`.
12 |
13 | If you want to know more information, see: [Environment variables](https://gridsome.org/docs/environment-variables/)
14 |
15 | :-1: Examples of **incorrect** code for this rule:
16 |
17 | ```html
18 |
19 |
20 |
29 | ```
30 |
31 | :+1: Examples of **correct** code for this rule:
32 |
33 | ```html
34 |
35 |
36 |
45 | ```
46 |
47 | ## :wrench: Options
48 |
49 | ```json
50 | {
51 | "gridsome/use-env-prefix": [
52 | "warn",
53 | {
54 | {
55 | "pathsForBrowserfile": ["src/**/*"],
56 | "envPath": ".env",
57 | },
58 | }
59 | ]
60 | }
61 | ```
62 |
63 | - `pathsForBrowserfile` (`string[]`) ... This option can specify paths for browser.
64 | - default ... ["src/**/*"]
65 | - `envPath` (`string`) ... This option can specify path for env file.
66 | - default ... ".env"
67 |
--------------------------------------------------------------------------------
/docs/user-guide/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: User Guide
3 | ---
4 |
5 | # User Guide
6 |
7 | ## 💿Installation
8 |
9 | ```bash
10 | npm install eslint eslint-plugin-gridsome vue-eslint-parser -D
11 | ```
12 |
13 | ::: tip
14 | There is a reason to install `vue-eslint-parser`.
15 | eslint-plugin-gridsome has been using vue-eslint-parser over the ^6.0.4 version.
16 | If you want to use other eslint plugin package, be careful vue-eslint-parser's version.
17 | :::
18 |
19 | ## 💻Usage
20 |
21 | ### plugins
22 |
23 | Example **.eslintrc.js**:
24 |
25 | ```javascript
26 | module.exports = {
27 | parser: "vue-eslint-parser",
28 | plugins: ["gridsome"],
29 | rules: {
30 | "gridsome/format-query-block": "error"
31 | ...
32 | },
33 | };
34 | ```
35 |
36 | ### extends
37 |
38 | You also can use [extends](https://eslint.org/docs/user-guide/configuring#using-the-configuration-from-a-plugin).
39 |
40 | ```diff
41 | module.exports = {
42 | parser: "vue-eslint-parser",
43 | + extends: ["plugin:gridsome/recommended"],
44 | - plugins: ["gridsome"],
45 | - rules: {
46 | - "gridsome/format-query-block": "error"
47 | - ...
48 | - },
49 | };
50 | ```
51 |
52 | Available extends:
53 |
54 | - [gridsome/recommended](https://github.com/gridsome/eslint-plugin-gridsome/blob/45395586e812167f1c1eb7e9c02d4e4a86b2b9ff/lib/configs/recommended.js)
55 |
--------------------------------------------------------------------------------
/lib/configs.ts:
--------------------------------------------------------------------------------
1 | import recommended from "./configs/recommended";
2 |
3 | export const configs = {
4 | recommended,
5 | };
6 |
--------------------------------------------------------------------------------
/lib/configs/base.ts:
--------------------------------------------------------------------------------
1 | export = {
2 | parser: "vue-eslint-parser",
3 | parserOptions: {
4 | sourceType: "module",
5 | ecmaFeatures: {
6 | jsx: true,
7 | },
8 | },
9 | plugins: ["gridsome"],
10 | };
11 |
--------------------------------------------------------------------------------
/lib/configs/recommended.ts:
--------------------------------------------------------------------------------
1 | export = {
2 | extends: require.resolve("./base"),
3 | rules: {
4 | "gridsome/format-query-block": "warn",
5 | "gridsome/require-g-image-src": "error",
6 | "gridsome/require-g-link-to": "warn",
7 | "gridsome/use-env-prefix": "warn",
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/lib/index.ts:
--------------------------------------------------------------------------------
1 | import { rules } from "./rules";
2 | import { configs } from "./configs";
3 |
4 | export = {
5 | rules,
6 | configs,
7 | };
8 |
--------------------------------------------------------------------------------
/lib/rules.ts:
--------------------------------------------------------------------------------
1 | // This file has been automatically generated, in order to update it's content execute "npm run update"
2 | import formatQueryBlock from "./rules/format-query-block";
3 | import requireGImageSrc from "./rules/require-g-image-src";
4 | import requireGLinkTo from "./rules/require-g-link-to";
5 | import useEnvPrefix from "./rules/use-env-prefix";
6 |
7 | export const rules = {
8 | "format-query-block": formatQueryBlock,
9 | "require-g-image-src": requireGImageSrc,
10 | "require-g-link-to": requireGLinkTo,
11 | "use-env-prefix": useEnvPrefix,
12 | };
13 |
--------------------------------------------------------------------------------
/lib/rules/format-query-block.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author tyankatsu
3 | * @copyright 2018 tyankatsu. All rights reserved.
4 | * See LICENSE file in root directory for full license.
5 | */
6 |
7 | import { AST } from "vue-eslint-parser";
8 | import {
9 | createRule,
10 | getPrettierDefaultOption,
11 | getPrettierRcOption,
12 | getMergedPrettierOption,
13 | getCodeWrapIndentInfo,
14 | NodeNames,
15 | OverridePrettierOption,
16 | } from "../utils";
17 |
18 | import prettier from "prettier";
19 |
20 | const prettierParser = "graphql";
21 | const LINES = /[^\r\n\u2028\u2029]+(?:$|\r\n|[\r\n\u2028\u2029])|\s/gu;
22 |
23 | type Options = {
24 | overridePrettierOption?: OverridePrettierOption;
25 | };
26 |
27 | const defaultOptions: [Options] = [{}];
28 |
29 | type MessageIds = "formatQueryBlock";
30 | export = createRule<[Options], MessageIds>({
31 | name: "format-query-block",
32 | meta: {
33 | docs: {
34 | description:
35 | "Format fix for `` and `` in .vue. Using Prettier API",
36 | category: "Stylistic Issues",
37 | recommended: false,
38 | },
39 | type: "layout",
40 | fixable: "whitespace",
41 | messages: {
42 | formatQueryBlock: "{{ name }} code format is incorrect",
43 | },
44 | schema: [
45 | {
46 | type: "object",
47 | properties: {
48 | overridePrettierOption: {
49 | type: "object",
50 | items: [
51 | { tabWidth: "number" },
52 | { useTabs: "boolean" },
53 | { vueIndentScriptAndStyle: "boolean" },
54 | ],
55 | },
56 | },
57 | },
58 | ],
59 | },
60 | defaultOptions,
61 | create(context) {
62 | const overridePrettierOption = context.options[0]?.overridePrettierOption;
63 |
64 | const sourceCode = context.getSourceCode();
65 | const filePath = context.getFilename();
66 |
67 | const mergedPrettierOption = getMergedPrettierOption(
68 | getPrettierDefaultOption,
69 | getPrettierRcOption(filePath)
70 | );
71 |
72 | const { indentRepeatTime, indentChar } = getCodeWrapIndentInfo(
73 | mergedPrettierOption,
74 | overridePrettierOption
75 | );
76 | const indent = indentChar.repeat(indentRepeatTime);
77 |
78 | return {
79 | Program(node: AST.ESLintProgram) {
80 | if (!node.templateBody) {
81 | return;
82 | }
83 |
84 | const topLevelNodes = node.templateBody.parent.children;
85 |
86 | for (const topLevelNode of topLevelNodes) {
87 | if (
88 | topLevelNode.type === "VElement" &&
89 | (topLevelNode.name === NodeNames["page-query"] ||
90 | topLevelNode.name === NodeNames["static-query"])
91 | ) {
92 | const codeRange: AST.OffsetRange = [
93 | topLevelNode.startTag.range[1],
94 | topLevelNode.endTag
95 | ? topLevelNode.endTag.range[0]
96 | : topLevelNode.range[1],
97 | ];
98 |
99 | const code = sourceCode.text.slice(...codeRange);
100 |
101 | const prettierConfig = {
102 | ...getPrettierRcOption(filePath),
103 | ...overridePrettierOption,
104 | };
105 |
106 | const formattedCode = prettier
107 | .format(code, { ...prettierConfig, parser: prettierParser })
108 | .trim();
109 |
110 | let lines = formattedCode.match(LINES);
111 |
112 | if (lines === null) {
113 | return;
114 | }
115 | lines = ["\n", ...lines, "\n"];
116 |
117 | const wrappedIndentCode = lines
118 | .map((line) => {
119 | if (line === "\n") {
120 | return line;
121 | }
122 | return indent + line;
123 | })
124 | .join("");
125 |
126 | if (wrappedIndentCode !== code) {
127 | context.report({
128 | messageId: "formatQueryBlock",
129 | data: {
130 | name: topLevelNode.name,
131 | },
132 | node: topLevelNode,
133 | loc: topLevelNode.loc,
134 |
135 | fix(fixer) {
136 | return fixer.replaceTextRange(codeRange, wrappedIndentCode);
137 | },
138 | });
139 | }
140 | }
141 | }
142 | },
143 | };
144 | },
145 | });
146 |
--------------------------------------------------------------------------------
/lib/rules/require-g-image-src.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author tyankatsu
3 | * @copyright 2019 tyankatsu. All rights reserved.
4 | * See LICENSE file in root directory for full license.
5 | */
6 |
7 | import { AST } from "vue-eslint-parser";
8 | import {
9 | createRule,
10 | defineTemplateBodyVisitor,
11 | hasAttribute,
12 | hasDirective,
13 | } from "../utils";
14 |
15 | type Options = {};
16 |
17 | const defaultOptions: [Options] = [{}];
18 |
19 | type MessageIds = "requireGImageSrc";
20 | export = createRule<[Options], MessageIds>({
21 | name: "require-g-image-src",
22 | meta: {
23 | docs: {
24 | description: "Require v-bind:src or src of `` elements",
25 | category: "Possible Errors",
26 | recommended: false,
27 | },
28 | type: "problem",
29 | messages: {
30 | requireGImageSrc:
31 | "Expected '' elements to have 'v-bind:src' or 'src'.",
32 | },
33 | schema: [],
34 | },
35 | defaultOptions,
36 | create(context) {
37 | return defineTemplateBodyVisitor(context, {
38 | "VElement[name='g-image']"(node: AST.VElement) {
39 | if (!hasAttribute(node, "src") && !hasDirective(node, "bind", "src")) {
40 | context.report({
41 | node,
42 | loc: node.loc,
43 | messageId: "requireGImageSrc",
44 | });
45 | }
46 | },
47 | });
48 | },
49 | });
50 |
--------------------------------------------------------------------------------
/lib/rules/require-g-link-to.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author tyankatsu
3 | * @copyright 2019 tyankatsu. All rights reserved.
4 | * See LICENSE file in root directory for full license.
5 | */
6 |
7 | import { AST } from "vue-eslint-parser";
8 | import {
9 | createRule,
10 | defineTemplateBodyVisitor,
11 | hasAttribute,
12 | hasDirective,
13 | } from "../utils";
14 |
15 | type Options = {};
16 |
17 | const defaultOptions: [Options] = [{}];
18 |
19 | type MessageIds = "requireGLinkTo";
20 |
21 | const statementTo = (node: AST.VElement) =>
22 | !hasAttribute(node, "to") && !hasDirective(node, "bind", "to");
23 | const statementHref = (node: AST.VElement) =>
24 | !hasAttribute(node, "href") && !hasDirective(node, "bind", "href");
25 |
26 | export = createRule<[Options], MessageIds>({
27 | name: "require-g-link-to",
28 | meta: {
29 | docs: {
30 | description: "Require v-bind:to or to of `` elements",
31 | category: "Possible Errors",
32 | recommended: false,
33 | },
34 | type: "problem",
35 | messages: {
36 | requireGLinkTo:
37 | "Expected '' elements to have 'v-bind:to', 'to' or 'v-bind:href', 'href'.",
38 | },
39 | schema: [],
40 | },
41 | defaultOptions,
42 | create(context) {
43 | return defineTemplateBodyVisitor(context, {
44 | "VElement[name='g-link']"(node: AST.VElement) {
45 | if (statementTo(node) && statementHref(node)) {
46 | context.report({
47 | node,
48 | loc: node.loc,
49 | messageId: "requireGLinkTo",
50 | });
51 | }
52 | },
53 | });
54 | },
55 | });
56 |
--------------------------------------------------------------------------------
/lib/rules/use-env-prefix.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @author tyankatsu
3 | * @copyright 2020 tyankatsu. All rights reserved.
4 | * See LICENSE file in root directory for full license.
5 | */
6 | import { AST } from "vue-eslint-parser";
7 | import minimatch from "minimatch";
8 | import { createRule, Env, getPathFromProjectRoot } from "../utils";
9 | import * as Fs from "fs";
10 |
11 | const PREFIX = "GRIDSOME_";
12 |
13 | type Options = {
14 | pathsForBrowserfile?: string[];
15 | envPath?: string;
16 | };
17 |
18 | const defaultOptions: [Options] = [{}];
19 |
20 | type MessageIds = "useEnvPrefix";
21 | export = createRule<[Options], MessageIds>({
22 | name: "use-env-prefix",
23 | meta: {
24 | docs: {
25 | description: "Use prefix `GRIDSOME_` when using process.env in browser",
26 | category: "Possible Errors",
27 | recommended: false,
28 | },
29 | type: "problem",
30 | messages: {
31 | useEnvPrefix: "Use `process.env.{{ addedPrefixEnv }}`.",
32 | },
33 | schema: [
34 | {
35 | type: "object",
36 | properties: {
37 | pathsForBrowserfile: {
38 | type: "array",
39 | items: {
40 | type: "string",
41 | },
42 | },
43 | envPath: {
44 | type: "string",
45 | },
46 | },
47 | },
48 | ],
49 | },
50 | defaultOptions,
51 | create(context) {
52 | const path = getPathFromProjectRoot(context.getFilename(), process.cwd());
53 |
54 | const options = {
55 | pathsForBrowserfile: context.options[0]?.pathsForBrowserfile || [
56 | "src/**/*",
57 | ],
58 | envPath: context.options[0]?.envPath || ".env",
59 | };
60 |
61 | const isClientfile = options.pathsForBrowserfile.some((clientPath) =>
62 | minimatch(path, clientPath)
63 | );
64 |
65 | if (!Fs.existsSync(options.envPath)) return {};
66 | const envSource = Fs.readFileSync(options.envPath, { encoding: "utf8" });
67 |
68 | const parsedEnvSource = new Env(envSource).parse();
69 |
70 | return {
71 | "MemberExpression[object.object.name='process'][object.property.name='env']"(
72 | node: AST.ESLintMemberExpression
73 | ) {
74 | if (!isClientfile) return;
75 | if (node.property.type !== "Identifier") return;
76 | if (node.property.name.includes(PREFIX)) return;
77 |
78 | const envName = node.property.name;
79 |
80 | if (parsedEnvSource.has(envName)) {
81 | context.report({
82 | node,
83 | loc: node.loc,
84 | messageId: "useEnvPrefix",
85 | data: {
86 | addedPrefixEnv: `${PREFIX}${envName}`,
87 | },
88 | });
89 | }
90 | },
91 | };
92 | },
93 | });
94 |
--------------------------------------------------------------------------------
/lib/utils/attribute.ts:
--------------------------------------------------------------------------------
1 | import { AST } from "vue-eslint-parser";
2 |
3 | /**
4 | * Get the attribute which has the given name.
5 | */
6 | export const getAttribute = (
7 | node: AST.VElement,
8 | name: string,
9 | value?: string
10 | ) =>
11 | node.startTag.attributes.find(
12 | (a) =>
13 | !a.directive &&
14 | a.key.name === name &&
15 | (value === undefined || (a.value != null && a.value.value === value))
16 | );
17 |
18 | /**
19 | * Check whether the given start tag has specific directive.
20 | */
21 | export const hasAttribute = (
22 | node: AST.VElement,
23 | name: string,
24 | value?: string
25 | ) => Boolean(getAttribute(node, name, value));
26 |
--------------------------------------------------------------------------------
/lib/utils/create-rule.ts:
--------------------------------------------------------------------------------
1 | import { RuleCreator } from "./rule-creator";
2 |
3 | // eslint-disable-next-line new-cap
4 | export const createRule = RuleCreator(
5 | (name) =>
6 | `https://github.com/gridsome/eslint-plugin-gridsome/blob/master/docs/rules/${name}.md`
7 | );
8 |
--------------------------------------------------------------------------------
/lib/utils/directive.ts:
--------------------------------------------------------------------------------
1 | import { AST } from "vue-eslint-parser";
2 |
3 | /**
4 | * Get the directive which has the given name.
5 | * @param {ASTNode} node The start tag node to check.
6 | * @param {string} name The directive name to check.
7 | * @param {string} [argument] The directive argument to check.
8 | * @returns {ASTNode} The found directive.
9 | */
10 | export const getDirective = (
11 | node: AST.VElement,
12 | name: string,
13 | argument: string
14 | ) =>
15 | node.startTag.attributes.find(
16 | (a) =>
17 | a.directive &&
18 | a.key.name.name === name &&
19 | (argument === undefined ||
20 | (a.key.argument &&
21 | a.key.argument.type === "VIdentifier" &&
22 | a.key.argument.name) === argument)
23 | );
24 |
25 | /**
26 | * Check whether the given start tag has specific directive.
27 | * @param {ASTNode} node The start tag node to check.
28 | * @param {string} name The directive name to check.
29 | * @param {string} [argument] The directive argument to check.
30 | * @returns {boolean} `true` if the start tag has the directive.
31 | */
32 | export const hasDirective = (
33 | node: AST.VElement,
34 | name: string,
35 | argument: string
36 | ) => Boolean(getDirective(node, name, argument));
37 |
--------------------------------------------------------------------------------
/lib/utils/env.ts:
--------------------------------------------------------------------------------
1 | const COMMENT_PREFIX = "#";
2 | const SEPARATER_COMMENT = "=";
3 | const SEPARATER_SPACE = /( | )+/;
4 | const NEWLINES = /\n|\r|\r\n/;
5 |
6 | const isCommentCode = (line: string) => line.charAt(0) === COMMENT_PREFIX;
7 |
8 | export class Env {
9 | constructor(private source: string) {}
10 |
11 | public parse() {
12 | const result = new Map();
13 |
14 | this.source
15 | .toString()
16 | .trim()
17 | .split(NEWLINES)
18 | .forEach((line) => {
19 | const trimmedLine = line.trim();
20 |
21 | if (isCommentCode(trimmedLine)) return;
22 |
23 | const [key, ...value] = trimmedLine.split(SEPARATER_COMMENT);
24 | const joinedValue = value
25 | .join(SEPARATER_COMMENT)
26 | .split(SEPARATER_SPACE)[0];
27 |
28 | result.set(key, joinedValue);
29 | });
30 |
31 | return result;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/lib/utils/get-code-wrap-indent-info.ts:
--------------------------------------------------------------------------------
1 | import prettier from "prettier";
2 |
3 | import { MergedPrettierOption } from "./get-prettier-option";
4 | import { PrettierSupportOptionName } from "./types";
5 |
6 | const indent = {
7 | space: " ",
8 | tab: "\t",
9 | none: "",
10 | };
11 |
12 | export type OverridePrettierOption =
13 | | {
14 | tabWidth?: number;
15 | useTabs?: boolean;
16 | vueIndentScriptAndStyle?: boolean;
17 | }
18 | | undefined;
19 |
20 | type PrettierOptions = {
21 | [key in PrettierSupportOptionName]: prettier.SupportOption["default"];
22 | };
23 |
24 | /**
25 | * Get indent information
26 | */
27 | export const getCodeWrapIndentInfo = (
28 | mergedPrettierOptions: MergedPrettierOption,
29 | eslintOption?: OverridePrettierOption
30 | ) => {
31 | const defaultInfo = {
32 | indentRepeatTime: 0,
33 | indentChar: indent.space,
34 | };
35 |
36 | const prettierOptions = mergedPrettierOptions as PrettierOptions;
37 |
38 | const tabWidth = eslintOption?.tabWidth || prettierOptions.tabWidth;
39 | const useTabs = eslintOption?.useTabs ?? prettierOptions.useTabs;
40 | const vueIndentScriptAndStyle =
41 | eslintOption?.vueIndentScriptAndStyle ??
42 | prettierOptions.vueIndentScriptAndStyle;
43 |
44 | const result = {
45 | indentRepeatTime: tabWidth as number,
46 | indentChar: defaultInfo.indentChar,
47 | };
48 |
49 | if (useTabs) {
50 | result.indentRepeatTime = 1;
51 | result.indentChar = indent.tab;
52 | }
53 |
54 | if (!vueIndentScriptAndStyle) {
55 | result.indentRepeatTime = 0;
56 | result.indentChar = indent.none;
57 | }
58 |
59 | return { ...defaultInfo, ...result };
60 | };
61 |
--------------------------------------------------------------------------------
/lib/utils/get-prettier-option.ts:
--------------------------------------------------------------------------------
1 | import prettier from "prettier";
2 |
3 | type PrettierOptions = {
4 | [key: string]: prettier.SupportOption["default"];
5 | };
6 |
7 | /**
8 | * Get Prettier's default option
9 | */
10 | export const getPrettierDefaultOption = prettier
11 | .getSupportInfo()
12 | .options.reduce((acc, option) => {
13 | acc[option.name] = option.default;
14 | return acc;
15 | }, {});
16 |
17 | // /**
18 | // * Get option from .prettierrc
19 | // */
20 | export const getPrettierRcOption = (filePath: string) =>
21 | prettier.resolveConfig.sync(filePath, {
22 | editorconfig: true,
23 | }) as PrettierOptions | null;
24 |
25 | // /**
26 | // * Get option merged getPrettierDefaultOption and getPrettierRcOption
27 | // */
28 | export const getMergedPrettierOption = (
29 | prettierDefaultOption: typeof getPrettierDefaultOption,
30 | prettierRcOption: ReturnType
31 | ) => ({
32 | ...prettierDefaultOption,
33 | ...prettierRcOption,
34 | });
35 |
36 | export type MergedPrettierOption = ReturnType;
37 |
--------------------------------------------------------------------------------
/lib/utils/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./types";
2 | export * from "./create-rule";
3 | export * from "./parser-services";
4 |
5 | // ====================================================
6 | // Prettier
7 | // ====================================================
8 | export * from "./get-prettier-option";
9 | export * from "./get-code-wrap-indent-info";
10 |
11 | // ====================================================
12 | // AST
13 | // ====================================================
14 | export * from "./attribute";
15 | export * from "./directive";
16 |
17 | // ====================================================
18 | // env
19 | // ====================================================
20 | export * from "./env";
21 |
22 | // ====================================================
23 | // others
24 | // ====================================================
25 | export * from "./path";
26 |
--------------------------------------------------------------------------------
/lib/utils/parser-services.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @see https://github.com/mysticatea/vue-eslint-parser/blob/master/src/parser-services.ts
3 | */
4 |
5 | import { TemplateBodyVisitor, ScriptVisitor } from "./types";
6 |
7 | export const defineTemplateBodyVisitor = (
8 | context: any,
9 | templateBodyVisitor?: TemplateBodyVisitor,
10 | scriptVisitor?: ScriptVisitor
11 | ) =>
12 | context.parserServices.defineTemplateBodyVisitor(
13 | templateBodyVisitor,
14 | scriptVisitor
15 | );
16 |
--------------------------------------------------------------------------------
/lib/utils/path.ts:
--------------------------------------------------------------------------------
1 | export const getPathFromProjectRoot = (filename: string, cwd: string) =>
2 | filename.split("/").splice(cwd.split("/").length).join("/");
3 |
--------------------------------------------------------------------------------
/lib/utils/rule-creator.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/experimental-utils/src/eslint-utils/RuleCreator.ts
3 | */
4 | import { TSESLint, ESLintUtils } from "@typescript-eslint/experimental-utils";
5 | import { RuleContext, RuleListener } from "./types";
6 |
7 | // we'll automatically add the url + tslint description for people.
8 | type CreateRuleMetaDocs = Omit;
9 | export type CreateRuleMeta = {
10 | docs: CreateRuleMetaDocs;
11 | } & Omit, "docs">;
12 |
13 | export const RuleCreator = (urlCreator: (ruleName: string) => string) =>
14 | function createRule<
15 | TOptions extends readonly unknown[],
16 | TMessageIds extends string,
17 | TRuleListener extends RuleListener = RuleListener
18 | >({
19 | name,
20 | meta,
21 | defaultOptions,
22 | create,
23 | }: {
24 | name: string;
25 | meta: CreateRuleMeta;
26 | defaultOptions: TOptions;
27 | create: (
28 | context: RuleContext,
29 | optionsWithDefault: TOptions
30 | ) => TRuleListener;
31 | }) {
32 | return {
33 | meta: {
34 | ...meta,
35 | docs: {
36 | ...meta.docs,
37 | url: urlCreator(name),
38 | },
39 | },
40 | create(context: RuleContext): TRuleListener {
41 | const optionsWithDefault = ESLintUtils.applyDefault(
42 | defaultOptions,
43 | context.options
44 | );
45 | return create(context, optionsWithDefault);
46 | },
47 | };
48 | };
49 |
--------------------------------------------------------------------------------
/lib/utils/types/Node.ts:
--------------------------------------------------------------------------------
1 | export const NodeNames = {
2 | template: "template",
3 | script: "script",
4 | style: "style",
5 |
6 | "page-query": "page-query",
7 | "static-query": "static-query",
8 | } as const;
9 |
--------------------------------------------------------------------------------
/lib/utils/types/Parser.ts:
--------------------------------------------------------------------------------
1 | import { AST } from "vue-eslint-parser";
2 | import { TSESLint, TSESTree } from "@typescript-eslint/experimental-utils";
3 |
4 | export type VueEslintParserNodeTypes = AST.Node["type"];
5 |
6 | export type TemplateBodyVisitor = {
7 | [key in VueEslintParserNodeTypes]?: TSESLint.RuleFunction<
8 | AST.Node & TSESTree.BaseNode
9 | >;
10 | } & { [nodeSelector: string]: TSESLint.RuleFunction | undefined };
11 |
12 | export type ScriptVisitor = { [key: string]: (...args: any) => void };
13 |
--------------------------------------------------------------------------------
/lib/utils/types/Prettier.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @see https://prettier.io/docs/en/options.html
3 | */
4 | type PrettierDefaultOptionName =
5 | | "arrowParens"
6 | | "bracketSpacing"
7 | | "cursorOffset"
8 | | "endOfLine"
9 | | "filepath"
10 | | "htmlWhitespaceSensitivity"
11 | | "insertPragma"
12 | | "jsxBracketSameLine"
13 | | "jsxSingleQuote"
14 | | "parser"
15 | | "pluginSearchDirs"
16 | | "plugins"
17 | | "printWidth"
18 | | "proseWrap"
19 | | "quoteProps"
20 | | "rangeEnd"
21 | | "rangeStart"
22 | | "requirePragma"
23 | | "semi"
24 | | "singleQuote"
25 | | "tabWidth"
26 | | "trailingComma"
27 | | "useTabs"
28 | | "vueIndentScriptAndStyle";
29 |
30 | /**
31 | * Note: If eslint-plugin-gridsome supoprts prettier's plugin, define type like PrettierDefaultOptionName. Then, merge type at this type.
32 | */
33 | export type PrettierSupportOptionName = PrettierDefaultOptionName;
34 |
--------------------------------------------------------------------------------
/lib/utils/types/Rule.ts:
--------------------------------------------------------------------------------
1 | import { AST } from "vue-eslint-parser";
2 | import { TSESTree } from "@typescript-eslint/experimental-utils";
3 |
4 | /**
5 | * @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/experimental-utils/src/ts-eslint/Rule.ts
6 | */
7 |
8 | interface RuleFix {
9 | range: AST.OffsetRange;
10 | text: string;
11 | }
12 |
13 | interface RuleFixer {
14 | insertTextAfter(nodeOrToken: any, text: string): RuleFix;
15 |
16 | insertTextAfterRange(range: AST.OffsetRange, text: string): RuleFix;
17 |
18 | insertTextBefore(nodeOrToken: any, text: string): RuleFix;
19 |
20 | insertTextBeforeRange(range: AST.OffsetRange, text: string): RuleFix;
21 |
22 | remove(nodeOrToken: any): RuleFix;
23 |
24 | removeRange(range: AST.OffsetRange): RuleFix;
25 |
26 | replaceText(nodeOrToken: any, text: string): RuleFix;
27 |
28 | replaceTextRange(range: AST.OffsetRange, text: string): RuleFix;
29 | }
30 |
31 | type ReportFixFunction = (fixer: RuleFixer) => any;
32 |
33 | type ReportDescriptor = {
34 | node: any;
35 | loc?: TSESTree.SourceLocation | TSESTree.LineAndColumnData;
36 | messageId: TMessageIds;
37 | data?: Record;
38 | fix?: ReportFixFunction | null;
39 |
40 | [K: string]: any;
41 | };
42 |
43 | export interface RuleContext<
44 | TMessageIds extends string,
45 | TOptions extends readonly unknown[]
46 | > {
47 | /**
48 | * The rule ID.
49 | */
50 | id: string;
51 | /**
52 | * An array of the configured options for this rule.
53 | * This array does not include the rule severity.
54 | */
55 | options: TOptions;
56 | /**
57 | * The shared settings from configuration.
58 | * We do not have any shared settings in this plugin.
59 | */
60 | settings: Record;
61 | /**
62 | * The name of the parser from configuration.
63 | */
64 | parserPath: string;
65 | /**
66 | * The parser options configured for this run
67 | */
68 | parserOptions: any;
69 | /**
70 | * An object containing parser-provided services for rules
71 | */
72 | parserServices?: any;
73 | /**
74 | * Returns an array of the ancestors of the currently-traversed node, starting at
75 | * the root of the AST and continuing through the direct parent of the current node.
76 | * This array does not include the currently-traversed node itself.
77 | */
78 | getAncestors(): any[];
79 | /**
80 | * Returns a list of variables declared by the given node.
81 | * This information can be used to track references to variables.
82 | */
83 | getDeclaredVariables(node: any): any[];
84 | /**
85 | * Returns the filename associated with the source.
86 | */
87 | getFilename(): string;
88 | /**
89 | * Returns the scope of the currently-traversed node.
90 | * This information can be used track references to variables.
91 | */
92 | getScope(): any;
93 | /**
94 | * Returns a SourceCode object that you can use to work with the source that
95 | * was passed to ESLint.
96 | */
97 | getSourceCode(): any;
98 | /**
99 | * Marks a variable with the given name in the current scope as used.
100 | * This affects the no-unused-vars rule.
101 | */
102 | markVariableAsUsed(name: string): boolean;
103 | /**
104 | * Reports a problem in the code.
105 | */
106 | report(descriptor: ReportDescriptor): void;
107 | }
108 |
109 | export type RuleListener = any;
110 |
--------------------------------------------------------------------------------
/lib/utils/types/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./Node";
2 | export * from "./Rule";
3 | export * from "./Parser";
4 | export * from "./Prettier";
5 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-plugin-gridsome",
3 | "version": "1.6.2",
4 | "keywords": [
5 | "eslint",
6 | "eslintplugin",
7 | "vue",
8 | "gridsome"
9 | ],
10 | "homepage": "https://github.com/gridsome/eslint-plugin-gridsome",
11 | "bugs": {
12 | "url": "https://github.com/gridsome/eslint-plugin-gridsome/issues"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/gridsome/eslint-plugin-gridsome.git"
17 | },
18 | "license": "MIT",
19 | "author": "tyankatsu (https://tyankatsu.netlify.com/)",
20 | "main": "dist/lib/index.js",
21 | "files": [
22 | "LICENSE",
23 | "README.md",
24 | "dist",
25 | "package.json"
26 | ],
27 | "scripts": {
28 | "_docs:build": "vuepress build docs",
29 | "_docs:dev": "vuepress dev docs",
30 | "_log:lint": "eslint log/tests/* --rulesdir log/rules",
31 | "_log:print": "run-s _log:lint > log/log.json",
32 | "build": "tsc --project ./tsconfig.build.json",
33 | "precommit": "lint-staged",
34 | "commit": "git-cz",
35 | "confirm": "eslint ./development**/* --fix --ext .vue --rulesdir dist/lib/rules",
36 | "docs:build": "run-s build _docs:build",
37 | "docs:dev": "run-s build _docs:dev",
38 | "gen:development": "hygen generate development",
39 | "gen:log": "hygen generate log",
40 | "gen:rule": "hygen generate rule",
41 | "lint-staged": "lint-staged",
42 | "log": "npm run _log:print --silent",
43 | "release": "shipjs prepare",
44 | "test": "mocha --require ts-node/register tests/lib/**/*.spec.ts",
45 | "typecheck": "tsc --project ./tsconfig.build.json --noEmit",
46 | "update": "ts-node tools/update.ts"
47 | },
48 | "lint-staged": {
49 | "*.md": [
50 | "prettier --write"
51 | ],
52 | "*.ts": [
53 | "prettier --write",
54 | "eslint --fix"
55 | ]
56 | },
57 | "dependencies": {
58 | "@typescript-eslint/experimental-utils": "^3.3.0",
59 | "minimatch": "^3.0.4",
60 | "prettier": "^2.0.5",
61 | "vue-eslint-parser": "^7.1.0"
62 | },
63 | "devDependencies": {
64 | "@types/chai": "^4.2.14",
65 | "@types/eslint": "^7.2.6",
66 | "@types/minimatch": "^3.0.3",
67 | "@types/mocha": "^8.2.0",
68 | "@types/prettier": "^2.0.0",
69 | "@typescript-eslint/eslint-plugin": "^4.11.0",
70 | "@typescript-eslint/parser": "^4.11.0",
71 | "all-contributors-cli": "^6.19.0",
72 | "chai": "^4.2.0",
73 | "change-case": "^4.1.2",
74 | "commitizen": "^4.2.2",
75 | "cz-conventional-changelog": "^3.3.0",
76 | "eslint": "^7.0.0",
77 | "eslint-config-prettier": "^7.1.0",
78 | "eslint-plugin-prettier": "^3.3.0",
79 | "hygen": "^6.0.4",
80 | "lint-staged": "^10.5.3",
81 | "mocha": "^8.2.1",
82 | "npm-run-all": "^4.1.5",
83 | "shipjs": "0.23.0",
84 | "ts-node": "^9.1.1",
85 | "typescript": "^4.1.3",
86 | "vuepress": "^1.7.1"
87 | },
88 | "peerDependencies": {
89 | "eslint": "^6.2.0 || ^7.0.0",
90 | "minimatch": "^3.0.4"
91 | },
92 | "engines": {
93 | "node": "^10.13.0 || ^12.13.0 || ^13.0.0 || >=14.0.0"
94 | },
95 | "publishConfig": {
96 | "access": "public"
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/invalid/01/code.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | query Blog {
4 | allWordPressPost(limit: 5){
5 | edges{
6 | node {
7 | id
8 | title
9 | }
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/invalid/01/output.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | query Blog {
4 | allWordPressPost(limit: 5) {
5 | edges {
6 | node {
7 | id
8 | title
9 | }
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/invalid/02/code.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | query Blog {
4 | allWordPressPost(limit: 5) {
5 | edges {
6 | node {
7 | id
8 |
9 |
10 | title
11 | }
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/invalid/02/output.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | query Blog {
4 | allWordPressPost(limit: 5) {
5 | edges {
6 | node {
7 | id
8 |
9 | title
10 | }
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/invalid/03/code.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | query Example {
4 | example: examplePage (path: "/docs/example") {
5 | content
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/invalid/03/output.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | query Example {
4 | example: examplePage(path: "/docs/example") {
5 | content
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/invalid/04/code.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | query Example {
4 | example: examplePage (path: "/docs/example") {
5 | content
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/invalid/04/output.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | query Example {
4 | example: examplePage(path: "/docs/example") {
5 | content
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/valid/01/code.vue:
--------------------------------------------------------------------------------
1 |
2 | query Blog {
3 | allWordPressPost(limit: 5) {
4 | edges {
5 | node {
6 | id
7 | title
8 | }
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/valid/02/code.vue:
--------------------------------------------------------------------------------
1 |
2 | fragment RankingParts on TourRanking {
3 | id
4 | rankings: data {
5 | rank
6 | nickname
7 | score
8 | badge: pin_badge_image_url
9 | ranking_started_at
10 | ranking_finished_at
11 | }
12 | }
13 |
14 | query($id: ID, $prevId: ID, $nextId: ID) {
15 | ranking: tourRanking(id: $id) {
16 | ...RankingParts
17 | }
18 |
19 | next: tourRanking(id: $prevId) {
20 | ...RankingParts
21 | }
22 |
23 | prev: tourRanking(id: $nextId) {
24 | ...RankingParts
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/format-query-block/valid/03/code.vue:
--------------------------------------------------------------------------------
1 |
2 | query Example {
3 | example: examplePage(path: "/docs/example") {
4 | content
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/invalid/01/.env:
--------------------------------------------------------------------------------
1 | API_URL=http://foobar
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/invalid/01/code.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/invalid/02/.env:
--------------------------------------------------------------------------------
1 | DB_USER=user
2 | DB_PASS=password
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/invalid/02/client.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | {
4 | use: '@gridsome/source-plugin',
5 | options: {
6 | username: process.env.DB_USER,
7 | password: process.env.DB_PASS
8 | }
9 | }
10 | ]
11 | }
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/valid/01/.env:
--------------------------------------------------------------------------------
1 | API_URL=http://foobar
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/valid/01/code.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/valid/02/.env:
--------------------------------------------------------------------------------
1 | DB_USER=user
2 | DB_PASS=password
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/valid/02/client.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | {
4 | use: '@gridsome/source-plugin',
5 | options: {
6 | username: process.env.GRIDSOME_DB_USER,
7 | password: process.env.GRIDSOME_DB_PASS
8 | }
9 | }
10 | ]
11 | }
--------------------------------------------------------------------------------
/tests/lib/rules/fixtures/use-env-prefix/valid/03/client.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | {
4 | use: "@gridsome/source-plugin",
5 | options: {
6 | username: "user",
7 | password: "password",
8 | },
9 | },
10 | ],
11 | };
12 |
--------------------------------------------------------------------------------
/tests/lib/rules/format-query-block.spec.ts:
--------------------------------------------------------------------------------
1 | import { RuleTester, loadFixtureCreator } from "../../util";
2 |
3 | import rule from "../../../lib/rules/format-query-block";
4 |
5 | const tester = new RuleTester({
6 | parser: "vue-eslint-parser",
7 | parserOptions: {
8 | ecmaVersion: 2017,
9 | },
10 | });
11 |
12 | const loadFixture = loadFixtureCreator(
13 | "tests/lib/rules/fixtures/format-query-block"
14 | );
15 |
16 | tester.run("format-query-block", rule, {
17 | valid: [
18 | loadFixture({ fixtureDirectory: "valid/01" }),
19 | loadFixture({ fixtureDirectory: "valid/02" }),
20 | loadFixture({ fixtureDirectory: "valid/03" }),
21 | ],
22 |
23 | // @todo add test case that exist .prettierrc or not exist, if we know how to test that
24 | invalid: [
25 | {
26 | ...loadFixture({
27 | fixtureDirectory: "invalid/01",
28 | hasOutputFile: true,
29 | }),
30 | errors: [
31 | {
32 | messageId: "formatQueryBlock",
33 | },
34 | ],
35 | },
36 | {
37 | ...loadFixture({
38 | fixtureDirectory: "invalid/02",
39 | hasOutputFile: true,
40 | }),
41 | errors: [
42 | {
43 | messageId: "formatQueryBlock",
44 | },
45 | ],
46 | },
47 | {
48 | ...loadFixture({
49 | fixtureDirectory: "invalid/03",
50 | hasOutputFile: true,
51 | }),
52 | errors: [
53 | {
54 | messageId: "formatQueryBlock",
55 | },
56 | ],
57 | },
58 | {
59 | ...loadFixture({
60 | fixtureDirectory: "invalid/04",
61 | hasOutputFile: true,
62 | }),
63 | options: [
64 | {
65 | overridePrettierOption: {
66 | vueIndentScriptAndStyle: true,
67 | tabWidth: 5,
68 | },
69 | },
70 | ],
71 | errors: [
72 | {
73 | messageId: "formatQueryBlock",
74 | },
75 | ],
76 | },
77 | ],
78 | });
79 |
--------------------------------------------------------------------------------
/tests/lib/rules/require-g-image-src.spec.ts:
--------------------------------------------------------------------------------
1 | import { RuleTester } from "../../util";
2 |
3 | import rule from "../../../lib/rules/require-g-image-src";
4 |
5 | const tester = new RuleTester({
6 | parser: "vue-eslint-parser",
7 | parserOptions: {
8 | ecmaVersion: 2017,
9 | },
10 | });
11 |
12 | tester.run("require-g-image-src", rule, {
13 | valid: [
14 | `
15 |
16 |
21 | `,
22 | ],
23 | invalid: [
24 | {
25 | code: `
26 |
27 |
31 | `,
32 | errors: [
33 | {
34 | messageId: "requireGImageSrc",
35 | },
36 | ],
37 | },
38 | ],
39 | });
40 |
--------------------------------------------------------------------------------
/tests/lib/rules/require-g-link-to.spec.ts:
--------------------------------------------------------------------------------
1 | import { RuleTester } from "../../util";
2 |
3 | import rule from "../../../lib/rules/require-g-link-to";
4 |
5 | const tester = new RuleTester({
6 | parser: "vue-eslint-parser",
7 | parserOptions: {
8 | ecmaVersion: 2017,
9 | },
10 | });
11 |
12 | tester.run("require-g-link-to", rule, {
13 | valid: [
14 | `
15 |
16 |
20 | link is here
21 |
22 | `,
23 | `
24 |
25 |
29 | link is here
30 |
31 | `,
32 | `
33 |
34 |
38 | link is here
39 |
40 | `,
41 | `
42 |
43 |
47 | link is here
48 |
49 | `,
50 | `
51 |
52 |
56 | link is here
57 |
58 | `,
59 | `
60 |
61 |
65 | link is here
66 |
67 | `,
68 | ],
69 | invalid: [
70 | {
71 | code: `
72 |
73 |
76 | link is here
77 |
78 | `,
79 | errors: [
80 | {
81 | messageId: "requireGLinkTo",
82 | },
83 | ],
84 | },
85 | ],
86 | });
87 |
--------------------------------------------------------------------------------
/tests/lib/rules/use-env-prefix.spec.ts:
--------------------------------------------------------------------------------
1 | import path from "path";
2 | import { RuleTester, loadFixtureCreator } from "../../util";
3 |
4 | import rule from "../../../lib/rules/use-env-prefix";
5 |
6 | const tester = new RuleTester({
7 | parser: "vue-eslint-parser",
8 | parserOptions: {
9 | ecmaVersion: 2017,
10 | sourceType: "module",
11 | },
12 | });
13 |
14 | const loadFixture = loadFixtureCreator(
15 | "tests/lib/rules/fixtures/use-env-prefix"
16 | );
17 |
18 | tester.run("use-env-prefix", rule, {
19 | valid: [
20 | {
21 | filename: path.join(process.cwd(), "src/components/code.vue"),
22 | ...loadFixture({
23 | fixtureDirectory: "valid/01",
24 | }),
25 | options: [
26 | {
27 | pathsForBrowserfile: ["src/**/*"],
28 | envPath: "tests/lib/rules/fixtures/use-env-prefix/valid/01/.env",
29 | },
30 | ],
31 | },
32 | {
33 | filename: path.join(process.cwd(), "src/client.js"),
34 | ...loadFixture({
35 | fixtureDirectory: "valid/02",
36 | filenames: {
37 | code: "client.js",
38 | },
39 | }),
40 | options: [
41 | {
42 | pathsForBrowserfile: ["src/**/*"],
43 | envPath: "tests/lib/rules/fixtures/use-env-prefix/valid/02/.env",
44 | },
45 | ],
46 | },
47 | {
48 | filename: path.join(process.cwd(), "src/client.js"),
49 | ...loadFixture({
50 | fixtureDirectory: "valid/03",
51 | filenames: {
52 | code: "client.js",
53 | },
54 | }),
55 | options: [
56 | {
57 | pathsForBrowserfile: ["src/**/*"],
58 | envPath: "tests/lib/rules/fixtures/use-env-prefix/valid/03/.env",
59 | },
60 | ],
61 | },
62 | ],
63 | invalid: [
64 | {
65 | filename: path.join(process.cwd(), "src/components/code.vue"),
66 | ...loadFixture({
67 | fixtureDirectory: "invalid/01",
68 | }),
69 | options: [
70 | {
71 | pathsForBrowserfile: ["src/**/*"],
72 | envPath: "tests/lib/rules/fixtures/use-env-prefix/invalid/01/.env",
73 | },
74 | ],
75 | errors: [
76 | {
77 | messageId: "useEnvPrefix",
78 | },
79 | ],
80 | },
81 | {
82 | filename: path.join(process.cwd(), "src/client.js"),
83 | ...loadFixture({
84 | fixtureDirectory: "invalid/02",
85 | filenames: {
86 | code: "client.js",
87 | },
88 | }),
89 | options: [
90 | {
91 | pathsForBrowserfile: ["src/**/*"],
92 | envPath: "tests/lib/rules/fixtures/use-env-prefix/invalid/02/.env",
93 | },
94 | ],
95 | errors: [
96 | {
97 | messageId: "useEnvPrefix",
98 | },
99 | {
100 | messageId: "useEnvPrefix",
101 | },
102 | ],
103 | },
104 | ],
105 | });
106 |
--------------------------------------------------------------------------------
/tests/lib/utils/env.spec.ts:
--------------------------------------------------------------------------------
1 | import { Env } from "../../../lib/utils/env";
2 |
3 | import { expect } from "chai";
4 |
5 | describe("env", () => {
6 | describe("parse", () => {
7 | it("to JSON object", () => {
8 | const source = `
9 | ENV1=foo
10 | `;
11 |
12 | const env = new Env(source);
13 |
14 | const result = env.parse();
15 |
16 | expect(result.get("ENV1")).to.deep.equal("foo");
17 | });
18 |
19 | it("to JSON object even if include =", () => {
20 | const source = `
21 | ENV1======
22 | `;
23 |
24 | const env = new Env(source);
25 |
26 | const result = env.parse();
27 |
28 | expect(result.get("ENV1")).to.deep.equal("=====");
29 | });
30 |
31 | it("skip comment line", () => {
32 | const source = `
33 | # ENV1=foo
34 | ENV2=bar
35 | `;
36 |
37 | const env = new Env(source);
38 |
39 | const result = env.parse();
40 |
41 | expect(result.get("ENV2")).to.deep.equal("bar");
42 | });
43 |
44 | it("skip comment line same line", () => {
45 | const source = `
46 | ENV1=foo # comment
47 | ENV2=bar
48 | `;
49 |
50 | const env = new Env(source);
51 |
52 | const result = env.parse();
53 |
54 | expect(result.get("ENV1")).to.deep.equal("foo");
55 | expect(result.get("ENV2")).to.deep.equal("bar");
56 | });
57 | });
58 | });
59 |
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/not-use-prettierrc/file.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | file
4 |
5 |
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/override-prettier-option/not-use-prettierrc/file.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | file
4 |
5 |
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/override-prettier-option/use-prettierrc/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "tabWidth": 20,
3 | "vueIndentScriptAndStyle": true
4 | }
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/override-prettier-option/use-prettierrc/file.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | file
4 |
5 |
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/use-prettierrc/set-other-option/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "arrowParens": "avoid"
3 | }
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/use-prettierrc/set-other-option/file.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | file
4 |
5 |
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/use-prettierrc/set-tab-width/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "tabWidth": 4,
3 | "vueIndentScriptAndStyle": true
4 | }
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/use-prettierrc/set-tab-width/file.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | file
4 |
5 |
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/use-prettierrc/set-use-tabs/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "tabWidth": 200,
3 | "useTabs": true,
4 | "vueIndentScriptAndStyle": true
5 | }
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-code-wrap-indent-info/use-prettierrc/set-use-tabs/file.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | file
4 |
5 |
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-prettier-option/not-use-prettierrc/file.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | file
4 |
5 |
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-prettier-option/use-prettierrc/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "arrowParens": "avoid",
3 | "htmlWhitespaceSensitivity": "css"
4 | }
--------------------------------------------------------------------------------
/tests/lib/utils/fixtures/get-prettier-option/use-prettierrc/file.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | file
4 |
5 |
--------------------------------------------------------------------------------
/tests/lib/utils/get-code-wrap-indent-info.spec.ts:
--------------------------------------------------------------------------------
1 | import { getCodeWrapIndentInfo } from "../../../lib/utils/get-code-wrap-indent-info";
2 | import path from "path";
3 |
4 | import {
5 | getPrettierDefaultOption,
6 | getPrettierRcOption,
7 | getMergedPrettierOption,
8 | } from "../../../lib/utils/get-prettier-option";
9 | import { expect } from "chai";
10 |
11 | const indent = {
12 | space: " ",
13 | tab: "\t",
14 | none: "",
15 | };
16 |
17 | describe("getCodeWrapIndentInfo", () => {
18 | describe("not use prettierrc", () => {
19 | it("when not use prettierrc, it means vueIndentScriptAndStyle is false. So indentRepeatTime is 0, and indentChar is empty string", () => {
20 | const prettierDefaultOptions = getPrettierDefaultOption;
21 |
22 | const filePath = path.join(
23 | process.cwd(),
24 | "tests/lib/utils/fixtures",
25 | "get-code-wrap-indent-info",
26 | "not-use-prettierrc",
27 | "file.vue"
28 | );
29 | const prettierRcOptions = getPrettierRcOption(filePath);
30 |
31 | const mergedPrettierOption = getMergedPrettierOption(
32 | prettierDefaultOptions,
33 | prettierRcOptions
34 | );
35 |
36 | const result = getCodeWrapIndentInfo(mergedPrettierOption);
37 |
38 | expect(result).to.deep.equal({
39 | indentRepeatTime: 0,
40 | indentChar: indent.none,
41 | });
42 | });
43 |
44 | it("when not use prettierrc, follow option value if set eslint option", () => {
45 | const prettierDefaultOptions = getPrettierDefaultOption;
46 |
47 | const filePath = path.join(
48 | process.cwd(),
49 | "tests/lib/utils/fixtures",
50 | "get-code-wrap-indent-info",
51 | "not-use-prettierrc",
52 | "file.vue"
53 | );
54 | const prettierRcOptions = getPrettierRcOption(filePath);
55 |
56 | const mergedPrettierOption = getMergedPrettierOption(
57 | prettierDefaultOptions,
58 | prettierRcOptions
59 | );
60 |
61 | const eslintOption = {
62 | vueIndentScriptAndStyle: true,
63 | };
64 |
65 | const result = getCodeWrapIndentInfo(mergedPrettierOption, eslintOption);
66 |
67 | expect(result).to.deep.equal({
68 | indentRepeatTime: 2,
69 | indentChar: indent.space,
70 | });
71 | });
72 | });
73 |
74 | describe("use prettierrc", () => {
75 | it("when tabWidth is 4, indentRepeatTime is 4 indentChar is space", () => {
76 | const prettierDefaultOptions = getPrettierDefaultOption;
77 |
78 | const filePath = path.join(
79 | process.cwd(),
80 | "tests/lib/utils/fixtures",
81 | "get-code-wrap-indent-info",
82 | "use-prettierrc",
83 | "set-tab-width",
84 | "file.vue"
85 | );
86 | const prettierRcOptions = getPrettierRcOption(filePath);
87 |
88 | const mergedPrettierOption = getMergedPrettierOption(
89 | prettierDefaultOptions,
90 | prettierRcOptions
91 | );
92 |
93 | const result = getCodeWrapIndentInfo(mergedPrettierOption);
94 |
95 | expect(result).to.deep.equal({
96 | indentRepeatTime: 4,
97 | indentChar: indent.space,
98 | });
99 | });
100 |
101 | it("when useTabs is true, indentRepeatTime is fixed 1 indentChar is tab", () => {
102 | const prettierDefaultOptions = getPrettierDefaultOption;
103 |
104 | const filePath = path.join(
105 | process.cwd(),
106 | "tests/lib/utils/fixtures",
107 | "get-code-wrap-indent-info",
108 | "use-prettierrc",
109 | "set-use-tabs",
110 | "file.vue"
111 | );
112 | const prettierRcOptions = getPrettierRcOption(filePath);
113 |
114 | const mergedPrettierOption = getMergedPrettierOption(
115 | prettierDefaultOptions,
116 | prettierRcOptions
117 | );
118 |
119 | const result = getCodeWrapIndentInfo(mergedPrettierOption);
120 |
121 | expect(result).to.deep.equal({
122 | indentRepeatTime: 1,
123 | indentChar: indent.tab,
124 | });
125 | });
126 | });
127 |
128 | describe("override-prettier-option", () => {
129 | it("when not use prettierrc and use eslint option, override value of indentRepeatTime and indentChar", () => {
130 | const prettierDefaultOptions = getPrettierDefaultOption;
131 |
132 | const filePath = path.join(
133 | process.cwd(),
134 | "tests/lib/utils/fixtures",
135 | "get-code-wrap-indent-info",
136 | "override-prettier-option",
137 | "not-use-prettierrc",
138 | "file.vue"
139 | );
140 | const prettierRcOptions = getPrettierRcOption(filePath);
141 |
142 | const mergedPrettierOption = getMergedPrettierOption(
143 | prettierDefaultOptions,
144 | prettierRcOptions
145 | );
146 |
147 | const eslintOption = {
148 | vueIndentScriptAndStyle: true,
149 | tabWidth: 10,
150 | };
151 |
152 | const result = getCodeWrapIndentInfo(mergedPrettierOption, eslintOption);
153 |
154 | expect(result).to.deep.equal({
155 | indentRepeatTime: 10,
156 | indentChar: indent.space,
157 | });
158 | });
159 |
160 | it("when use prettierrc and use eslint option, follow prettierrc option and then override eslint option", () => {
161 | const prettierDefaultOptions = getPrettierDefaultOption;
162 |
163 | const filePath = path.join(
164 | process.cwd(),
165 | "tests/lib/utils/fixtures",
166 | "get-code-wrap-indent-info",
167 | "override-prettier-option",
168 | "use-prettierrc",
169 | "file.vue"
170 | );
171 | const prettierRcOptions = getPrettierRcOption(filePath);
172 |
173 | const mergedPrettierOption = getMergedPrettierOption(
174 | prettierDefaultOptions,
175 | prettierRcOptions
176 | );
177 |
178 | const eslintOption = {
179 | vueIndentScriptAndStyle: true,
180 | tabWidth: 4,
181 | };
182 |
183 | const result = getCodeWrapIndentInfo(mergedPrettierOption, eslintOption);
184 |
185 | expect(result).to.deep.equal({
186 | indentRepeatTime: 4,
187 | indentChar: indent.space,
188 | });
189 | });
190 | });
191 | });
192 |
--------------------------------------------------------------------------------
/tests/lib/utils/get-prettier-option.spec.ts:
--------------------------------------------------------------------------------
1 | import path from "path";
2 |
3 | import {
4 | getPrettierDefaultOption,
5 | getPrettierRcOption,
6 | getMergedPrettierOption,
7 | } from "../../../lib/utils/get-prettier-option";
8 | import { expect } from "chai";
9 |
10 | describe("getPrettierOption", () => {
11 | describe("getPrettierDefaultOption", () => {
12 | it("when call getPrettierDefaultOption, return object(key is option.name, value is option.default at prettier v2)", () => {
13 | const result = getPrettierDefaultOption;
14 |
15 | expect(result).to.deep.equal({
16 | arrowParens: "always",
17 | bracketSpacing: true,
18 | cursorOffset: -1,
19 | endOfLine: "lf",
20 | filepath: undefined,
21 | htmlWhitespaceSensitivity: "css",
22 | insertPragma: false,
23 | jsxBracketSameLine: false,
24 | jsxSingleQuote: false,
25 | parser: undefined,
26 | pluginSearchDirs: [],
27 | plugins: [],
28 | printWidth: 80,
29 | proseWrap: "preserve",
30 | quoteProps: "as-needed",
31 | rangeEnd: Infinity,
32 | rangeStart: 0,
33 | requirePragma: false,
34 | semi: true,
35 | singleQuote: false,
36 | tabWidth: 2,
37 | trailingComma: "es5",
38 | useTabs: false,
39 | vueIndentScriptAndStyle: false,
40 | });
41 | });
42 | });
43 |
44 | describe("getPrettierRcOption", () => {
45 | it("when discover .prettierrc, return option object", () => {
46 | const filePath = path.join(
47 | process.cwd(),
48 | "tests/lib/utils/fixtures",
49 | "get-prettier-option",
50 | "use-prettierrc",
51 | "file.vue"
52 | );
53 |
54 | const result = getPrettierRcOption(filePath);
55 |
56 | expect(result).to.deep.equal({
57 | arrowParens: "avoid",
58 | htmlWhitespaceSensitivity: "css",
59 | });
60 | });
61 |
62 | it("when discover .prettierrc, return null", () => {
63 | const filePath = path.join(
64 | process.cwd(),
65 | "tests/lib/utils/fixtures",
66 | "get-prettier-option",
67 | "not-use-prettierrc",
68 | "file.vue"
69 | );
70 |
71 | const result = getPrettierRcOption(filePath);
72 |
73 | expect(result).to.deep.equal(null);
74 | });
75 | });
76 |
77 | describe("getMergedPrettierOption", () => {
78 | it("when discover .prettierrc, return object merged prettierDefaultOptions and .prettierrc", () => {
79 | const prettierDefaultOptions = getPrettierDefaultOption;
80 |
81 | const filePath = path.join(
82 | process.cwd(),
83 | "tests/lib/utils/fixtures",
84 | "get-prettier-option",
85 | "use-prettierrc",
86 | "file.vue"
87 | );
88 | const prettierRcOptions = getPrettierRcOption(filePath);
89 |
90 | const result = getMergedPrettierOption(
91 | prettierDefaultOptions,
92 | prettierRcOptions
93 | );
94 |
95 | expect(result).to.deep.equal({
96 | arrowParens: "avoid",
97 | bracketSpacing: true,
98 | cursorOffset: -1,
99 | endOfLine: "lf",
100 | filepath: undefined,
101 | htmlWhitespaceSensitivity: "css",
102 | insertPragma: false,
103 | jsxBracketSameLine: false,
104 | jsxSingleQuote: false,
105 | parser: undefined,
106 | pluginSearchDirs: [],
107 | plugins: [],
108 | printWidth: 80,
109 | proseWrap: "preserve",
110 | quoteProps: "as-needed",
111 | rangeEnd: Infinity,
112 | rangeStart: 0,
113 | requirePragma: false,
114 | semi: true,
115 | singleQuote: false,
116 | tabWidth: 2,
117 | trailingComma: "es5",
118 | useTabs: false,
119 | vueIndentScriptAndStyle: false,
120 | });
121 | });
122 |
123 | it("when not discover .prettierrc, return object merged prettierDefaultOptions and null", () => {
124 | const prettierDefaultOptions = getPrettierDefaultOption;
125 |
126 | const filePath = path.join(
127 | process.cwd(),
128 | "tests/lib/utils/fixtures",
129 | "get-prettier-option",
130 | "not-use-prettierrc",
131 | "file.vue"
132 | );
133 | const prettierRcOptions = getPrettierRcOption(filePath);
134 |
135 | const result = getMergedPrettierOption(
136 | prettierDefaultOptions,
137 | prettierRcOptions
138 | );
139 |
140 | expect(result).to.deep.equal({
141 | arrowParens: "always",
142 | bracketSpacing: true,
143 | cursorOffset: -1,
144 | endOfLine: "lf",
145 | filepath: undefined,
146 | htmlWhitespaceSensitivity: "css",
147 | insertPragma: false,
148 | jsxBracketSameLine: false,
149 | jsxSingleQuote: false,
150 | parser: undefined,
151 | pluginSearchDirs: [],
152 | plugins: [],
153 | printWidth: 80,
154 | proseWrap: "preserve",
155 | quoteProps: "as-needed",
156 | rangeEnd: Infinity,
157 | rangeStart: 0,
158 | requirePragma: false,
159 | semi: true,
160 | singleQuote: false,
161 | tabWidth: 2,
162 | trailingComma: "es5",
163 | useTabs: false,
164 | vueIndentScriptAndStyle: false,
165 | });
166 | });
167 | });
168 | });
169 |
--------------------------------------------------------------------------------
/tests/lib/utils/path.spec.ts:
--------------------------------------------------------------------------------
1 | import { getPathFromProjectRoot } from "../../../lib/utils/path";
2 |
3 | import { expect } from "chai";
4 |
5 | describe("path", () => {
6 | describe("getPathFromProjectRoot", () => {
7 | it("when call getPathFromProjectRoot with context.getFilename() and process.cwd(), return path from project root", () => {
8 | const filename = "/User/path/to/project/src/index.js";
9 | const cwd = "/User/path/to/project";
10 |
11 | const result = getPathFromProjectRoot(filename, cwd);
12 |
13 | expect(result).to.deep.equal("src/index.js");
14 | });
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/tests/util/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./rule-tester";
2 | export * from "./load-fixture-creator";
3 |
--------------------------------------------------------------------------------
/tests/util/load-fixture-creator.ts:
--------------------------------------------------------------------------------
1 | import path from "path";
2 | import fs from "fs";
3 |
4 | export const loadFixtureCreator = (
5 | fixtureDirectoryFromRoot: string
6 | ) => (params: {
7 | fixtureDirectory: string;
8 | hasOutputFile?: boolean;
9 | filenames?: {
10 | code?: string;
11 | output?: string;
12 | };
13 | }) => {
14 | const file = {
15 | code: params.filenames?.code || "code.vue",
16 | output: params.filenames?.output || "output.vue",
17 | };
18 | if (params.hasOutputFile) {
19 | return {
20 | code: fs.readFileSync(
21 | path.join(
22 | `${fixtureDirectoryFromRoot}/${params.fixtureDirectory}/${file.code}`
23 | ),
24 | { encoding: "utf8" }
25 | ),
26 | output: fs.readFileSync(
27 | path.join(
28 | `${fixtureDirectoryFromRoot}/${params.fixtureDirectory}/${file.output}`
29 | ),
30 | { encoding: "utf8" }
31 | ),
32 | };
33 | }
34 |
35 | return {
36 | code: fs.readFileSync(
37 | path.join(
38 | `${fixtureDirectoryFromRoot}/${params.fixtureDirectory}/${file.code}`
39 | ),
40 | { encoding: "utf8" }
41 | ),
42 | };
43 | };
44 |
--------------------------------------------------------------------------------
/tests/util/rule-tester.ts:
--------------------------------------------------------------------------------
1 | import { TSESLint } from "@typescript-eslint/experimental-utils";
2 |
3 | type Parser = "vue-eslint-parser";
4 |
5 | type RuleTesterConfig = Omit & {
6 | parser: Parser;
7 | };
8 |
9 | export class RuleTester extends TSESLint.RuleTester {
10 | constructor(protected config: RuleTesterConfig) {
11 | super({
12 | ...config,
13 | // @see https://eslint.org/docs/user-guide/migrating-to-6.0.0#ruletester-now-requires-an-absolute-path-on-parser-option
14 | parser: require.resolve(config.parser),
15 | });
16 | }
17 | }
18 | /* eslint-enable */
19 |
--------------------------------------------------------------------------------
/tools/update-rules-docs.ts:
--------------------------------------------------------------------------------
1 | import fs from "fs";
2 | import path from "path";
3 |
4 | import { getRulesMetaData, createRuleDocs, DIR_DOCS } from "./util";
5 |
6 | const rulesDocsPath = path.join(DIR_DOCS, "rules", "README.md");
7 |
8 | export const updateRulesDocs = async () => {
9 | const { rulesMetaData } = await getRulesMetaData();
10 |
11 | const { doc } = createRuleDocs(rulesMetaData);
12 |
13 | fs.writeFileSync(rulesDocsPath, doc);
14 | };
15 |
--------------------------------------------------------------------------------
/tools/update-rules-list.ts:
--------------------------------------------------------------------------------
1 | import fs from "fs";
2 |
3 | import { getRulesMetaData, createRulesList, DIR_LIB } from "./util";
4 |
5 | const rulesListPath = `${DIR_LIB}/rules.ts`;
6 |
7 | export const updateRulesList = async () => {
8 | const { rulesMetaData } = await getRulesMetaData();
9 | const { list } = await createRulesList(rulesMetaData);
10 |
11 | if (list !== undefined) {
12 | fs.writeFileSync(rulesListPath, list);
13 | }
14 | };
15 |
--------------------------------------------------------------------------------
/tools/update.ts:
--------------------------------------------------------------------------------
1 | import { updateRulesDocs } from "./update-rules-docs";
2 | import { updateRulesList } from "./update-rules-list";
3 |
4 | // eslint-disable-next-line @mysticatea/ts/no-floating-promises
5 | (async () => {
6 | await updateRulesDocs();
7 | await updateRulesList();
8 | })();
9 |
--------------------------------------------------------------------------------
/tools/util/const.ts:
--------------------------------------------------------------------------------
1 | import path from "path";
2 |
3 | export const NAME_SPACE = "gridsome";
4 | export const DIR_ROOT = path.join(__dirname, "../../");
5 | export const DIR_LIB = path.join(DIR_ROOT, "lib");
6 | export const DIR_DOCS = path.join(DIR_ROOT, "docs");
7 |
--------------------------------------------------------------------------------
/tools/util/create-rules-docs.ts:
--------------------------------------------------------------------------------
1 | import { NAME_SPACE } from "./const";
2 | import { RuleMetaData } from "./types";
3 | import { formatMarkdown } from "./format-markdown";
4 |
5 | const createIntro = () => `
6 | ---
7 | title: Rules
8 | ---
9 |
10 |
11 |
12 | # Rules
13 |
14 | ## 🛠Available rules
15 | `;
16 |
17 | const createRulesSection = (rulesMetaData: RuleMetaData[]) => {
18 | const tableHeader = `
19 | |Rule ID|Description|Fixable|
20 | | :--- | :--- | :---: |`;
21 |
22 | const rulesTable = rulesMetaData
23 | .map((ruleMetaData) => {
24 | const { name } = ruleMetaData;
25 | const url = `/rules/${name}`;
26 | const description = ruleMetaData.meta.docs?.description;
27 | const fixable = ruleMetaData.meta.fixable ? ":wrench:" : "";
28 |
29 | return `|[${NAME_SPACE}/${name}](${url})|${description}|${fixable}|\n`;
30 | })
31 | .join("");
32 |
33 | return `
34 | ${tableHeader}
35 | ${rulesTable}
36 | `;
37 | };
38 |
39 | export const createRuleDocs = (rulesMetaData: RuleMetaData[]) => {
40 | const doc: string[] = [];
41 | doc.push(createIntro());
42 |
43 | doc.push(createRulesSection(rulesMetaData));
44 |
45 | return { doc: formatMarkdown(doc.join("")) };
46 | };
47 |
--------------------------------------------------------------------------------
/tools/util/create-rules-list.ts:
--------------------------------------------------------------------------------
1 | import { camelCase } from "change-case";
2 |
3 | import { RuleMetaData } from "./types";
4 | import { formatTypescript } from "./format-typescript";
5 |
6 | const importSection = (ruleNames: RuleMetaData["name"][]) =>
7 | ruleNames
8 | .map((ruleName) => {
9 | const nameCamel = camelCase(ruleName);
10 |
11 | return `import ${nameCamel} from './rules/${ruleName}';`;
12 | })
13 | .join("");
14 |
15 | const exportSection = (ruleNames: RuleMetaData["name"][]) => {
16 | const header = "export const rules = {";
17 | const footer = "};";
18 | const rules = ruleNames
19 | .map((ruleName) => {
20 | const nameCamel = camelCase(ruleName);
21 |
22 | return `"${ruleName}": ${nameCamel},`;
23 | })
24 | .join("");
25 | return `
26 | ${header}
27 | ${rules}
28 | ${footer}
29 | `;
30 | };
31 | export const createRulesList = async (rulesMetaData: RuleMetaData[]) => {
32 | const ruleNames = rulesMetaData.map((ruleMetaData) => ruleMetaData.name);
33 |
34 | const content = `
35 | // This file has been automatically generated, in order to update it's content execute "npm run update"
36 | ${importSection(ruleNames)}
37 | ${exportSection(ruleNames)}
38 | `;
39 |
40 | return { list: await formatTypescript(content) };
41 | };
42 |
--------------------------------------------------------------------------------
/tools/util/format-markdown.ts:
--------------------------------------------------------------------------------
1 | import prettier from "prettier";
2 |
3 | export const formatMarkdown = (content: string) =>
4 | prettier.format(content, { parser: "markdown" });
5 |
--------------------------------------------------------------------------------
/tools/util/format-typescript.ts:
--------------------------------------------------------------------------------
1 | import eslint from "eslint";
2 |
3 | export const formatTypescript = async (content: string) => {
4 | const linter = new eslint.ESLint({ fix: true });
5 | const results = await linter.lintText(content);
6 |
7 | return results[0].output;
8 | };
9 |
--------------------------------------------------------------------------------
/tools/util/get-rules-meta-data.ts:
--------------------------------------------------------------------------------
1 | import fs from "fs";
2 |
3 | import { DIR_LIB } from "./const";
4 | import { Rule, RuleMetaData } from "./types";
5 |
6 | const getRuleName = (rulePath: string) => {
7 | const ruleName = rulePath.slice(0, -3);
8 |
9 | return ruleName;
10 | };
11 |
12 | export const getRulesMetaData = async () => {
13 | const rulePaths = fs.readdirSync(`${DIR_LIB}/rules`);
14 | const rulesMetaData: RuleMetaData[] = [];
15 |
16 | for (const rulePath of rulePaths) {
17 | const name = getRuleName(rulePath);
18 |
19 | const rule: Promise = await import(`${DIR_LIB}/rules/${rulePath}`);
20 | rulesMetaData.push({
21 | name,
22 | meta: (await rule).meta,
23 | });
24 | }
25 |
26 | return { rulesMetaData };
27 | };
28 |
--------------------------------------------------------------------------------
/tools/util/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./const";
2 | export * from "./get-rules-meta-data";
3 | export * from "./create-rules-docs";
4 | export * from "./create-rules-list";
5 |
--------------------------------------------------------------------------------
/tools/util/types.ts:
--------------------------------------------------------------------------------
1 | import { ESLintUtils } from "@typescript-eslint/experimental-utils";
2 |
3 | export type Rule = ReturnType>;
4 |
5 | export type RuleMetaData = { name: string; meta: Rule["meta"] };
6 |
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "exclude": ["tests/**/*", "tools/**/*"],
4 | "compilerOptions": {
5 | "removeComments": true
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */
4 |
5 | /* Basic Options */
6 | // "incremental": true, /* Enable incremental compilation */
7 | "target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9 | // "lib": [], /* Specify library files to be included in the compilation. */
10 | // "allowJs": true, /* Allow javascript files to be compiled. */
11 | // "checkJs": true, /* Report errors in .js files. */
12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */
14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15 | // "sourceMap": true, /* Generates corresponding '.map' file. */
16 | // "outFile": "./", /* Concatenate and emit output to single file. */
17 | "outDir": "./dist", /* Redirect output structure to the directory. */
18 | "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19 | // "composite": true, /* Enable project compilation */
20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21 | // "removeComments": true, /* Do not emit comments to output. */
22 | // "noEmit": true, /* Do not emit outputs. */
23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26 |
27 | /* Strict Type-Checking Options */
28 | "strict": true, /* Enable all strict type-checking options. */
29 | "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30 | // "strictNullChecks": true, /* Enable strict null checks. */
31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */
32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36 |
37 | /* Additional Checks */
38 | "noUnusedLocals": true, /* Report errors on unused locals. */
39 | "noUnusedParameters": true, /* Report errors on unused parameters. */
40 | "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41 | "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42 |
43 | /* Module Resolution Options */
44 | "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
48 | // "typeRoots": [], /* List of folders to include type definitions from. */
49 | // "types": [], /* Type declaration files to be included in compilation. */
50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
54 |
55 | /* Source Map Options */
56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
60 |
61 | /* Experimental Options */
62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
64 |
65 | /* Advanced Options */
66 | "skipLibCheck": true, /* Skip type checking of declaration files. */
67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
68 | },
69 | "include": [
70 | "lib/**/*",
71 | "tests/**/*",
72 | "tools/**/*",
73 | ]
74 | }
75 |
--------------------------------------------------------------------------------