Skip to content

Commit ce59119

Browse files
committed
chore: update linters to use prettier
1 parent 3aad32d commit ce59119

8 files changed

Lines changed: 436 additions & 800 deletions

File tree

.editorconfig

Lines changed: 0 additions & 10 deletions
This file was deleted.

.eslintrc.json

Lines changed: 107 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,109 @@
11
{
2-
"env": {
3-
"browser": true,
4-
"node": true,
5-
"es2021": true,
6-
"es2022": true,
7-
"webextensions": true
8-
},
9-
"extends": ["eslint:recommended", "airbnb-base"],
10-
"globals": {
11-
"_browser": "writable",
12-
"browser": "readonly"
13-
},
14-
"ignorePatterns": [
15-
"/etc",
16-
"build",
17-
"dist",
18-
"node_modules"
19-
],
20-
"overrides": [
21-
{
22-
"files": ["*.svelte"],
23-
"processor": "svelte3/svelte3"
24-
}
25-
],
26-
"parserOptions": {
27-
"ecmaVersion": "latest",
28-
"sourceType": "module"
29-
},
30-
"plugins": ["svelte3"],
31-
"rules": {
32-
"array-callback-return": "off",
33-
"arrow-body-style": "off",
34-
"arrow-parens": ["error", "as-needed"],
35-
"comma-dangle": ["error", "never"],
36-
"consistent-return": "off",
37-
"default-case": "off",
38-
"eqeqeq": ["error", "smart"],
39-
"global-require": "off",
40-
"guard-for-in": "warn",
41-
"import/extensions": "off",
42-
"import/first": "off",
43-
"import/no-mutable-exports": "off",
44-
"import/no-extraneous-dependencies": ["error", {
45-
"devDependencies": true
46-
}],
47-
"import/prefer-default-export": "off",
48-
"import/no-unresolved": "off",
49-
"indent": ["error", 4, {"SwitchCase": 1}],
50-
"max-len": "off",
51-
"no-alert":"off",
52-
"no-await-in-loop":"warn",
53-
"no-confusing-arrow": ["warn", {
54-
"allowParens": true,
55-
"onlyOneSimpleParam": true
56-
}],
57-
"no-console": ["warn", {"allow": ["info", "warn", "error"]}],
58-
"no-continue": "off",
59-
"no-else-return": ["error", {"allowElseIf": true}],
60-
"no-nested-ternary": "off",
61-
"no-param-reassign": ["warn", { "props": false }],
62-
"no-plusplus": "off",
63-
"no-restricted-syntax": "off",
64-
"no-return-assign": "off",
65-
"no-underscore-dangle":"off",
66-
"no-unused-expressions": "off",
67-
"no-use-before-define": ["error", {
68-
"functions": false,
69-
"classes": true,
70-
"variables": true,
71-
"allowNamedExports": false
72-
}],
73-
"object-curly-newline": ["error", {"consistent": true}],
74-
"object-curly-spacing": ["error", "never"],
75-
"one-var": "off",
76-
"one-var-declaration-per-line": "off",
77-
"prefer-destructuring": "off",
78-
"prefer-object-spread": "warn",
79-
"quotes": ["error", "double"],
80-
"import/no-namespace": "warn"
81-
}
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": ["prettier"],
8+
"globals": {
9+
"browser": "readonly",
10+
"webkit": "readonly"
11+
},
12+
"ignorePatterns": ["node_modules", "xcode"],
13+
"parserOptions": {
14+
"ecmaVersion": 13,
15+
"sourceType": "module"
16+
},
17+
"overrides": [
18+
{
19+
"files": ["*.svelte"],
20+
// why use this instead of the svelte3 plugin?
21+
// eslint prettier errors are ignored for stylelint, and...
22+
// https://github.com/prettier/eslint-plugin-prettier#svelte-support
23+
"parser": "svelte-eslint-parser"
24+
}
25+
],
26+
"plugins": ["prettier"],
27+
"rules": {
28+
"curly": ["error", "multi-line"],
29+
"eqeqeq": ["error", "smart"],
30+
"max-len": [
31+
"error",
32+
{
33+
"code": 80,
34+
"ignoreRegExpLiterals": true,
35+
"tabWidth": 4
36+
}
37+
],
38+
"no-bitwise": "error",
39+
"no-console": [1, {"allow": ["error", "info", "warn"]}],
40+
"no-duplicate-imports": "error",
41+
"no-mixed-operators": "error",
42+
"no-multi-str": "error",
43+
"no-restricted-syntax": [
44+
"error",
45+
{
46+
"selector": "VariableDeclaration[kind='var'][declare!=true]",
47+
"message": "Unexpected var, use let or const instead."
48+
}
49+
],
50+
"no-useless-concat": "error",
51+
"no-unused-vars": [
52+
"error",
53+
{
54+
"args": "all",
55+
"argsIgnorePattern": "^_",
56+
"caughtErrors": "all",
57+
"caughtErrorsIgnorePattern": "^_",
58+
"destructuredArrayIgnorePattern": "^_"
59+
}
60+
],
61+
"no-undef": "error",
62+
"no-use-before-define": [
63+
"error",
64+
{
65+
"classes": true,
66+
"functions": false,
67+
"variables": true
68+
}
69+
],
70+
"no-var": "off",
71+
"operator-assignment": ["error", "always"],
72+
"padding-line-between-statements": [
73+
"error",
74+
// {
75+
// "blankLine": "always",
76+
// "prev": "*",
77+
// "next": ["return", "throw"]
78+
// },
79+
// {
80+
// "blankLine": "always",
81+
// "prev": ["const", "let", "var"],
82+
// "next": "*"
83+
// },
84+
// {
85+
// "blankLine": "any",
86+
// "prev": ["const", "let", "var"],
87+
// "next": ["const", "let", "var"]
88+
// },
89+
{
90+
"blankLine": "always",
91+
"prev": ["directive", "import"],
92+
"next": "*"
93+
},
94+
{
95+
"blankLine": "any",
96+
"prev": ["directive", "import"],
97+
"next": ["directive", "import"]
98+
}
99+
],
100+
"prefer-const": "error",
101+
"prefer-template": "error",
102+
"quotes": [
103+
"error",
104+
"double",
105+
{"allowTemplateLiterals": false, "avoidEscape": true}
106+
],
107+
"prettier/prettier": "error"
108+
}
82109
}

.prettierignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
!.env.example
2+
.DS_Store
3+
.env
4+
.env.*
5+
*.png
6+
*.svg
7+
/build
8+
/package
9+
node_modules
10+
xcode
11+
12+
# Ignore files for PNPM, NPM and YARN
13+
pnpm-lock.yaml
14+
package-lock.json
15+
yarn.lock

.prettierrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": false,
4+
"bracketSameLine": false,
5+
"plugins": ["prettier-plugin-svelte"],
6+
"printWidth": 80,
7+
"quoteProps": "as-needed",
8+
"semi": true,
9+
"singleAttributePerLine": false,
10+
"singleQuote": false,
11+
"tabWidth": 4,
12+
"trailingComma": "none",
13+
"useTabs": true,
14+
"overrides": [
15+
{"files": "*.svelte", "options": {"parser": "svelte"}},
16+
{"files": "*.yml", "options": {"tabWidth": 2, "useTabs": false}}
17+
]
18+
}

.stylelintrc.json

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
{
2-
"extends": [
3-
"stylelint-config-recommended",
4-
"stylelint-config-standard",
5-
"stylelint-config-html/svelte"
6-
],
7-
"ignoreFiles": [
8-
"**/build/**",
9-
"**/dist/**",
10-
"**/etc/**",
11-
"**/node_modules/**",
12-
"**/reset.css"
13-
],
14-
"rules": {
15-
"alpha-value-notation": "number",
16-
"comment-empty-line-before": ["always",{
17-
"ignore": ["after-comment", "stylelint-commands"]
18-
}],
19-
"custom-property-empty-line-before": null,
20-
"indentation": 4,
21-
"max-empty-lines": 1,
22-
"no-descending-specificity": null,
23-
"property-no-vendor-prefix": null,
24-
"selector-class-pattern": null,
25-
"selector-pseudo-class-no-unknown": [true, {
26-
"ignorePseudoClasses": ["global"]
27-
}]
28-
}
2+
"extends": [
3+
"stylelint-config-standard",
4+
"stylelint-prettier/recommended",
5+
"stylelint-config-prettier"
6+
],
7+
"ignoreFiles": [
8+
"**/node_modules/**",
9+
"**/reset.css",
10+
"xcode/**/*"
11+
],
12+
"plugins": ["stylelint-order"],
13+
"rules": {
14+
"alpha-value-notation": "number",
15+
"custom-property-empty-line-before": "never",
16+
"declaration-block-no-duplicate-properties": true,
17+
"order/properties-alphabetical-order": true,
18+
"property-no-vendor-prefix": true,
19+
"selector-class-pattern": [
20+
"^[a-z]([-]?[a-z0-9]+)*(__[a-z0-9]([-]?[a-z0-9]+)*)?(--[a-z0-9]([-]?[a-z0-9]+)*)?$",
21+
{
22+
"resolveNestedSelectors": true,
23+
"message": "Expected class selector to match BEM CSS pattern https://en.bem.info/methodology/css. Regex examples: https://regex101.com/r/DhEhbS/1"
24+
}
25+
],
26+
"selector-pseudo-class-no-unknown": [
27+
true,
28+
{
29+
"ignorePseudoClasses": ["global"]
30+
}
31+
]
32+
},
33+
"overrides": [
34+
{
35+
"customSyntax": "postcss-html",
36+
"files": ["**/*svelte"]
37+
}
38+
]
2939
}

