Browse Source

init work to upgrade node and linting

pull/6059/head
danstarns 2 years ago
parent
commit
b177c9b5b0
  1. 18
      .editorconfig
  2. 26
      .eslintrc
  3. 74
      .eslintrc.js
  4. 9
      .github/workflows/publish.yml
  5. 18
      .github/workflows/quailty.yml
  6. 10
      .prettierrc
  7. 8
      babel.config.js
  8. 12
      jest.config.js
  9. 78
      package.json
  10. 16
      tsconfig.json
  11. 6234
      yarn.lock

18
.editorconfig

@ -1,18 +0,0 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.js]
charset = utf-8
indent_style = space
indent_size = 2
quote_type = single
[*.ts]
charset = utf-8
indent_style = space
indent_size = 2
quote_type = single
max_line_length = 120

26
.eslintrc

@ -1,26 +0,0 @@
{
"env": {
"browser": true,
"node": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"strict": 0,
"quotes": ["warn", "single", { "avoidEscape": true }],
"eol-last": ["warn", "always"],
"no-mixed-requires": [0],
"no-underscore-dangle": [0]
},
"overrides": [{
"files": ["*.ts"],
"parser": "@typescript-eslint/parser"
}],
"ignorePatterns": [
"dist/*",
"locale/*",
"private/*"
]
}

74
.eslintrc.js

@ -0,0 +1,74 @@
module.exports = {
root: true, // Add this to indicate this is the root ESLint configuration
env: {
browser: true,
node: true,
'jest/globals': true
},
globals: {
$: true,
grapesjs: true
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'jest'],
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module'
},
rules: {
'no-var': 'off',
'prefer-const': 'off',
'no-prototype-builtins': 'off',
'no-useless-escape': 'off',
'prefer-rest-params': 'off',
'no-empty': 'off',
'prefer-spread': 'off',
'no-extra-boolean-cast': 'off',
'no-unsafe-optional-chaining': 'off',
'no-shadow-restricted-names': 'off',
'no-cond-assign': 'off',
'no-fallthrough': 'off',
'no-sparse-arrays': 'off',
'no-redeclare': 'off',
'no-control-regex': 'off',
'no-constant-condition': 'off',
'no-misleading-character-class': 'off',
'no-undef': 'off',
'no-func-assign': 'off',
'no-regex-spaces': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unnecessary-type-const': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
indent: ['error', 2],
quotes: ['error', 'single'],
'linebreak-style': ['error', 'unix'],
'max-len': ['error', { code: 120 }],
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }]
},
overrides: [
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
rules: {
indent: ['error', 2],
quotes: ['error', 'single']
}
},
{
files: ['*.js'],
rules: {
indent: ['error', 2],
quotes: ['error', 'single']
}
}
]
};

9
.github/workflows/publish.yml

@ -9,15 +9,14 @@ jobs:
if: ${{ false }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '12.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- run: yarn --frozen-lockfile
- run: yarn build
- run: npm run lint
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

18
.github/workflows/build.yml → .github/workflows/quailty.yml

@ -2,27 +2,29 @@ name: Tests
on:
push:
branches: [ dev ]
branches: [dev]
pull_request:
branches: [ dev ]
branches: [dev]
jobs:
build:
quailty:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.17, 16.x]
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --frozen-lockfile
- run: yarn build
- run: npm run lint
- run: npm run lint:ts
- run: npm run format:check
- run: yarn build
- run: npm run ts:build:check
- run: npm test
- run: npm test

10
.prettierrc

@ -0,0 +1,10 @@
{
"endOfLine": "lf",
"insertPragma": false,
"requirePragma": false,
"trailingComma": "none",
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"printWidth": 120
}

8
babel.config.js

@ -0,0 +1,8 @@
/** @type {import('@babel/core')} */
module.exports = {
env: {
test: {
presets: ['@babel/preset-env', '@babel/preset-typescript']
}
}
};

12
jest.config.js

