Skip to content

Commit b34106c

Browse files
fix: add meta tags for plugin exports (#183)
1 parent d7f346b commit b34106c

File tree

3 files changed

+68
-40
lines changed

3 files changed

+68
-40
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2.1
22

3-
supported-eslint-versions: &supported-eslint-versions ["local", "9"]
3+
supported-eslint-versions: &supported-eslint-versions ["local"]
44

55
deploy_filters: &deploy_filters
66
filters:

README.md

Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,74 @@ $ npm install eslint @babel/core @babel/eslint-parser @lwc/eslint-plugin-lwc --s
1010

1111
## Usage
1212

13-
Add `@lwc/eslint-plugin-lwc` to the `plugins` section of your configuration. Then configure the desired rules in the `rules` sections. Some of the syntax used in Lightning Web Components is not yet stage 4 (eg. class fields or decorators), and the out-of-the-box parser from ESLint doesn't support this syntax yet. In order to parse the LWC files properly, set the `parser` field to [`@babel/eslint-parser`](https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser).
14-
15-
Example of `.eslintrc`:
16-
17-
```json
18-
{
19-
"parser": "@babel/eslint-parser",
20-
"parserOptions": {
21-
"requireConfigFile": false,
22-
"babelOptions": {
23-
"parserOpts": {
24-
"plugins": ["classProperties", ["decorators", { "decoratorsBeforeExport": false }]]
25-
}
26-
}
13+
_Starting with v2.0.0, @lwc/eslint-plugin-lwc only supports eslint@v9. Use @lwc/eslint-plugin-lwc@v1.x for older versions of eslint._
14+
15+
Import `@lwc/eslint-plugin-lwc` and use it in the `plugins` section of your configuration as shown below. Then configure the desired rules in the `rules` sections. Some of the syntax used in Lightning Web Components is not yet stage 4 (eg. class fields or decorators), and the out-of-the-box parser from ESLint doesn't support this syntax yet. In order to parse the LWC files properly, set the `parser` field to [`@babel/eslint-parser`](https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser) in the `languageOptions` section of the eslint config.
16+
17+
Example of `eslint.config.js`:
18+
19+
```js
20+
const eslintPluginLwc = require('@lwc/eslint-plugin-lwc');
21+
const babelParser = require('@babel/eslint-parser');
22+
23+
module.exports = [
24+
{
25+
languageOptions: {
26+
parser: babelParser,
27+
parserOptions: {
28+
requireConfigFile: false,
29+
babelOptions: {
30+
parserOpts: {
31+
plugins: [
32+
'classProperties',
33+
['decorators', { decoratorsBeforeExport: false }],
34+
],
35+
},
36+
},
37+
},
38+
},
39+
plugins: {
40+
'@lwc/lwc': eslintPluginLwc, // https://github.com/salesforce/eslint-plugin-lwc
41+
},
42+
rules: {
43+
'@lwc/lwc/no-deprecated': 'error',
44+
'@lwc/lwc/valid-api': 'error',
45+
'@lwc/lwc/no-document-query': 'error',
46+
'@lwc/lwc/ssr-no-unsupported-properties': 'error',
47+
},
2748
},
28-
29-
"plugins": ["@lwc/eslint-plugin-lwc"],
30-
31-
"rules": {
32-
"@lwc/lwc/no-deprecated": "error",
33-
"@lwc/lwc/valid-api": "error",
34-
"@lwc/lwc/no-document-query": "error",
35-
"@lwc/lwc/ssr-no-unsupported-properties": "error"
36-
}
37-
}
49+
];
3850
```
3951

4052
### Usage with TypeScript
4153

42-
To enable working with TypeScript projects, install `@babel/preset-typescript` as a dependency add `"typescript"` to `parserOptions.babelOptions.parserOpts.plugins` in your `.eslintrc`.
54+
To enable working with TypeScript projects, install `@babel/preset-typescript` as a dependency add `"typescript"` to `languageOptions.parserOptions.babelOptions.parserOpts.plugins` in your `eslint.config.js`.
4355

4456
Example:
4557

46-
```json
47-
{
48-
"parserOptions": {
49-
"babelOptions": {
50-
"parserOpts": {
51-
"plugins": [
52-
"classProperties",
53-
["decorators", { "decoratorsBeforExport": false }],
54-
"typescript"
55-
]
56-
}
57-
}
58-
}
59-
}
58+
```js
59+
const eslintPluginLwc = require('@lwc/eslint-plugin-lwc');
60+
const babelParser = require('@babel/eslint-parser');
61+
62+
module.exports = [
63+
{
64+
languageOptions: {
65+
parser: babelParser,
66+
parserOptions: {
67+
requireConfigFile: false,
68+
babelOptions: {
69+
parserOpts: {
70+
plugins: [
71+
'classProperties',
72+
['decorators', { decoratorsBeforeExport: false }],
73+
'typescript',
74+
],
75+
},
76+
},
77+
},
78+
},
79+
},
80+
];
6081
```
6182

6283
For more details about configuration please refer to the dedicated section in the ESLint documentation: https://eslint.org/docs/user-guide/configuring

lib/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
'use strict';
88

9+
const { version } = require('../package.json');
10+
911
const rules = {
1012
'consistent-component-name': require('./rules/consistent-component-name'),
1113
'no-api-reassignments': require('./rules/no-api-reassignments'),
@@ -43,5 +45,10 @@ const rules = {
4345
};
4446

4547
module.exports = {
48+
// https://eslint.org/docs/latest/extend/plugins#meta-data-in-plugins
49+
meta: {
50+
name: '@lwc/eslint-plugin-lwc',
51+
version,
52+
},
4653
rules,
4754
};

0 commit comments

Comments
 (0)