ESLint mono-plugin bundler with strict, opinionated defaults for JavaScript, TypeScript, Svelte, HTML, Tailwind/CSS, JSON, JSONC, YAML, and Mocha.
npm install lintedlinted
> [!CAUTION]
> ___DO NOT USE - DOCUMENTATION IS SIGNIFICANTLY OUTDATED AS OF AUGUST 4, 2024___
---
ESLint mono-plugin bundler with strict, opinionated defaults for JavaScript, TypeScript, Svelte, HTML, Tailwind/CSS, JSON, JSONC, YAML, and Mocha.
1. Languages
2. Features
3. Limitation
4. Install
5. Roadmap
6. Rule Logic (Advanced)
> [!NOTE]
> _See language support __roadmap.___
- __JavaScript:__ eslint
- __TypeScript:__ @typescript-eslint + eslint
- __Svelte:__ eslint-plugin-svelte + @typescript-eslint + eslint
- __HTML:__ @html-eslint
- __JSON & JSONC:__ eslint-plugin-jsonc
- __YAML:__ eslint-plugin-yml
No need to install 17 plugins and 12 parsers: each language's latest plugin is bundled and configured.
No need to remember each plugin's parserOptions; you won't have to do _this_ just to enable Svelte linting:
``javascript`
// lint TypeScript blocks in Svelte
plugins: {
"@typescript-eslint": ts,
svelte,
},
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
parser: svelteParser,
parserOptions: {
parser: tsParser,
ecmaVersion: "latest",
sourceType: "module",
project: "tsconfig.json",
extraFileExtensions: [".svelte"],
},
},
processor: "svelte/svelte",
`javascript`
linted();
`javascript
import linted from "linted";
export default linted();
`
- includes (scoped glob patterns)ignores
- (global glob patterns and other options)overrides
- (scoped rule statements)
#### includes _(Scoped)_
`javascript
import linted from "linted";
linted(
{
/ includes /
js: [
"scripts/*//.{js,mjs}",
"*.config.js",
], / example: array of glob patterns to lint using JavaScript rules /
ts: [
"src/*/.ts",
"*.config.ts",
],
// svelte: [],
// html: [],
/ ...json, jsonc, yml, /
},
);
`
#### ignores _(Global)_
`javascript
import linted from "linted";
linted(
{ / includes / },
{
/ ignores /
gitignore: true, / (default) never lint any git-ignored file /
ignoreArtifacts: true, / (default) never lint "//package-lock.json" */
global: [], / array of glob patterns to never lint /
},
)
`
#### overrides _(Scoped)_
`javascriptts
linted(
{/ includes /},
{/ ignores /},
{
/ overrides /
overrideJs: {}, / js rule overrides /
overrideTs: {
/* Overrides apply to scope,js
* but NOT to scope,svelte
* NOR to scope.`
*/
"no-unused-vars": "off", / example: ESLint base rule /
"@typescript-eslint/indent": "warn", / example: TypeScript plugin rule /
}, / js rule overrides /
/ ...overrideTs, overrideSvelte, overrideHtml, overrideJson, overrideJsonc, overrideYml, /
},
);
In __TypeScript__ projects, skipLibCheck must be true.
By default, skipLibCheck is false. To set it to true:
#### tsconfig.json
`jsonc`
{
"compilerOptions": {
"skipLibCheck": true,
},
}
#### _...or_ tsc CLI option
`bash`
tsc --skipLibCheck
`bash`
npm i -D eslint@^8.57 linted
1. Create eslint.config.js in your project root.
1. In eslint.config.js:linted
- Import function .
`javascript`
import linted from "linted";
- Export linted with optional arguments:
`javascript
import linted from "linted";
export default linted(
// ...
);
`
---
#### Tailwind
- Tailwind
- CSS
#### HTML Embeds
- Embedded CSS
- Svelte Interaction TBD
- .svelte-embedded HTML (on top of Svelte HTML rules)
- .html files in Svelte projects (e.g. title not required)
- Should Svelte-Linter handle all .html / HTML-embedded linting for Svelte projects, and HTML-Linter only handles non-Svelte projects?
#### JSON (Custom Schema Validation)
- JSON Custom Schema Validation
---
Each scope maps to a unique language:
- __js:__ JavaScriptts
- __:__ TypeScriptsvelte
- __:__ Sveltehtml
- __:__ HTMLjson
- __:__ JSONjsonc
- __:__ JSONCyml
- __:__ YAML
Each scope supports:
- all base ESLint rules
- all rules from its language's __plugins__
#### Default Rules
- Each language has a set of default rules.
#### Language-Aggregate scope
A language can be an extension of or depend on another language.
For example:
- TypeScript extends JavaScript
- Svelte depends on TypeScript (which extends JavaScript)
For such a language, its scope's default rules are aggregated with the default rules of extended or consumed languages by scope precedence:
- __js:__ jsts
- __:__ js < tssvelte
- __:__ js < ts < sveltehtml
- __:__ htmljson
- __:__ jsonjsonc
- __:__ json < jsoncyml
- __:__ yml
#### Global Ignores
##### .gitignore
By default, linted ignores all files in .gitignore. This behavior can be disabled.
##### package-lock.json
*/.package-lock.json is always skipped. _This cannot be overriden._
##### ignores
Additional glob patterns supplied if matched by a file will skip linting that file, even if a scope pattern matches the file.
#### Scoped Includes
Files specified in scope are appended to the following default files:
`javascript`
{
js: [
"{src,static}/*/.{js,mjs,cjs}",
"*.{js,mjs,cjs}",
],
ts: [
"{src,static}/*/.{ts,mts,cts}",
"*.{ts,mts,cts}",
],
svelte: ["{src,static}/*/.svelte"],
html: [
"{src,static}/*/.html",
"*.html",
],
json: [
"{src,static}/*/.json",
"*.json",
],
jsonc: [
"tsconfig.json",
"{src,static}/*/.jsonc",
"*.jsonc",
],
yml: [
".github/workflows/*.{yml,yaml}",
"{src,static}/*/.{yml,yaml}",
"*.{yml,yaml}",
],
},
#### Scope Conflict
- If a given file matches more than one scope glob, then the set of all matching scopes' rules are applied to the file.scope
- If any rule is specified in more than one matching a given file, the specifies a rule, then the highest-precedence scope's rule specification wins.
##### Scope Precedence (low to high)
`bash`
js
ts
svelte
html
json
jsonc
yml
ignores (global)
Overrides are per-__scope.__
#### Example
overrideTs rules apply to files which:
- ✅ ONLY match scope ts.ts
- ✅ match scope and any number of lower precedence scopes (e.g. js).overrideTs
> [!NOTE]
> rules do __NOT__ apply to files which:ts
>
> - TBD
- ❌ match scope and at least one higher precedence scope (e.g. svelte), even if the higher precedence scope includes ts language default rules (e.g. svelte includes ts default rules, but NOT overrideTs` rules).