Skip to content

Commit

Permalink
Cleanup eslint config (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Jun 21, 2021
1 parent 00592c8 commit 354a632
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 112 deletions.
57 changes: 40 additions & 17 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"security"
],
"plugins": ["@typescript-eslint", "security"],
"env": {
"browser": true
},
Expand All @@ -13,6 +10,9 @@
"webpack": {
"config": "./browsers/webpack.config.js"
}
},
"react": {
"version": "detect"
}
},
"extends": [
Expand All @@ -21,12 +21,15 @@
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:security/recommended"

// TODO: Restore these after https://github.com/benmosher/eslint-plugin-import/issues/1931
// "plugin:import/errors",
// "plugin:import/warnings",
],
"rules": {
"@typescript-eslint/no-empty-function": "off",
"react/prop-types": "off",
"@typescript-eslint/ban-types": ["warn"],
"@typescript-eslint/no-unused-vars": [
Expand All @@ -41,19 +44,39 @@
}
],
"@typescript-eslint/no-explicit-any": ["warn"],
"@typescript-eslint/ban-ts-comment": ["error", {
"ts-ignore": "allow-with-description",
"minimumDescriptionLength": 3
}]
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-ignore": "allow-with-description",
"minimumDescriptionLength": 3
}
]
},
"ignorePatterns": [
"browsers/chrome/webpack/**",
"browsers/firefox/webpack/**",
"browsers/webpack.config.js",
"scripts/webpack.scripts.js",
"src/vendors/libraryDetector/**",
"src/**/*.test.ts",
"src/**/*.test.js",
"node_modules",
".idea",
"browsers/dist",
"artifacts",
"scripts/bin",
"src/vendors",
"src/support.js"
],
"overrides": [
{
"files": [
"webpack.*.js",
"*.config.js",
"test-env.js",
"**/__mocks__/**",
"*.test.js"
],
"env": {
"node": true,
"jest": true
},
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
17 changes: 17 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,20 @@ jobs:
name: brick-headers
path: headers.json
retention-days: 5

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "14.x"
- uses: bahmutov/npm-install@v1
# Run eslint without GitHub Actions annotations
# https://stackoverflow.com/a/65964721/288906
- name: npm run lint
run: |
echo "::remove-matcher owner=eslint-compact::"
echo "::remove-matcher owner=eslint-stylish::"
npm run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ db.sqlite3
.env
.env.*
staticfiles
.vscode

# User-specific stuff:
.idea/workspace.xml
Expand Down
4 changes: 4 additions & 0 deletions browsers/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ module.exports = (env, options) => ({
type: "json", // Required by Webpack v4
use: "yaml-loader",
},
{
test: /\.txt/,
type: "asset/source",
},
],
},
});
88 changes: 12 additions & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test": "jest",
"test:watch": "jest --watchAll",
"lint": "eslint src/**",
"lint": "eslint src",
"watch": "ENV_FILE='.env.development' webpack --mode development --config browsers/webpack.config.js --watch",
"build": "NODE_OPTIONS=--max_old_space_size=8192 webpack --mode production --config browsers/webpack.config.js",
"build:scripts": "webpack --mode production --config scripts/webpack.scripts.js",
Expand Down Expand Up @@ -156,7 +156,7 @@
"@types/webpack-env": "^1.16.0",
"@types/yup": "^0.29.11",
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.20.0",
"@typescript-eslint/parser": "^4.27.0",
"axios-mock-adapter": "^1.19.0",
"babel-jest": "^27.0.2",
"compass-mixins": "^0.12.10",
Expand Down
1 change: 0 additions & 1 deletion src/devTools/editor/SelectorSelectorField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { Framework } from "@/messaging/constants";
import { reportError } from "@/telemetry/logging";

// eslint is complaining that it can't parse the Option file
// eslint-disable-next-line import/namespace
import { OptionProps } from "react-select/src/components/Option";
import { useToasts } from "react-toast-notifications";

Expand Down
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function engineRenderer(
}

// first part of the path can be global context with a @
const pathRegex = /^(@?[a-zA-Z0-9_\-]+\??)(\.[a-zA-Z0-9_\-]+\??)*$/;
const pathRegex = /^(@?[a-zA-Z0-9_-]+\??)(\.[a-zA-Z0-9_-]+\??)*$/;

/**
* Return true if maybePath refers to a property in ctxt.
Expand Down
5 changes: 5 additions & 0 deletions src/import-svg.d.ts → src/import-assets.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ declare module "*.svg" {
const value: any;
export default value;
}

declare module "*.txt" {
const value: string;
export default value;
}
22 changes: 7 additions & 15 deletions src/options/pages/brickEditor/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@ import Select from "react-select";
import React, { useState, useRef, Suspense, useEffect } from "react";
import { useField, useFormikContext } from "formik";

// https://webpack.js.org/loaders/raw-loader/#examples
const serviceTemplate = require("raw-loader!@contrib/templates/service.txt?esModule=false")
.default;
const emberjsTemplate = require("raw-loader!@contrib/templates/reader-emberjs.txt?esModule=false")
.default;
const jqueryTemplate = require("raw-loader!@contrib/templates/reader-jquery.txt?esModule=false")
.default;
const reactTemplate = require("raw-loader!@contrib/templates/reader-react.txt?esModule=false")
.default;
const menuTemplate = require("raw-loader!@contrib/templates/foundation-menu-item.txt?esModule=false")
.default;
const panelTemplate = require("raw-loader!@contrib/templates/foundation-panel.txt?esModule=false")
.default;
const blueprintTemplate = require("raw-loader!@contrib/templates/blueprint-menu.txt?esModule=false")
.default;
import serviceTemplate from "@contrib/templates/service.txt";
import emberjsTemplate from "@contrib/templates/reader-emberjs.txt";
import jqueryTemplate from "@contrib/templates/reader-jquery.txt";
import reactTemplate from "@contrib/templates/reader-react.txt";
import menuTemplate from "@contrib/templates/foundation-menu-item.txt";
import panelTemplate from "@contrib/templates/foundation-panel.txt";
import blueprintTemplate from "@contrib/templates/blueprint-menu.txt";

const AceEditor = React.lazy(
() =>
Expand Down

0 comments on commit 354a632

Please sign in to comment.