Skip to content

Commit ca0bde1

Browse files
authored
Implementation of eslint plugin (#1)
1 parent 51c67f6 commit ca0bde1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+14706
-105
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
!/docs/.vuepress
2+
!/.github
3+
!/.vscode
4+
/.nyc_output
5+
/assets
6+
/coverage
7+
/dist
8+
/docs/.vuepress/dist
9+
/node_modules
10+
# /tests/fixtures Used testcases
11+
/tests-integrations/config-recommended

.eslintrc.js

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
'use strict'
2+
3+
module.exports = {
4+
root: true,
5+
env: {
6+
node: true,
7+
mocha: true,
8+
es2021: true
9+
},
10+
extends: [
11+
'plugin:prettier/recommended',
12+
'plugin:markdown/recommended',
13+
'prettier'
14+
],
15+
plugins: ['@typescript-eslint'],
16+
parserOptions: {
17+
ecmaVersion: 2021
18+
},
19+
rules: {
20+
'accessor-pairs': 2,
21+
'brace-style': [2, '1tbs', { allowSingleLine: true }],
22+
camelcase: [2, { properties: 'never' }],
23+
'comma-dangle': [2, 'never'],
24+
'constructor-super': 2,
25+
curly: [2, 'multi-line'],
26+
eqeqeq: [2, 'allow-null'],
27+
'handle-callback-err': [2, '^(err|error)$'],
28+
'new-cap': [2, { newIsCap: true, capIsNew: false }],
29+
'new-parens': 2,
30+
'no-array-constructor': 2,
31+
'no-caller': 2,
32+
'no-class-assign': 2,
33+
'no-cond-assign': 2,
34+
'no-const-assign': 2,
35+
'no-control-regex': 2,
36+
'no-delete-var': 2,
37+
'no-dupe-args': 2,
38+
'no-dupe-class-members': 2,
39+
'no-dupe-keys': 2,
40+
'no-duplicate-case': 2,
41+
'no-empty-character-class': 2,
42+
'no-empty-pattern': 2,
43+
'no-eval': 2,
44+
'no-ex-assign': 2,
45+
'no-extend-native': 2,
46+
'no-extra-bind': 2,
47+
'no-extra-boolean-cast': 2,
48+
'no-extra-parens': [2, 'functions'],
49+
'no-fallthrough': 2,
50+
'no-floating-decimal': 2,
51+
'no-func-assign': 2,
52+
'no-implied-eval': 2,
53+
'no-inner-declarations': [2, 'functions'],
54+
'no-invalid-regexp': 2,
55+
'no-irregular-whitespace': 2,
56+
'no-iterator': 2,
57+
'no-label-var': 2,
58+
'no-labels': [2, { allowLoop: false, allowSwitch: false }],
59+
'no-lone-blocks': 2,
60+
'no-mixed-spaces-and-tabs': 2,
61+
'no-multi-str': 2,
62+
'no-native-reassign': 2,
63+
'no-negated-in-lhs': 2,
64+
'no-new-object': 2,
65+
'no-new-require': 2,
66+
'no-new-symbol': 2,
67+
'no-new-wrappers': 2,
68+
'no-obj-calls': 2,
69+
'no-octal': 2,
70+
'no-octal-escape': 2,
71+
'no-path-concat': 2,
72+
'no-proto': 2,
73+
'no-redeclare': 2,
74+
'no-regex-spaces': 2,
75+
'no-return-assign': [2, 'except-parens'],
76+
'no-self-assign': 2,
77+
'no-self-compare': 2,
78+
'no-sequences': 2,
79+
'no-shadow-restricted-names': 2,
80+
'no-spaced-func': 2,
81+
'no-sparse-arrays': 2,
82+
'no-this-before-super': 2,
83+
'no-throw-literal': 2,
84+
'no-trailing-spaces': 2,
85+
'no-undef': 2,
86+
'no-undef-init': 2,
87+
'no-unexpected-multiline': 2,
88+
'no-unmodified-loop-condition': 2,
89+
'no-unneeded-ternary': [2, { defaultAssignment: false }],
90+
'no-unreachable': 2,
91+
'no-unsafe-finally': 2,
92+
'no-unused-vars': [2, { vars: 'all', args: 'none' }],
93+
'no-useless-call': 2,
94+
'no-useless-computed-key': 2,
95+
'no-useless-constructor': 2,
96+
'no-useless-escape': 0,
97+
'no-whitespace-before-property': 2,
98+
'no-with': 2,
99+
'one-var': [2, { initialized: 'never' }],
100+
'use-isnan': 2,
101+
'valid-typeof': 2,
102+
'wrap-iife': [2, 'any'],
103+
yoda: [2, 'never'],
104+
'prefer-const': 2,
105+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
106+
'object-shorthand': 'error'
107+
},
108+
overrides: [
109+
{
110+
files: ['*.ts'],
111+
extends: ['plugin:@typescript-eslint/recommended'],
112+
parser: '@typescript-eslint/parser',
113+
rules: {
114+
'@typescript-eslint/no-non-null-assertion': 'off',
115+
'@typescript-eslint/consistent-type-imports': 'error'
116+
}
117+
},
118+
{
119+
files: ['*.vue'],
120+
parser: 'vue-eslint-parser',
121+
parserOptions: {
122+
ecmaVersion: 2021,
123+
sourceType: 'module'
124+
}
125+
},
126+
{
127+
files: ['**/*.md/*.*'],
128+
rules: {
129+
'prettier/prettier': 'off'
130+
}
131+
}
132+
]
133+
}

.github/CONTRIBUTING.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# @intlify/eslint-plugin-svelte Contributing Guide
2+
3+
- [Issue Reporting Guidelines](#issue-reporting-guidelines)
4+
- [Pull Request Guidelines](#pull-request-guidelines)
5+
- [Development Setup](#development-setup)
6+
7+
## Issue Reporting Guidelines
8+
9+
- The issue list of this repo is **exclusively** for bug reports and feature requests. Non-conforming issues will be closed immediately.
10+
11+
- For simple beginner questions, you can get quick answers from [GitHub Discussions](https://github.com/intlify/eslint-plugin-svelte/discussions)
12+
13+
- For more complicated questions, you can use [GitHub Discussions](https://github.com/intlify/eslint-plugin-svelte/discussions) or StackOverflow. Make sure to provide enough information when asking your questions - this makes it easier for others to help you!
14+
15+
- Try to search for your issue, it may have already been answered or even fixed in the development branch.
16+
17+
- Check if the issue is reproducible with the latest stable version of ESLint. If you are using a pre-release, please indicate the specific version you are using.
18+
19+
- It is **required** that you clearly describe the steps necessary to reproduce the issue you are running into. Issues with no clear repro steps will not be triaged. If an issue labeled "need repro" receives no further input from the issue author for more than 5 days, it will be closed.
20+
21+
- For bugs that involves build setups, you can create a reproduction repository with steps in the README.
22+
23+
- If your issue is resolved but still open, don’t hesitate to close it. In case you found a solution by yourself, it could be helpful to explain how you fixed it.
24+
25+
## Pull Request Guidelines
26+
27+
- The `main` branch is basically just a snapshot of the latest stable release. All development should be done in dedicated branches. **Do not submit PRs against the `main` branch.**
28+
29+
- Checkout a topic branch from the relevant branch, e.g. `main`, and merge back against that branch.
30+
31+
- It's OK to have multiple small commits as you work on the PR - we will let GitHub automatically squash it before merging.
32+
33+
- Make sure `yarn test` passes. (see [development setup](#development-setup))
34+
35+
- If adding new feature:
36+
37+
- Add accompanying test case.
38+
- Provide convincing reason to add this feature. Ideally you should open a suggestion issue first and have it greenlighted before working on it.
39+
40+
- If fixing a bug:
41+
- Provide detailed description of the bug in the PR. Live demo preferred.
42+
- Add appropriate test coverage if applicable.
43+
44+
### Work Step Example
45+
46+
- Fork the repository from [@intlify/eslint-plugin-svelte](https://github.com/intlify/eslint-plugin-svelte) !
47+
- Create your topic branch from `main`: `git branch my-new-topic origin/main`
48+
- Add codes and pass tests !
49+
- Commit your changes: `git commit -am 'Add some topic'`
50+
- Push to the branch: `git push origin my-new-topic`
51+
- Submit a pull request to `main` branch of `@intlify/eslint-plugin-svelte` repository !
52+
53+
## Development Setup
54+
55+
You will need [Node.js](http://nodejs.org) and [Yarn](https://yarnpkg.com/en/)
56+
57+
After cloning the repo, run:
58+
59+
$ yarn
60+
61+
### Commonly used scirpt with Yarn
62+
63+
# lint source codes and docs
64+
$ yarn lint
65+
$ yarn lint:docs
66+
67+
# run the vuepress
68+
$ yarn docs
69+
70+
# run the test suite
71+
$ yarn test
72+
73+
There are some other scripts available in the `scripts` section of the `package.json` file.
74+
75+
The default test script will do the following: lint with ESLint -> unit tests with coverage. **Please make sure to have this pass successfully before submitting a PR.** Although the same tests will be run against your PR on the CI server, it is better to have it working locally beforehand.

.github/ISSUE_TEMPLATE/bug_report.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
---
5+
6+
<!--
7+
Before posting the issue, please confirm that the problem you're getting
8+
is not related with your code editor configuration.
9+
To make sure it's not, run: yarn eslint src/your-file.svelte
10+
-->
11+
12+
**Tell us about your environment**
13+
14+
- **ESLint version:**
15+
- **@intlify/eslint-plugin-svelte version:**
16+
- **Node version:**
17+
18+
**Please show your full configuration:**
19+
<!-- Paste content of your .eslintrc file -->
20+
21+
```json5
22+
23+
```
24+
25+
26+
**What did you do?**
27+
<!-- Please include the actual source code causing the issue. -->
28+
29+
```svelte
30+
31+
```
32+
33+
34+
**What did you expect to happen?**
35+
36+
37+
**What actually happened?**
38+
<!--
39+
Please include the actual, raw output from ESLint.
40+
If you are only looking at the results of your editor extension, also check the CLI results.
41+
-->
42+

.github/ISSUE_TEMPLATE/change.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: 'Non-rule change request'
3+
about: Request a change that is not a bug fix, rule change, or new rule
4+
---
5+
6+
<!--
7+
Before proposing changes, please make sure it hasn't been posted already.
8+
You can see all open propositions here:
9+
https://github.com/intlify/eslint-plugin-svelte/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Feature%22
10+
-->
11+
12+
**Tell us about your environment**
13+
14+
- **ESLint version:**
15+
- **@intlify/eslint-plugin-svelte version:**
16+
- **Node version:**
17+
18+
**The problem you want to solve.**
19+
20+
21+
**Your take on the correct solution to problem.**
22+
23+
24+
**Additional context**
25+
<!-- Add any other context or screenshots about the feature request here. -->

.github/ISSUE_TEMPLATE/rule-change.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: 'Rule change request'
3+
about: Request a change to an existing rule
4+
---
5+
6+
<!--
7+
Before proposing rule changes, please make sure it hasn't been posted already.
8+
You can see all open propositions here:
9+
https://github.com/intlify/eslint-plugin-svelte/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Feature%22
10+
-->
11+
12+
**What rule do you want to change?**
13+
14+
15+
**Does this change cause the rule to produce more or fewer warnings?**
16+
17+
18+
**How will the change be implemented? (New option, new default behavior, etc.)?**
19+
20+
21+
**Please provide some example code that this change will affect:**
22+
<!-- Put your code examples here -->
23+
24+
```svelte
25+
26+
```
27+
28+
29+
**What does the rule currently do for this code?**
30+
31+
32+
**What will the rule do after it's changed?**
33+
34+
35+
**Additional context**
36+
<!-- Add any other context or screenshots about the feature request here. -->
37+
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Rule Proposal
3+
about: Suggest an idea for a new rule
4+
---
5+
6+
<!--
7+
Before proposing new rule, please make sure it hasn't been posted already.
8+
You can see all open propositions here:
9+
https://github.com/intlify/eslint-plugin-svelte/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Feature%22
10+
-->
11+
12+
**Please describe what the rule should do:**
13+
<!-- A clear and concise description of what the rule should do. -->
14+
15+
16+
**What category should the rule belong to?**
17+
<!-- (place an "X" next to just one item) -->
18+
19+
[ ] Enforces code style (layout)
20+
[ ] Warns about a potential error (problem)
21+
[ ] Suggests an alternate way of doing something (suggestion)
22+
[ ] Other (please specify:)
23+
24+
**Provide 2-3 code examples that this rule should warn about:**
25+
26+
```svelte
27+
28+
```
29+
30+
31+
```svelte
32+
33+
```
34+
35+
36+
```svelte
37+
38+
```
39+
40+
**Additional context**
41+
<!-- Add any other context or screenshots about the feature request here. -->
42+

0 commit comments

Comments
 (0)