@ -0,0 +1,12 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
testEnvironment: 'jsdom',
moduleFileExtensions: ['js', 'ts'],
verbose: true,
testEnvironmentOptions: {
url: 'http://localhost/'
},
modulePaths: ['<rootDir>/src'],
testMatch: ['<rootDir>/test/specs/**/*.(t|j)s'],
setupFilesAfterEnv: ['<rootDir>/test/setup.js']
};

78
package.json

@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Free and Open Source Web Builder Framework",
"version": "0.21.12",
"version": "0.21.13",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",
@ -40,22 +40,29 @@
"underscore": "^1.13.1"
},
"devDependencies": {
"@babel/cli": "^7.15.7",
"@babel/preset-typescript": "^7.16.7",
"@types/jest": "^28.1.1",
"@typescript-eslint/parser": "^5.22.0",
"@babel/cli": "7.24.8",
"@babel/preset-typescript": "7.24.7",
"@types/jest": "29.5.12",
"@types/markdown-it": "14.1.2",
"@typescript-eslint/eslint-plugin": "8.0.1",
"@typescript-eslint/parser": "8.0.1",
"@vuepress/plugin-google-analytics": "^1.8.2",
"@vuepress/types": "^1.9.10",
"documentation": "^13.2.5",
"eslint": "^8.12.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.8.0",
"eslint-plugin-prettier": "5.1.3",
"grapesjs-cli": "^4.1.3",
"html-entities": "^1.4.0",
"husky": "^2.7.0",
"jest": "^24.9.0",
"lint-staged": "^8.2.1",
"jest": "29.7.0",
"jsdom": "24.1.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.4.1",
"postcss": "8",
"prettier": "3.3.3",
"sass": "^1.42.1",
"vuepress": "^1.8.2",
"typescript": "5.4.5",
"vuepress": "^1.9.10",
"whatwg-fetch": "^3.6.2"
},
"resolutions": {
@ -73,55 +80,15 @@
"site",
"builder"
],
"babel": {
"env": {
"test": {
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
]
}
}
},
"lint-staged": {
"{src,test}/**/*.(t|j)s": [
"eslint --ext .ts,.js --fix",
"prettier --single-quote --print-width 120 --arrow-parens avoid --write",
"git add"
]
},
"jest": {
"moduleFileExtensions": [
"js",
"ts"
],
"verbose": true,
"testURL": "http://localhost/",
"modulePaths": [
"<rootDir>/src"
],
"testMatch": [
"<rootDir>/test/specs/**/*.(t|j)s"
],
"setupFiles": [
"<rootDir>/test/setup.js"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"scripts": {
"docs": "vuepress dev docs",
"docs:api": "node docs/api.js",
"docs:build-vp": "vuepress build docs",
"docs:build": "npm run docs:api && npm run docs:build-vp",
"docs:deploy": "docs/deploy.sh",
"lint": "eslint . --ext .ts,.js && npm run lint:ts",
"check": "npm run lint && npm run test",
"lint": "eslint .",
"lint:ts": "tsc --noEmit",
"build": "npm run check && npm run build-all && npm run ts:check",
"build": "npm run build-all && npm run ts:check",
"build-all": "run-s build:*",
"build:js": "grapesjs-cli build --targets=\"> 1%, ie 11, safari 8, not dead\" --statsOutput=\"stats.json\" --localePath=\"src/i18n/locale\"",
"build:mjs": "BUILD_MODULE=true grapesjs-cli build --dts='skip' --patch=0 --targets=\"> 1%, ie 11, safari 8, not dead\"",
@ -132,8 +99,9 @@
"start": "run-p start:*",
"start:js": "grapesjs-cli serve",
"start:css": "npm run build:css -- --watch",
"format": "prettier --single-quote --write './{src,test}/**/*.js'",
"test": "jest",
"format": "prettier . --write",
"format:check": "prettier . --check",
"test": "jest --forceExit",
"test:dev": "jest --watch"
}
}

16
tsconfig.json

@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"sourceMap": true,
"skipLibCheck": true,
@ -18,10 +14,8 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false
"noEmit": false,
"outDir": "./dist"
},
"include": [
"src",
"test"
]
}
"include": ["src", "test"]
}

6234
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save