generated from wopjs/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
chore: add eslint plugin
Showing
6 changed files
with
574 additions
and
1,594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const plugin = { | ||
meta: { | ||
name: "eslint-plugin-disposable", | ||
}, | ||
rules: { | ||
"readonly-dispose": { | ||
create(context) { | ||
function checkProperty(node) { | ||
context.report({ | ||
fix(fixer) { | ||
return fixer.insertTextBefore(node, "readonly "); | ||
}, | ||
message: `Use readonly for Disposable to avoid leaks through accidental reassignment.`, | ||
node, | ||
}); | ||
} | ||
|
||
return { | ||
"PropertyDefinition[readonly!=true][key.name=dispose][typeAnnotation.typeAnnotation.typeName.name=/Disposer|IDisposable|DisposableType|DisposableDisposer|DisposableStore|DisposableMap|DisposableOne/]": | ||
checkProperty, | ||
"PropertyDefinition[readonly!=true][key.name=dispose][value.type=CallExpression][value.callee.name=/disposableStore|disposableMap|disposableOne/]": | ||
checkProperty, | ||
}; | ||
}, | ||
meta: { | ||
fixable: "code", | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
plugin, | ||
recommended: { | ||
plugins: { | ||
disposable: plugin, | ||
}, | ||
rules: { | ||
"disposable/readonly-dispose": "error", | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,9 @@ | ||
import jsEslint from "@eslint/js"; | ||
import eslintConfigPrettier from "eslint-config-prettier"; | ||
import importPlugin from "eslint-plugin-import"; | ||
import tsEslint from "typescript-eslint"; | ||
import wopjs, { defineConfig } from "@wopjs/eslint-config"; | ||
|
||
export default tsEslint.config( | ||
jsEslint.configs.recommended, | ||
...tsEslint.configs.recommended, | ||
importPlugin.flatConfigs.recommended, | ||
importPlugin.flatConfigs.typescript, | ||
eslintConfigPrettier, | ||
{ | ||
ignores: ["**/dist/", "**/public/", "**/docs/", "**/node_modules/"], | ||
}, | ||
{ | ||
languageOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
globals: { | ||
console: true, | ||
process: true, | ||
}, | ||
}, | ||
rules: { | ||
"import/no-unresolved": "off", | ||
"import/newline-after-import": [ | ||
"error", | ||
{ considerComments: true, count: 1 }, | ||
], | ||
"import/consistent-type-specifier-style": ["error", "prefer-top-level"], | ||
"import/no-duplicates": ["error", { considerQueryString: true }], | ||
"import/order": [ | ||
"error", | ||
{ | ||
"newlines-between": "always", | ||
alphabetize: { order: "asc", caseInsensitive: true }, | ||
groups: [ | ||
"object", | ||
"type", | ||
["builtin", "external", "internal"], | ||
["parent", "sibling", "index"], | ||
], | ||
pathGroups: [ | ||
{ | ||
pattern: "*.+(scss|css|less)", | ||
patternOptions: { matchBase: true }, | ||
group: "object", | ||
}, | ||
{ pattern: "~/**", group: "internal", position: "after" }, | ||
{ pattern: "../**", group: "parent", position: "before" }, | ||
], | ||
pathGroupsExcludedImportTypes: [ | ||
"builtin", | ||
"external", | ||
"object", | ||
"type", | ||
], | ||
distinctGroup: false, | ||
}, | ||
], | ||
}, | ||
import disposable from "./eslint-plugin.js"; | ||
|
||
export default defineConfig(...wopjs, disposable.recommended, { | ||
rules: { | ||
"@typescript-eslint/no-explicit-any": "off", | ||
}, | ||
{ | ||
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"], | ||
plugins: { | ||
"@typescript-eslint": tsEslint.plugin, | ||
}, | ||
languageOptions: { | ||
parser: tsEslint.parser, | ||
}, | ||
rules: { | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/consistent-type-imports": "error", | ||
"@typescript-eslint/no-empty-interface": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
argsIgnorePattern: "^_", | ||
varsIgnorePattern: "^_", | ||
destructuredArrayIgnorePattern: "^_", | ||
ignoreRestSiblings: true, | ||
}, | ||
], | ||
}, | ||
} | ||
); | ||
}); |
Oops, something went wrong.