@gitlab/eslint-plugin 9.2.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/CONTRIBUTING.md +40 -0
- package/docs/development.md +15 -0
- package/docs/rules/require-valid-i18n-helpers.md +41 -0
- package/docs/rules/vue-require-valid-i18n-helpers.md +42 -0
- package/docs/rules.md +2 -2
- package/gitlab_schema_apollo.graphql +29355 -0
- package/jest.config.js +6 -0
- package/lib/configs/default.js +0 -1
- package/lib/configs/i18n.js +2 -1
- package/lib/index.js +2 -1
- package/lib/rules/require-i18n-strings.js +5 -11
- package/lib/rules/require-valid-i18n-helpers.js +29 -0
- package/lib/rules/vue-require-valid-i18n-helpers.js +30 -0
- package/lib/utils/i18n-utils.js +68 -0
- package/lib/utils/rule-utils.js +27 -5
- package/package.json +3 -3
- package/docs/rules/require-string-literal-i18n-helpers.md +0 -26
- package/lib/rules/require-string-literal-i18n-helpers.js +0 -61
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## [10.0.1](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v10.0.0...v10.0.1) (2022-01-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **ci:** Generate GraphQL schema before running integration test ([d5e6d88](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/d5e6d88e5bb2e06d1ea923a95f7b1a425e5b09d0))
|
|
7
|
+
|
|
8
|
+
# [10.0.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v9.4.0...v10.0.0) (2021-11-03)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* lint against missing translation namespaces ([db00d87](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/db00d87e3877fa0fe538775280a54fd820c89572))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* require-string-literal-i18n-helpers and
|
|
19
|
+
vue-require-string-literal-i18n-helpers rules have been renamed to
|
|
20
|
+
require-valid-i18n-helpers and vue-require-valid-i18n-helpers
|
|
21
|
+
respectively.
|
|
22
|
+
|
|
23
|
+
# [9.4.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v9.3.0...v9.4.0) (2021-09-21)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* Ignore import path order ([9391f9c](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/9391f9c83fd016a8d6ea10e6eae6f44e79907c14))
|
|
29
|
+
|
|
30
|
+
# [9.3.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v9.2.0...v9.3.0) (2021-09-06)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* add vue-require-string-literal-i18n-helpers rule ([34fd19d](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/34fd19df7d14f5d1c62b6795927e0ff15e3aaf44))
|
|
36
|
+
|
|
1
37
|
# [9.2.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v9.1.0...v9.2.0) (2021-08-30)
|
|
2
38
|
|
|
3
39
|
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
## Developer Certificate of Origin and License
|
|
2
|
+
|
|
3
|
+
By contributing to GitLab B.V., you accept and agree to the following terms and
|
|
4
|
+
conditions for your present and future contributions submitted to GitLab B.V.
|
|
5
|
+
Except for the license granted herein to GitLab B.V. and recipients of software
|
|
6
|
+
distributed by GitLab B.V., you reserve all right, title, and interest in and to
|
|
7
|
+
your Contributions.
|
|
8
|
+
|
|
9
|
+
All contributions are subject to the Developer Certificate of Origin and license set out at [docs.gitlab.com/ce/legal/developer_certificate_of_origin](https://docs.gitlab.com/ce/legal/developer_certificate_of_origin).
|
|
10
|
+
|
|
11
|
+
_This notice should stay as the first item in the CONTRIBUTING.md file._
|
|
12
|
+
|
|
13
|
+
## Code of conduct
|
|
14
|
+
|
|
15
|
+
As contributors and maintainers of this project, we pledge to respect all people
|
|
16
|
+
who contribute through reporting issues, posting feature requests, updating
|
|
17
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
18
|
+
|
|
19
|
+
We are committed to making participation in this project a harassment-free
|
|
20
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
21
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
22
|
+
body size, race, ethnicity, age, or religion.
|
|
23
|
+
|
|
24
|
+
Examples of unacceptable behavior by participants include the use of sexual
|
|
25
|
+
language or imagery, derogatory comments or personal attacks, trolling, public
|
|
26
|
+
or private harassment, insults, or other unprofessional conduct.
|
|
27
|
+
|
|
28
|
+
Project maintainers have the right and responsibility to remove, edit, or reject
|
|
29
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
30
|
+
not aligned to this Code of Conduct. Project maintainers who do not follow the
|
|
31
|
+
Code of Conduct may be removed from the project team.
|
|
32
|
+
|
|
33
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
34
|
+
when an individual is representing the project or its community.
|
|
35
|
+
|
|
36
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior can be
|
|
37
|
+
reported by emailing contact@gitlab.com.
|
|
38
|
+
|
|
39
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org), version 1.1.0,
|
|
40
|
+
available at [https://contributor-covenant.org/version/1/1/0/](https://contributor-covenant.org/version/1/1/0/).
|
package/docs/development.md
CHANGED
|
@@ -18,3 +18,18 @@ Run `yarn createRule`, it will create:
|
|
|
18
18
|
- `docs/rules/<name>.js` (documentation)
|
|
19
19
|
- `lib/rules/<name>.js` (rule definition)
|
|
20
20
|
- `tests/rules/<name>.js` (rule unit tests)
|
|
21
|
+
|
|
22
|
+
## Testing
|
|
23
|
+
|
|
24
|
+
Run `yarn test` to execute the test suite, the suite includes rule tests and util tests.
|
|
25
|
+
Jest is used as the test runner for executing these tests.
|
|
26
|
+
|
|
27
|
+
### Rule tests
|
|
28
|
+
|
|
29
|
+
The [eslint ruletester](https://eslint.org/docs/developer-guide/unit-tests) is used to write tests for eslint rules, new tests should be added for new rules or updates to a rule.
|
|
30
|
+
|
|
31
|
+
All the current rule tests are available in the `tests/lib/rules` directory.
|
|
32
|
+
|
|
33
|
+
### Util tests
|
|
34
|
+
|
|
35
|
+
These utilities are useful to simplify writing new tests and can be found in the `test/lib/utils` directory.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @gitlab/require-valid-i18n-helpers
|
|
2
|
+
|
|
3
|
+
This rule enforces valid usages of the translation helpers (`__`, `s__` and `n__`). It requires the
|
|
4
|
+
following:
|
|
5
|
+
|
|
6
|
+
- All helpers should be called with string-literal arguments to ensure the strings are properly
|
|
7
|
+
collected by the `gettext:regenerate` script.
|
|
8
|
+
- `s__` requires a translation namespace to be provided.
|
|
9
|
+
|
|
10
|
+
## Rule Details
|
|
11
|
+
|
|
12
|
+
### Examples of **incorrect** code for this rule
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
// Invalid argument types
|
|
16
|
+
const label = __(LABEL);
|
|
17
|
+
const description = __(getDescription());
|
|
18
|
+
|
|
19
|
+
// Missing translation namespace
|
|
20
|
+
const namespacedTranslation = s__('NamespacedTranslation');
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Examples of **correct** code for this rule
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
// Valid argument type
|
|
27
|
+
const label = __('Some label');
|
|
28
|
+
|
|
29
|
+
// Valid translation namespace
|
|
30
|
+
const namespacedTranslation = s__('Namespace|Translation');
|
|
31
|
+
// or
|
|
32
|
+
const otherNamespacedTranslation = s__('Namespace', 'Other translation');
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Options
|
|
36
|
+
|
|
37
|
+
Nothing
|
|
38
|
+
|
|
39
|
+
## Related rules
|
|
40
|
+
|
|
41
|
+
- TBA
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @gitlab/vue-require-valid-i18n-helpers
|
|
2
|
+
|
|
3
|
+
This rule is like [require-valid-i18n-helpers](./require-valid-i18n-helpers.md) for Vue templates.
|
|
4
|
+
|
|
5
|
+
## Rule Details
|
|
6
|
+
|
|
7
|
+
### Examples of **incorrect** code for this rule
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<template>
|
|
11
|
+
<div>
|
|
12
|
+
<!-- Invalid argument types -->
|
|
13
|
+
{{ __(LABEL) }}
|
|
14
|
+
{{ __(getDescription()) }}
|
|
15
|
+
|
|
16
|
+
<!-- Missing translation namespace -->
|
|
17
|
+
{{ s__('NamespacedTranslation') }}
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Examples of **correct** code for this rule
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<template>
|
|
26
|
+
<div>
|
|
27
|
+
<!-- Valid argument type -->
|
|
28
|
+
{{ __('Some label') }}
|
|
29
|
+
|
|
30
|
+
<!-- Valid translation namespace -->
|
|
31
|
+
{{ s__('Namespace|Translation') }}
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Options
|
|
37
|
+
|
|
38
|
+
Nothing
|
|
39
|
+
|
|
40
|
+
## Related rules
|
|
41
|
+
|
|
42
|
+
- TBA
|
package/docs/rules.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
Available rules:
|
|
6
6
|
|
|
7
|
-
- [require-string-literal-i18n-helpers](./rules/require-string-literal-i18n-helpers.md): Requires
|
|
8
|
-
translation helpers to be called with string literals.
|
|
9
7
|
- [no-global-event-off](./rules/no-global-event-off.md): Throw an error when globally deregistering all event listeners.
|
|
10
8
|
- [no-runtime-template-compiler](./rules/no-runtime-template-compiler.md): Disallow components which rely on a runtime template compiler.
|
|
11
9
|
- [require-i18n-strings](./rules/require-i18n-strings.md): Detect a string which has been hard coded and requires externalization.
|
|
10
|
+
- [require-valid-i18n-helpers](./rules/require-valid-i18n-helpers.md): Enforces valid usage of translation helpers in JavaScript.
|
|
12
11
|
- [vue-emit-events-with-two-args](./rules/vue-emit-events-with-two-args.md): Throw an error when emit is called with more than two arguments.
|
|
13
12
|
- [vue-no-data-toggle](./rules/vue-no-data-toggle.md): Restrict the use of `data-toggle` bootstrap behaviors within Vue templates
|
|
14
13
|
- [vue-no-new-non-primitive-in-template](./rules/vue-no-new-non-primitive-in-template.md): Prevents non-primitive values from being declared in templates
|
|
15
14
|
- [vue-require-i18n-attribute-strings](./rules/vue-require-i18n-attribute-strings.md): Detect non externalized strings in vue `<template>` attributes
|
|
16
15
|
- [vue-require-i18n-strings](./rules/vue-require-i18n-strings.md): enforce no bare strings in vue `<template>`
|
|
17
16
|
- [vue-require-required-key](./rules/vue-require-required-key.md): Require the required key to be set
|
|
17
|
+
- [vue-require-valid-i18n-helpers](./rules/vue-require-valid-i18n-helpers.md): Enforces valid usage of translation helpers in Vue templates.
|
|
18
18
|
- [vue-slot-name-casing](./rules/vue-slot-name-casing.md): enforce specific casing for slot naming style in template
|