Update linting and integrate prettier

This commit is contained in:
Giuseppe Criscione 2023-12-03 15:08:58 +01:00
parent 15c84ec94d
commit 37c3218c01
7 changed files with 483 additions and 555 deletions

View File

@ -7,6 +7,7 @@ end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
max_line_length = off
[*.md] [*.md]
trim_trailing_whitespace = false trim_trailing_whitespace = false

1
panel/.prettierrc Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -1,100 +0,0 @@
{
"extends": [
"stylelint-config-standard-scss",
"stylelint-config-idiomatic-order"
],
"ignoreFiles": [
"./assets/css/*.css",
"./assets/scss/*.scss",
"./assets/scss/vendor/*.scss"
],
"plugins": [
"stylelint-scss",
"stylelint-order"
],
"rules": {
"at-rule-empty-line-before": ["always", {
"except": [
"first-nested"
],
"ignore": [
"after-comment"
],
"ignoreAtRules": [
"if", "import", "include", "else", "extend", "media"
]
}],
"at-rule-name-space-after": "always",
"at-rule-no-unknown": null,
"at-rule-no-vendor-prefix": true,
"at-rule-semicolon-space-before": "never",
"block-closing-brace-newline-after": ["always", {
"ignoreAtRules": [
"if"
]
}],
"color-function-notation": null,
"color-hex-case": "lower",
"color-hex-length": "short",
"color-named": "never",
"comment-whitespace-inside": "always",
"declaration-block-trailing-semicolon": "always",
"declaration-colon-space-before": "never",
"declaration-colon-space-after": "always",
"declaration-block-no-duplicate-custom-properties": true,
"declaration-block-no-duplicate-properties": true,
"font-family-no-duplicate-names": true,
"indentation": 4,
"keyframes-name-pattern": null,
"max-line-length": 180,
"media-feature-range-operator-space-before": "always",
"media-feature-range-operator-space-after": "always",
"media-feature-parentheses-space-inside": "never",
"media-feature-colon-space-before": "never",
"media-feature-colon-space-after": "always",
"no-descending-specificity": true,
"no-duplicate-at-import-rules": true,
"no-duplicate-selectors": true,
"number-max-precision": 5,
"number-leading-zero": "always",
"property-no-vendor-prefix": null,
"scss/at-extend-no-missing-placeholder": null,
"scss/at-import-no-partial-leading-underscore": true,
"scss/at-rule-no-unknown": true,
"scss/dollar-variable-colon-space-after": "always",
"scss/dollar-variable-colon-space-before": "never",
"scss/dollar-variable-empty-line-before": null,
"scss/dollar-variable-first-in-block": [true, {
"ignore": [
"comments", "imports"
]
}],
"scss/dollar-variable-no-missing-interpolation": true,
"scss/no-duplicate-dollar-variables": [true, {
"ignoreInside": "at-rule"
}],
"scss/no-duplicate-mixins": true,
"scss/no-global-function-names": true,
"scss/operator-no-unspaced": true,
"rule-empty-line-before": ["always", {
"except": [
"after-single-line-comment"
],
"ignore": [
"inside-block"
]
}],
"selector-class-pattern": null,
"selector-combinator-space-after": "always",
"selector-list-comma-newline-after": "always-multi-line",
"selector-no-vendor-prefix": null,
"selector-pseudo-element-colon-notation": "double",
"shorthand-property-no-redundant-values": null,
"string-quotes": "single",
"value-keyword-case": ["lower", {
"ignoreProperties": [
"/^\\$/"
]
}]
}
}

136
panel/.stylelintrc.yaml Normal file
View File