.vscode/settings.json

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
{
2-
"editor.formatOnSave": false,
3-
"files.associations": {
4-
".htmlhintrc": "json"
5-
},
6-
"eslint.validate": [
7-
"svelte"
8-
],
9-
"stylelint.validate": [
10-
"css",
11-
"postcss",
12-
"svelte"
13-
],
14-
"svelte.plugin.svelte.compilerWarnings": {
15-
"a11y-missing-attribute": "error"
16-
},
17-
"svelte.plugin.svelte.rename.enable": false,
18-
"[svelte]": {
19-
"editor.defaultFormatter": "svelte.svelte-vscode"
20-
},
21-
"[css]": {
22-
"editor.defaultFormatter": "stylelint.vscode-stylelint"
23-
}
2+
"eslint.validate": ["javascript", "svelte"],
3+
"stylelint.validate": ["css", "postcss", "svelte"],
4+
"[svelte]": {
5+
"editor.defaultFormatter": "svelte.svelte-vscode"
6+
}
247
}

package.json

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
{
2-
"name": "userscripts",
3-
"private": true,
4-
"type": "module",
5-
"scripts": {
6-
"dev": "vite",
7-
"build": "vite build",
8-
"lint-js": "eslint ./",
9-
"lint-css": "stylelint '**/*.{css,svelte}'"
10-
},
11-
"devDependencies": {
12-
"@sveltejs/vite-plugin-svelte": "^2.0.3",
13-
"autoprefixer": "^10.4.13",
14-
"cm-show-invisibles": "^3.1.0",
15-
"codemirror": "^5.65.12",
16-
"eslint": "^8.35.0",
17-
"eslint-config-airbnb-base": "^15.0.0",
18-
"eslint-plugin-import": "^2.27.5",
19-
"eslint-plugin-svelte3": "^4.0.0",
20-
"postcss-html": "^1.5.0",
21-
"stylelint": "^15.2.0",
22-
"stylelint-config-html": "^1.1.0",
23-
"stylelint-config-recommended": "^10.0.1",
24-
"stylelint-config-standard": "^30.0.1",
25-
"svelte": "^3.55.1",
26-
"vite": "^4.1.4"
27-
}
2+
"name": "userscripts",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build",
8+
"lint-js": "eslint ./",
9+
"lint-css": "stylelint '**/*.{css,svelte}'"
10+
},
11+
"devDependencies": {
12+
"@sveltejs/vite-plugin-svelte": "^2.0.3",
13+
"autoprefixer": "^10.4.13",
14+
"cm-show-invisibles": "^3.1.0",
15+
"codemirror": "^5.65.12",
16+
"eslint": "^8.35.0",
17+
"eslint-config-prettier": "^8.8.0",
18+
"eslint-plugin-prettier": "^4.2.1",
19+
"eslint-plugin-svelte": "^2.27.2",
20+
"postcss": "^8.4.23",
21+
"postcss-html": "^1.5.0",
22+
"prettier": "^2.8.8",
23+
"prettier-plugin-svelte": "^2.10.0",
24+
"stylelint": "^14.16.1",
25+
"stylelint-config-html": "^1.1.0",
26+
"stylelint-config-prettier": "^9.0.5",
27+
"stylelint-config-standard": "^29.0.0",
28+
"stylelint-order": "^6.0.3",
29+
"stylelint-prettier": "^3.0.0",
30+
"svelte": "^3.55.1",
31+
"vite": "^4.1.4"
32+
}
2833
}

0 commit comments

Comments
 (0)