Skip to content

Commit

Permalink
feat: importable config
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 9, 2022
1 parent a9051f3 commit 0cc5a6e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
"engines": {
"node": ">=14.16.0"
},
"main": "dist/index.js",
"type": "commonjs",
"files": [
"dist/**"
"dist",
"package.json",
"README.md",
"LICENSE.txt"
],
"dependencies": {
"@typescript-eslint/utils": "^5.27.0"
Expand Down
29 changes: 12 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,22 @@ import { flagCrossReferences } from './rules/flagCrossReferences';
export = {
configs: {
recommended: {
plugins: ['@salesforce/sf-plugin'],
plugins: ['sf-plugin'],
rules: {
'@salesforce/sf-plugin/no-duplicate-short-characters': 'error',
'@salesforce/sf-plugin/flag-case': 'error',
'@salesforce/sf-plugin/no-hardcoded-messages': 'warn',
'@salesforce/sf-plugin/flag-cross-references': 'error',
'sf-plugin/no-duplicate-short-characters': 'error',
'sf-plugin/flag-case': 'error',
'sf-plugin/no-hardcoded-messages': 'warn',
'sf-plugin/flag-cross-references': 'error',
},
},
},
rules: {
'no-duplicate-short-characters': {
create: noDuplicateShortCharacters,
},
'flag-case': {
create: flagCasing,
},
'no-hardcoded-messages': {
create: extractMessage,
},
'flag-cross-references': {
create: flagCrossReferences,
},
'no-duplicate-short-characters': noDuplicateShortCharacters,

'flag-case': flagCasing,

'no-hardcoded-messages': extractMessage,

'flag-cross-references': flagCrossReferences,
},
};
14 changes: 13 additions & 1 deletion src/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

Helpful eslint rules for sf plugins.

## Consume

`yarn add --dev eslint-plugin-sf-plugin`

in your `.eslintrc`, add `"plugin:sf-plugin/recommended"` to your`extends` property. example:

```js
module.exports = {
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license', "plugin:sf-plugin/recommended"],
}
```

## Developing

Use <https://astexplorer.net/> and choose `@typescript/eslint-parser` from the `</>` dropdown. This'll give you the AST as the parser sees it.
Expand All @@ -15,7 +27,7 @@ useful posts

* <https://medium.com/bigpicture-one/writing-custom-typescript-eslint-rules-with-unit-tests-for-angular-project-f004482551db>

be sure to import/export your rule with index.ts
be sure to import/export your rule with index.ts and add it the configs sections

## Testing

Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"compilerOptions": {
"outDir": "./dist",
"rootDir": "src",
"target": "esnext",
"rootDir": "./src",
"target": "es2019",
"moduleResolution": "node",
"esModuleInterop": true,
"module": "commonjs",
"declaration": false,
"declarationMap": false,
},
"include": ["src/**/*.ts", "src/index.js"]
}

0 comments on commit 0cc5a6e

Please sign in to comment.