@ -0,0 +1,136 @@
extends:
- stylelint-config-standard-scss
ignoreFiles:
- "./assets/css/*.css"
- "./assets/scss/*.scss"
- "./assets/scss/vendor/*.scss"
plugins:
- stylelint-scss
- stylelint-order
rules:
at-rule-empty-line-before:
- always
- except:
- first-nested
ignore:
- after-comment
ignoreAtRules:
- if
- import
- include
- else
- extend
- media
at-rule-no-unknown:
at-rule-no-vendor-prefix: true
color-function-notation:
color-hex-length: short
color-named: never
comment-whitespace-inside: always
declaration-block-no-duplicate-custom-properties: true
declaration-block-no-duplicate-properties: true
font-family-no-duplicate-names: true
keyframes-name-pattern:
no-descending-specificity: true
no-duplicate-at-import-rules: true
no-duplicate-selectors: true
number-max-precision: 5
property-no-vendor-prefix:
scss/at-extend-no-missing-placeholder:
scss/load-no-partial-leading-underscore: true
scss/at-rule-no-unknown: true
scss/dollar-variable-colon-space-after: always
scss/dollar-variable-colon-space-before: never
scss/dollar-variable-empty-line-before:
scss/dollar-variable-first-in-block:
- true
- ignore:
- comments
- imports
scss/dollar-variable-no-missing-interpolation: true
scss/no-duplicate-dollar-variables:
- true
- ignoreInside: at-rule
scss/no-duplicate-mixins: true
scss/no-global-function-names: true
scss/operator-no-unspaced: true
rule-empty-line-before:
- always
- except:
- after-single-line-comment
ignore:
- inside-block
selector-class-pattern:
selector-no-vendor-prefix:
selector-pseudo-element-colon-notation: double
shorthand-property-no-redundant-values:
value-keyword-case:
- lower
- ignoreProperties:
- "/^\\$/"
order/properties-order:
- - composes
- all
- position
- z-index
- top
- right
- bottom
- left
- display
- overflow
- width
- min-width
- max-width
- height
- min-height
- max-height
- box-sizing
- flex
- flex-basis
- flex-direction
- flex-flow
- flex-grow
- flex-shrink
- flex-wrap
- align-content
- align-items
- align-self
- justify-content
- order
- padding
- padding-top
- padding-right
- padding-bottom
- padding-left
- border
- border-width
- border-style
- border-color
- border-radius
- border-top
- border-top-width
- border-top-style
- border-top-color
- border-top-radius
- border-right
- border-right-width
- border-right-style
- border-right-color
- border-right-radius
- border-bottom
- border-bottom-width
- border-bottom-style
- border-bottom-color
- border-bottom-radius
- border-left
- border-left-width
- border-left-style
- border-left-color
- border-left-radius
- margin
- margin-top
- margin-right
- margin-bottom
- margin-left
- unspecified: bottomAlphabetical

View File

@ -1,61 +1,40 @@
import js from '@eslint/js'; import js from "@eslint/js";
import globals from 'globals'; import globals from "globals";
import eslintConfigPrettier from "eslint-config-prettier";
export default [ export default [
js.configs.recommended, js.configs.recommended,
{ {
'languageOptions': { languageOptions: {
'ecmaVersion': 6, ecmaVersion: 11,
'globals': { globals: {
...globals.browser, ...globals.browser,
'$': 'readonly', $: "readonly",
'$$': 'readonly', $$: "readonly",
'Formwork': 'readonly', Formwork: "readonly",
}, },
'sourceType': 'module', sourceType: "module",
}, },
'rules': { rules: {
'arrow-body-style': ['error', 'as-needed'], "arrow-body-style": ["error", "as-needed"],
'arrow-parens': ['error'], curly: ["error", "all"],
'arrow-spacing': ['error'], eqeqeq: ["error", "always"],
'brace-style': ['error', '1tbs'], "no-else-return": ["error"],
'comma-dangle': ['error', { 'objects': 'always-multiline' }], "no-lonely-if": ["error"],
'curly': ['error', 'all'], "no-unneeded-ternary": ["error"],
'eqeqeq': ['error', 'always'], "no-var": ["error"],
'indent': ['error', 4], "one-var": [
'keyword-spacing': ['error'], "error",
'linebreak-style': ['error', 'unix'], {
'new-parens': ['error'], initialized: "never",
'no-else-return': ['error'], uninitialized: "always",
'no-lonely-if': ['error'], },
'no-multi-spaces': ['error'], ],
'no-multiple-empty-lines': ['error', { 'max': 1 }], "operator-assignment": ["error"],
'no-trailing-spaces': ['error'], "prefer-arrow-callback": ["error"],
'no-unneeded-ternary': ['error'], "prefer-const": ["error"],
'no-var': ['error'], "prefer-template": ["error"],
'object-curly-newline': ['error', { 'multiline': true }],
'object-curly-spacing': ['error', 'always'],
'object-property-newline': ['error'],
'one-var': ['error', {
'initialized': 'never',
'uninitialized': 'always',
}],
'operator-assignment': ['error'],
'prefer-arrow-callback': ['error'],
'prefer-const': ['error'],
'prefer-template': ['error'],
'quotes': ['error', 'single'],
'space-before-function-paren': ['error', {
'anonymous': 'always',
'named': 'never',
}],
'space-infix-ops': ['error'],
'space-unary-ops': ['error', {
'nonwords': false,
'words': true,
}],
'spaced-comment': ['error'],
'template-curly-spacing': ['error', 'never'],
}, },
} },
eslintConfigPrettier,
]; ];

