Skip to content

Commit

Permalink
feat: support linter (apache#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyeYoung authored Mar 30, 2022
1 parent 98ff9ea commit ce2909a
Show file tree
Hide file tree
Showing 7 changed files with 1,455 additions and 49 deletions.
12 changes: 12 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/website/src/static/js/**/*.js
/website/src/assets
/website/src/fonts
/website/src/shaders
/website/.docusaurus
/website/articles
/website/blog
/website/build
/website/docs
/website/docs-apisix*
/website/i18n
yarn.lock
94 changes: 94 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
const OFF = 0;
const WARNING = 1;
const ERROR = 2;

module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
'plugin:react/recommended',
'airbnb',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'react',
'@typescript-eslint',
],
rules: {
quotes: [ERROR, 'single', { allowTemplateLiterals: true }],
'no-unused-vars': OFF,
'@typescript-eslint/no-unused-vars': [ERROR, { ignoreRestSiblings: true }],
'@typescript-eslint/ban-ts-comment': [
ERROR,
{ 'ts-expect-error': 'allow-with-description' },
],
'@typescript-eslint/consistent-indexed-object-style': [
WARNING,
'index-signature',
],
'@typescript-eslint/consistent-type-imports': [
WARNING,
{ disallowTypeAnnotations: false },
],
'@typescript-eslint/explicit-module-boundary-types': WARNING,
'@typescript-eslint/method-signature-style': ERROR,
'@typescript-eslint/no-empty-function': OFF,
'@typescript-eslint/no-empty-interface': [
ERROR,
{ allowSingleExtends: true },
],
'@typescript-eslint/no-inferrable-types': OFF,
'@typescript-eslint/no-namespace': [WARNING, { allowDeclarations: true }],
'no-use-before-define': OFF,
'@typescript-eslint/no-use-before-define': [
ERROR,
{ functions: false, classes: false, variables: true },
],
'@typescript-eslint/no-non-null-assertion': OFF,
'no-redeclare': OFF,
'@typescript-eslint/no-redeclare': ERROR,
'no-shadow': OFF,
'@typescript-eslint/no-shadow': ERROR,
'import/no-unresolved': [
ERROR,
{
ignore: [
'^@theme',
'^@docusaurus',
'^@generated',
'^@site',
'^@testing-utils',
],
},
],
},
overrides: [
{
files: [
'scripts/**/*.js',
'website/src/clientModules/**/*.js',
],
env: {
node: true,
amd: true,
},
},
{
files: ['*.yaml', '*.yml'],
extends: [
'plugin:yml/standard',
],
parser: 'yaml-eslint-parser',
},
],
};
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
8 changes: 8 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "stylelint-config-standard",
"rules": {
"selector-type-case": "lower",
"selector-class-pattern": null,
"property-no-vendor-prefix": true
}
}
23 changes: 22 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@
"update-sitemap": "yarn workspace scripts update-sitemap",
"start": "yarn workspace website start",
"build": "yarn workspace website build",
"docusaurus": "yarn workspace website docusaurus"
"docusaurus": "yarn workspace website docusaurus",
"prepare": "husky install"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"eslint": "^8.2.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-yml": "^0.14.0",
"husky": ">=6",
"lint-staged": ">=10",
"stylelint": "^14.6.1",
"stylelint-config-standard": "^25.0.0"
},
"lint-staged": {
"*.{js, jsx, ts, tsx}": "eslint --cache --fix",
"*.{yml, yaml}": "eslint --cache --fix",
"*.css": "stylelint --cache --fix"
}
}
Loading

0 comments on commit ce2909a

Please sign in to comment.