Skip to content

Commit

Permalink
- Linting: No longer necessary to disable prettier on vue files; drop…
Browse files Browse the repository at this point in the history
… TS resolver on non-TS files (though make exception where needed)

- Linting: Comment blocks; enable no-unregistered-components rule; remove now redundant or unneeded rules
- Linting: Remove plugin/parser redundant with typescript-eslint config
  • Loading branch information
brettz9 committed Nov 12, 2020
1 parent 47ca5c8 commit cf36356
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 58 deletions.
94 changes: 43 additions & 51 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

// Non-TS base
const baseConfigs = [
'ash-nazg/sauron',
'plugin:vue/vue3-recommended',
Expand All @@ -8,20 +9,27 @@ const baseConfigs = [
'plugin:prettier/recommended',
]

// TS base
const baseTSConfigs = [
...baseConfigs,
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
]

// Todo: Remove this in favor of `baseTSConfigs` when TS working in Vue files
const baseConfigsNoTS = baseTSConfigs.filter(c => !c.includes('@typescript-eslint'))

// `eslint-plugin-vue` rules
const vueRules = {
// Disabling as Vue linter won't catch (and we are requiring `name` anyways)
'import/no-anonymous-default-export': 'off',

// Temporarily disable
'vue/no-boolean-default': 'off',
'vue/no-mutating-props': 'off',
'vue/require-default-prop': 'off',
'vue/no-boolean-default': 'off', // Enable?
'vue/no-mutating-props': 'off', // Enable?
'vue/require-default-prop': 'off', // Enable?
// 'vue/no-duplicate-attr-inheritance': ['error'], // Enforce?
// 'vue/no-static-inline-styles': ['error'], // Use later; require in <style>
/*
'vue/no-unused-properties': [
'error',
Expand All @@ -32,14 +40,11 @@ const vueRules = {
],
*/
// 'vue/no-bare-strings-in-template': ['error'], // Use later i18nizing
// 'vue/no-static-inline-styles': ['error'], // Revisit later
// 'vue/no-unregistered-components': ['error'],
// 'vue/html-comment-indent': ['error'],
// 'vue/no-duplicate-attr-inheritance': ['error'],
// 'vue/html-comment-indent': ['error'], // Possibly too oppressive

// Disable
'vue/attributes-order': 'off',
'vue/max-attributes-per-line': 'off',
'vue/attributes-order': 'off', // Oppressive
'vue/max-attributes-per-line': 'off', // A bit oppressive

'vue/block-tag-newline': ['error'],
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
Expand All @@ -53,6 +58,7 @@ const vueRules = {
'vue/no-reserved-component-names': ['error'],
'vue/no-restricted-component-options': ['error', 'data', 'computed', 'methods', 'watch'],
'vue/no-template-target-blank': ['error', { allowReferrer: true }],
'vue/no-unregistered-components': ['error'],
'vue/no-unsupported-features': ['error', { version: '^3.0.0' }],
'vue/no-useless-mustaches': ['error'],
'vue/no-useless-v-bind': ['error'],
Expand Down Expand Up @@ -82,30 +88,22 @@ const baseRules = {
// Keep this here so can uncomment to check inline disabling
// "eslint-comments/no-use": "error",

// Reapply from ash-nazg
semi: ['error', 'never'],
quotes: ['error', 'single'],
indent: ['error', 2],
curly: ['error'],
'block-spacing': ['error'],
'comma-spacing': ['error'],
'eol-last': ['error'],
'key-spacing': ['error'],
'keyword-spacing': ['error'],
'no-extra-semi': ['error'],
'no-trailing-spaces': ['error'],
'no-tabs': ['error'],
'no-multi-spaces': ['error'],
'nonblock-statement-body-position': ['error'],
'object-curly-spacing': ['error', 'always'],
'space-before-blocks': ['error'],
'space-infix-ops': ['error'],
// Simplifying
'import/extensions': 'off',

// Disabling for now
'max-len': 'off', // ['warn', { code: 80 }],
'jsdoc/require-jsdoc': 'off',
'require-unicode-regexp': 'off',
'prefer-named-capture-group': 'off',

// More consistent styling of WS before exports
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: ['const', 'let'], next: 'export' },
],
// semi: ['error', 'never'],

// Wasteful to use all named imports
'no-restricted-syntax': [
'error',
{
Expand All @@ -115,13 +113,6 @@ const baseRules = {
'which are needed (or switch to a default import).',
},
],

// Disabling for now
'max-len': 'off', // ['warn', { code: 80 }],
'import/extensions': 'off',
'jsdoc/require-jsdoc': 'off',
'require-unicode-regexp': 'off',
'prefer-named-capture-group': 'off',
}

module.exports = {
Expand All @@ -138,17 +129,22 @@ module.exports = {
ecmaVersion: 2020,
},
overrides: [
// Node.js config files (non-Vue, non-TS)
{
files: [
'.eslintrc.js',
'.stylelintrc.js',
'.ncurc.js',
'postcss.config.js',
'webpack.config.js',
'.3rdparty-eslintrc.js',
'.np-config.js',
],
extends: baseConfigs,
extends: [
'ash-nazg/sauron-node',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:prettier/recommended',
],
env: {
node: true,
},
Expand All @@ -164,27 +160,24 @@ module.exports = {
},
rules: {
...baseRules,

// CommonJS:
strict: ['error', 'global'],
'import/no-commonjs': 'off',
},
},
// TS files
{
files: '*.ts',
extends: baseTSConfigs,
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
rules: {
...baseRules,
// Reenable later
'eslint-comments/require-description': 0,
'eslint-comments/no-unused-disable': 0,

// Possible non-recommended items to enable?
// '@typescript-eslint/no-unsafe-assignment': ['error'],
// '@typescript-eslint/no-unsafe-member-access': ['error'],
// '@typescript-eslint/no-unsafe-return': ['error'],
// '@typescript-eslint/naming-convention': ['error'],
// Reenable later?
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/naming-convention': ['error'],
},
},
{
Expand All @@ -196,17 +189,16 @@ module.exports = {
'import/unambiguous': 'off',
},
},
// Vue SFC files
{
files: '*.vue',
extends: baseConfigs,
plugins: ['@pathscale/vue3'],
extends: baseConfigsNoTS,
// Need `vue` `parser` and `plugins` re-added since adding `vue3`
parser: require.resolve('vue-eslint-parser'),
plugins: ['vue', '@pathscale/vue3'],
rules: {
...baseRules,
...vueRules,
// Reapply to better match prettier
'arrow-parens': ['error', 'as-needed'],
// 'comma-dangle': ['error', 'always'], // Interferes with arrow-parens
'space-before-function-paren': ['error', 'never'],

'@pathscale/vue3/v-directive': [
'error',
Expand Down
3 changes: 3 additions & 0 deletions helper/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export function getWhitelist(input: string): { always?: string[], optional?: str
// parent
// },

/* eslint-disable @typescript-eslint/naming-convention -- AST */
StringLiteral({ node }) {
if (!isVueSFC(id)) return
for (const cl of node.value.split(' ')) {
Expand All @@ -131,6 +132,8 @@ export function getWhitelist(input: string): { always?: string[], optional?: str
const depId = resolveSource(id, node.source.value)
if (depId) idList.push(depId)
},

/* eslint-enable @typescript-eslint/naming-convention -- AST */
})
}

Expand Down
10 changes: 5 additions & 5 deletions helper/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export const textual = {
figureClasses: undefined,
imgClasses: undefined,
// Functions
columnClasses: () => undefined,
selectedClasses: () => undefined,
cellClasses: () => undefined,
tabClasses: () => undefined,
labelClasses: () => undefined,
columnClasses: () : void => undefined,
selectedClasses: () : void => undefined,
cellClasses: () : void => undefined,
tabClasses: () : void => undefined,
labelClasses: () : void => undefined,
}

export const truthy = {
Expand Down
1 change: 1 addition & 0 deletions helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ async function main(): Promise<void> {

const ast = jsparserParse(inputCode, parserOpts)
traverse(ast, {
// eslint-disable-next-line @typescript-eslint/naming-convention -- AST
ExportNamedDeclaration({ node }) {
if (!node.source) return
const { value } = node.source
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
"ts-node": "^9.0.0",
"tslib": "^2.0.3",
"typescript": "^4.0.3",
"vue": "^3.0.0"
"vue": "^3.0.0",
"vue-eslint-parser": "^7.1.1"
},
"peerDependencies": {
"vue": "^3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/components/compounds/Table/DataGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DataGrid {
this.originalRows.splice(index, 1)
}

// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line class-methods-use-this -- Convenient on instance
editCell(row: Row, column: Column, newValue: string | number): void {
row[column.name] = newValue
}
Expand Down

0 comments on commit cf36356

Please sign in to comment.