View File

@ -1,42 +1,44 @@
{ {
"name": "formwork-panel", "name": "formwork-panel",
"description": "Formwork CMS Administration Panel", "description": "Formwork CMS Administration Panel",
"author": "Giuseppe Criscione", "author": "Giuseppe Criscione",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/getformwork/formwork.git" "url": "git+https://github.com/getformwork/formwork.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/getformwork/formwork/issues" "url": "https://github.com/getformwork/formwork/issues"
}, },
"scripts": { "scripts": {
"build": "yarn build:css && yarn build:js", "build": "yarn build:css && yarn build:js",
"build:css": "sass ./src/scss/panel.scss:./assets/css/panel.min.css ./src/scss/panel-dark.scss:./assets/css/panel-dark.min.css --style=compressed --no-source-map", "build:css": "sass ./src/scss/panel.scss:./assets/css/panel.min.css ./src/scss/panel-dark.scss:./assets/css/panel-dark.min.css --style=compressed --no-source-map",
"build:js": "esbuild ./src/js/main.js --outfile=./assets/js/app.min.js --bundle --format=iife --global-name=Formwork --target=es6 --minify", "build:js": "esbuild ./src/js/main.js --outfile=./assets/js/app.min.js --bundle --format=iife --global-name=Formwork --target=es6 --minify",
"watch:css": "yarn build:css --watch", "watch:css": "yarn build:css --watch",
"watch:js": "yarn build:js --watch", "watch:js": "yarn build:js --watch",
"lint:css": "stylelint './src/scss/**/*.scss' --fix", "lint": "yarn lint:css && yarn lint:js",
"lint:js": "eslint './src/js/**' --fix" "lint:css": "prettier './src/scss/**/*.scss' --write && stylelint './src/scss/**/*.scss' --fix",
}, "lint:js": "prettier './src/js/**/*.js' --write && eslint './src/js/**/*.js' --fix"
"dependencies": { },
"chartist": "^1.3.0", "dependencies": {
"codemirror": "^5.65.11", "chartist": "^1.3.0",
"sortablejs": "^1.15.0" "codemirror": "^5.65.16",
}, "sortablejs": "^1.15.1"
"devDependencies": { },
"@eslint/js": "^8.41.0", "devDependencies": {
"esbuild": "^0.19.2", "@eslint/js": "^8.55.0",
"eslint": "^8.40.0", "esbuild": "^0.19.8",
"globals": "^13.20.0", "eslint": "^8.55.0",
"postcss": "^8.4.19", "eslint-config-prettier": "^9.1.0",
"sass": "^1.66.1", "globals": "^13.23.0",
"stylelint": "^14.16.1", "postcss": "^8.4.32",
"stylelint-config-idiomatic-order": "^9.0.0", "prettier": "3.1.0",
"stylelint-config-standard-scss": "^6.1.0", "sass": "^1.69.5",
"stylelint-order": "^6.0.1", "stylelint": "^15.11.0",
"stylelint-scss": "^4.7.0" "stylelint-config-standard-scss": "^11.1.0",
}, "stylelint-order": "^6.0.3",
"packageManager": "yarn@4.0.2" "stylelint-scss": "^5.3.1"
},
"packageManager": "yarn@4.0.2"
} }

File diff suppressed because it is too large Load Diff