Browse Source

Update eslint config

- Move to manageble private package
- Ensure '.vue' rules are used via override
- Add support for TypeScript
- Update AP config to install correctly
master
Futago-za Ryuu 2 years ago
parent
commit
f00b516cd7
  1. 11
      .eslintrc.js
  2. 3
      azure-pipelines.yml
  3. 21
      docs/.vuepress/.eslintrc.js
  4. 4
      package.json
  5. 13
      tools/eslint-config/javascript.js
  6. 81
      tools/eslint-config/overrides/typescript.js
  7. 18
      tools/eslint-config/overrides/vue.js
  8. 16
      tools/eslint-config/package.json

11
.eslintrc.js

@ -1,13 +1,12 @@
"use strict";
const ts = require( "eslint-config-pegjs/overrides/typescript" )( __dirname );
const vue = require( "eslint-config-pegjs/overrides/vue" );
module.exports = {
"extends": "futagozaryuu/node-v6",
"extends": "pegjs",
"overrides": [ ts, vue ],
"root": true,
"rules": {
"no-eval": 0,
},
};

3
azure-pipelines.yml

@ -13,6 +13,9 @@ variables:
jobs:
- template: eslint.yml@apt
parameters:
install_scope: 'yarn'
job_script: 'yarn lint'
- template: node-test.yml@apt
parameters:

21
docs/.vuepress/.eslintrc.js

@ -1,21 +0,0 @@
"use strict";
module.exports = {
"extends": "plugin:vue/recommended",
"parserOptions": {
// plugin:vue/recommended set's this to "module" for some reason...
"sourceType": "script"
},
"rules": {
"vue/html-indent": [ "error", 4 ],
"vue/singleline-html-element-content-newline": 0,
},
};

4
package.json

@ -7,7 +7,7 @@
"test"
],
"scripts": {
"lint": "eslint --ext .js,.vue . docs/.vuepress",
"lint": "eslint --ext .js,.ts,.vue . docs/.vuepress",
"spec": "mocha --reporter progress",
"benchmark": "node tools/benchmark",
"build-docs": "vuepress build docs",
@ -24,8 +24,6 @@
"dependencies": {
"codecov": "3.3.0",
"eslint": "5.16.0",
"eslint-config-futagozaryuu": "5.8.0",
"eslint-plugin-vue": "5.2.2",
"mocha": "6.1.3",
"mocha-junit-reporter": "1.22.0",
"mocha-multi-reporters": "1.1.7",

13
tools/eslint-config/javascript.js

@ -0,0 +1,13 @@
"use strict";
module.exports = {
"extends": "futagozaryuu/node-v6",
"rules": {
"no-duplicate-imports": [ "error", { "includeExports": false } ],
"no-eval": 0,
},
};

81
tools/eslint-config/overrides/typescript.js

@ -0,0 +1,81 @@
"use strict";
const path = require( "path" );
const config = {
...require( "eslint-config-futagozaryuu/stylistic-issues" ).rules,
...require( "eslint-config-futagozaryuu/variables" ).rules,
...require( "eslint-config-futagozaryuu/es2015" ).rules,
};
function ts( cwd ) {
const ts = require( "@typescript-eslint/eslint-plugin/dist/configs/base.json" );
ts.files = [ "*.ts" ];
ts.parserOptions = {
"project": path.join( cwd, "tsconfig.json" ),
"sourceType": "module",
};
ts.rules = {
...require( "@typescript-eslint/eslint-plugin/dist/configs/recommended.json" ).rules,
...require( "@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended" ).default.overrides[ 0 ].rules,
"strict": "off",
"node/no-unsupported-features/es-syntax": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/indent": config.indent,
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-delimiter-style": [ "error", {
"multiline": {
"delimiter": "semi",
"requireLast": true,
},
"singleline": {
"delimiter": "semi",
"requireLast": true,
},
} ],
"@typescript-eslint/member-naming": [ "warn", {
"private": "^_",
} ],
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-array-constructor": config[ "no-array-constructor" ],
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-extraneous-class": [ "error", {
"constructorOnly": true,
"allowEmpty": false,
"staticOnly": false,
} ],
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-type-alias": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": config[ "no-use-before-define" ],
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": config[ "no-useless-constructor" ],
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/prefer-interface": "off",
"@typescript-eslint/explicit-function-return-type": [ "error", {
allowExpressions: true,
} ],
};
return ts;
}
module.exports = ts;

18
tools/eslint-config/overrides/vue.js

@ -0,0 +1,18 @@
"use strict";
const vue = require( "eslint-plugin-vue/lib/configs/base" );
vue.files = [ "*.vue" ];
Object.assign( vue.rules, {
...require( "eslint-plugin-vue/lib/configs/essential" ).rules,
...require( "eslint-plugin-vue/lib/configs/strongly-recommended" ).rules,
...require( "eslint-plugin-vue/lib/configs/recommended" ).rules,
"vue/html-indent": [ "error", 4 ],
"vue/singleline-html-element-content-newline": 0,
} );
module.exports = vue;

16
tools/eslint-config/package.json

@ -0,0 +1,16 @@
{
"name": "eslint-config-pegjs",
"version": "2.3.0",
"private": true,
"main": "javascript.js",
"dependencies": {
"@typescript-eslint/eslint-plugin": "1.9.1-alpha.26",
"@typescript-eslint/parser": "1.9.1-alpha.26",
"eslint-config-futagozaryuu": "5.8.0",
"eslint-plugin-vue": "5.2.2",
"typescript": "3.5.1"
},
"engines": {
"node": ">= 6"
}
}
Loading…
Cancel
Save