nikku / eslint-plugin-license-header

Rules to validate the presence of license headers in source files.
MIT License
27 stars 9 forks source link

Passing header as string doesn't work #18

Closed philippfromme closed 1 month ago

philippfromme commented 1 month ago

Describe the Bug

Passing the header as a string will result in the plugin treating it as a path to read from.

Steps to Reproduce

Doesn't work:

import licenseHeaderPlugin from 'eslint-plugin-license-header';

import apacheLicenseHeader from '../resources/apache-license-header.js'

export default [
  {
    plugins: {
      'license-header': licenseHeaderPlugin
    },
    rules: {
      'license-header/header': [2, apacheLicenseHeader]
    }
  }
]

Works:

import licenseHeaderPlugin from 'eslint-plugin-license-header';

import apacheLicenseHeader from '../resources/apache-license-header.js'

export default [
  {
    plugins: {
      'license-header': licenseHeaderPlugin
    },
    rules: {
      'license-header/header': [2, apacheLicenseHeader.split('\n')]
    }
  }
]

Expected Behavior

Passing header as string instead of array of strings works as to be expected from the name of the variable pathOrLicense.

nikku commented 1 month ago

To my knowledge this works, in according to the specification. What are you missing?

philippfromme commented 1 month ago

I guess it works as expected then. I just stumbled over the fact I have to .split('\n') my header,